Skip to content

Commit

Permalink
added version changes
Browse files Browse the repository at this point in the history
  • Loading branch information
swatiawate1 committed Oct 30, 2024
1 parent 0c953d0 commit aacbea4
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/main/java/com/cx/plugin/utils/CxPluginUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public static void printConfiguration(CxScanConfig config, String[] osaIgnoreSco
log.info("Policy violations enabled: " + config.getEnablePolicyViolations());
log.info("CxSAST thresholds enabled: " + config.getSastThresholdsEnabled());
if (config.getSastThresholdsEnabled()) {
if (config.getSastCriticalThreshold()!=null) {
Double version = getSASTVersion(config, log);
// Check if SAST version supports critical threshold
if (version >= 9.7) {
log.info("CxSAST critical threshold: " + (config.getSastCriticalThreshold() == null ? "[No Threshold]"
: config.getSastCriticalThreshold()));
}
Expand All @@ -100,6 +102,25 @@ public static void printConfiguration(CxScanConfig config, String[] osaIgnoreSco
//todo check log.info("fileExclusions: " + Arrays.toString(fileExclusions));
}

private static Double getSASTVersion(CxScanConfig config, Logger log) {
String cxServerUrl = config.getUrl();
String cxUser = config.getUsername();
String cxPass = config.getPassword();
Double version = 9.0;
String sastVersion;
// Fetch SAST version using API call
try {
sastVersion = SASTUtils.loginToServer(new URL(cxServerUrl), cxUser, cxPass);
String[] sastVersionSplit = sastVersion.split("\\.");
if(sastVersionSplit != null && sastVersionSplit.length > 1) {
version = Double.parseDouble(sastVersionSplit[0] + "." + sastVersionSplit[1]);
}
} catch (Exception e) {
log.error(e.getMessage());
}
return version;
}

public static void printBuildFailure(String thDescription, ScanResults ret, Logger log) throws MojoFailureException
{
StringBuilder builder = new StringBuilder();
Expand Down

0 comments on commit aacbea4

Please sign in to comment.