Skip to content

Commit

Permalink
Jira new labels DEV or PROD (#1272)
Browse files Browse the repository at this point in the history
* Jira new labels DEV or PROD

* test case updated

* test case updated

* SCA Test case Fix

* Fix for testcase

* Test Null ptr exception fix

---------

Co-authored-by: satyamchaurasiapersistent <[email protected]>
  • Loading branch information
itsKedar and satyamchaurasiapersistent authored Sep 9, 2023
1 parent 1b9d381 commit f3bf3d5
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build-11.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
ext {


CxSBSDK = "0.5.56"
CxSBSDK = "0.5.59"
ConfigProviderVersion = "1.0.9"
//cxVersion = "8.90.5"
springBootVersion = '2.7.14'
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ buildscript {
ext {


CxSBSDK = "0.5.56"
CxSBSDK = "0.5.59"
ConfigProviderVersion = "1.0.10"
//cxVersion = "8.90.5"
springBootVersion = '2.7.14'
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/checkmarx/flow/CxFlowRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ private void commandLineRunner(ApplicationArguments args) throws ExitThrowable {
boolean usingBitBucketCloud = args.containsOption("bb");
boolean usingBitBucketServer = args.containsOption("bbs");
boolean disableCertificateValidation = args.containsOption("trust-cert");
boolean disablePolicyViolation = args.containsOption("sca-policy-disable");
disableBreakbuild=args.containsOption("disable-break-build");
branchProtectionEnabled = args.containsOption("branch-protection-enabled");
sbom = args.containsOption("sbom");
Expand Down Expand Up @@ -381,6 +382,7 @@ private void commandLineRunner(ApplicationArguments args) throws ExitThrowable {
.commentSAST(commentSAST)
.disableBreakbuild(disableBreakbuild)
.sbom(sbom)
.disablePolicyViolation(disablePolicyViolation)
.build();

if (projectId != null) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/checkmarx/flow/dto/ScanRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public class ScanRequest {
@Getter @Setter
private String scanResubmit;
private Boolean incremental;
@Getter @Setter
private Boolean disablePolicyViolation=true;
private String scanPreset;

/**
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/checkmarx/flow/service/JiraService.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public class JiraService {
private static final String ACCOUNT_ID = "accountId";
private static final String JIRA_ISSUE_LABEL_SCA = "scanner:SCA";
private static final String JIRA_ISSUE_LABEL_SAST = "scanner:SAST";
private static final String JIRA_DEV_LABEL ="DEV";
private static final String JIRA_PROD_LABEL ="PROD";
private static final String CASCADE_PARENT_CHILD_DELIMITER = ";";
private static final int MAX_RESULTS_ALLOWED = 1000000;
private static final String SEARCH_ASSIGNABLE_USER = "%s/rest/api/latest/user/assignable/search?project={projectKey}&query={assignee}";
Expand Down Expand Up @@ -368,6 +370,13 @@ public String createIssue(ScanResults.XIssue issue, ScanRequest request) throws
}
if (null != scaDetails) {
labels.add(JIRA_ISSUE_LABEL_SCA);
if(issue.getScaDetails().get(0).getVulnerabilityPackage().isIsDevelopmentDependency() || issue.getScaDetails().get(0).getVulnerabilityPackage().isIsTestDependency())
{
labels.add(JIRA_DEV_LABEL);
}
else{
labels.add(JIRA_PROD_LABEL);
}
}else{
labels.add(JIRA_ISSUE_LABEL_SAST);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ private boolean isAllowedSca(ScanResults scanResults, ScanRequest request) {
boolean isAllowedSca;
// isPolicyViolated flag gets the top priority whether to the break build or not
SCAResults scaResults = scanResults.getScaResults();
if (scaResults.isPolicyViolated()) {
if(request!=null && request.getDisablePolicyViolation()){
scaProperties.setEnablePolicyViolation(false);
}
if (scaResults.isPolicyViolated() && scaProperties.isEnablePolicyViolation()) {
printViolatedPoliciesNames(scaResults.getViolatedPolicies());
isAllowedSca = false;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void runningWithBreakBuild(String input) {
setFilters("High");
switch (input) {
case "success":
commandBuilder.append("--scan --severity=High --app=MyApp --cx-project=test").append(GITHUB_REPO_ARGS);
commandBuilder.append("--scan --sca-policy-disable=true --severity=High --app=MyApp --cx-project=test").append(GITHUB_REPO_ARGS);
scaProperties.setThresholdsScore(10.0);
break;
case "break-build":
Expand Down

0 comments on commit f3bf3d5

Please sign in to comment.