Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jira1190 #140

Open
wants to merge 1 commit into
base: 2023_Q4_integration_branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dependencies {
exclude group: 'org.apache.logging.log4j', module: 'log4j-core'
}

compile ('com.checkmarx:cx-client-common:3.3.3') {
compile ('com.checkmarx:cx-client-common:4.4.4') {
exclude group: 'org.apache.commons', module: 'commons-compress'
exclude group: 'org.yaml' , module: 'snakeyaml'
exclude group: 'com.google.code.gson', module: 'gson'
Expand Down
48 changes: 46 additions & 2 deletions src/main/java/com/checkmarx/jenkins/CxScanBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,6 @@ public String getExcludeOpenSourceFolders() {
public void setExcludeOpenSourceFolders(@Nullable String excludeOpenSourceFolders) {
this.excludeOpenSourceFolders = excludeOpenSourceFolders;
}

@Nullable
public String getIncludeOpenSourceFolders() {
return includeOpenSourceFolders;
Expand Down Expand Up @@ -1773,6 +1772,8 @@ private AstScaConfig getScaConfig(Run<?, ?> run, EnvVars env, DependencyScanConf
result.setAccessControlUrl(dsConfig.scaAccessControlUrl);
result.setWebAppUrl(dsConfig.scaWebAppUrl);
result.setTenant(dsConfig.scaTenant);
result.setScaScanCustomTags(dsConfig.scaScanCustomTags);
result.setScaProjectCustomTags(dsConfig.scaProjectCustomTags);
result.setTeamPath(dsConfig.scaTeamPath);
result.setTeamId(dsConfig.scaTeamId);
result.setIncludeSources(dsConfig.isIncludeSources);
Expand Down Expand Up @@ -1927,6 +1928,8 @@ private void printConfiguration(CxScanConfig config, DescriptorImpl descriptor,
log.info("Team: " + config.getAstScaConfig().getTeamPath());
log.info("is generate SCA report: " + config.isGenerateScaReport());
log.info("Enable Sca Resolver: " + config.getAstScaConfig().isEnableScaResolver());
log.info("Project custom Tags for SCA: " + config.getAstScaConfig().getScaProjectCustomTags());
log.info("Scan custom Tags for SCA: " + config.getAstScaConfig().getScaScanCustomTags());
if (config.getAstScaConfig().isEnableScaResolver())
log.info("Enable Exploitable Path by Sca Resolver: " + ((dependencyScanConfig.overrideGlobalConfig)
? dependencyScanConfig.isExploitablePathByScaResolver
Expand Down Expand Up @@ -2409,6 +2412,7 @@ public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {
@Nullable
private String password;
private Integer projectRetentionRateEnforce;

private String credentialsId;
private String mvnPath;
private boolean isProxy = true;
Expand Down Expand Up @@ -2873,6 +2877,46 @@ private boolean checkAnyMandatoryAddParams(String scaResolverAddParameters) {
|| scaResolverAddParameters.contains("--resolver-result-path"));
}

/**
* This method validates the SCA Project Custom Tags Parameters on UI.
*
* @param value: Indicates scaProjectCustomTags.
* @return FormValidation: Indicates the outcome of the validation and send to
* UI.
*/
@POST
public FormValidation doCheckScaProjectCustomTags(@QueryParameter String value,@AncestorInPath Item item) {
if (item == null) {
return FormValidation.ok();
}
item.checkPermission(Item.CONFIGURE);
Pattern pattern = Pattern.compile("(^([a-zA-Z0-9#._]*):([a-zA-Z0-9#._]*)+(,([a-zA-Z0-9#._]*):([a-zA-Z0-9#._]*)+)*$)");
Matcher match = pattern.matcher(value);
if (!StringUtil.isNullOrEmpty(value) && !match.find()) {
return FormValidation.error("Custom Fields must have given format: key1:val1,key2:val2. \nCustom field allows to use these special characters: # . _ ");
}
return FormValidation.ok();
}
/**
* This method validates the SCA Scan Custom Tags Parameters on UI.
*
* @param value: Indicates scaProjectCustomTags.
* @return FormValidation: Indicates the outcome of the validation and send to
* UI.
*/
@POST
public FormValidation doCheckScaScanCustomTags(@QueryParameter String value,@AncestorInPath Item item) {
if (item == null) {
return FormValidation.ok();
}
item.checkPermission(Item.CONFIGURE);
Pattern pattern = Pattern.compile("(^([a-zA-Z0-9#._]*):([a-zA-Z0-9#._]*)+(,([a-zA-Z0-9#._]*):([a-zA-Z0-9#._]*)+)*$)");
Matcher match = pattern.matcher(value);
if (!StringUtil.isNullOrEmpty(value) && !match.find()) {
return FormValidation.error("Custom Fields must have given format: key1:val1,key2:val2. \nCustom field allows to use these special characters: # . _ ");
}
return FormValidation.ok();
}

/**
* This method validates the SCA Resolver Additional Parameters on UI.
Expand All @@ -2883,7 +2927,7 @@ private boolean checkAnyMandatoryAddParams(String scaResolverAddParameters) {
* UI.
*/
@POST
public FormValidation doCheckScaResolverAddParameters(@QueryParameter String value,
public FormValidation doCheckResolverAddParameters(@QueryParameter String value,
@QueryParameter boolean isExploitablePathByScaResolver) {
String warnMessage = "";
String errorMessage = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ public class DependencyScanConfig {

@DataBoundSetter
public String scaTeamPath;


@DataBoundSetter
public String scaScanCustomTags;

@DataBoundSetter
public String scaProjectCustomTags;

@DataBoundSetter
public String scaTeamId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@
<f:entry title="Teampath" field="scaTeamPath">
<f:textbox value="${instance.dependencyScanConfig.scaTeamPath}"/>
</f:entry>
<f:entry title="Project Custom Tags" field="scaProjectCustomTags">
<f:textbox value="${instance.dependencyScanConfig.scaProjectCustomTags}"/>
</f:entry>
<f:entry title="Scan Custom Tags" field="scaScanCustomTags">
<f:textbox value="${instance.dependencyScanConfig.scaScanCustomTags}"/>
</f:entry>

<f:entry title="SCA Scan timeout (minutes)" field="scaTimeout">
<f:textbox value="${instance.dependencyScanConfig.scaTimeout}"/>
Expand Down Expand Up @@ -278,7 +284,7 @@
<f:optionalBlock title="Generate CxSAST PDF report" inline="true" field="generatePdfReport" />

<!-- -= enableProjectPolicyEnforcement =- -->
<f:optionalBlock title="Enable Project's policy enforcement for SAST" inline="true" field="enableProjectPolicyEnforcementSAST" />
<f:optionalBlock title="Enable Project's policy enforcement for SAST" inline="true" field="enableProjectPolicyEnforcement" />
<f:optionalBlock title="Enable Project's policy enforcement for SCA" inline="true" field="enableProjectPolicyEnforcementSCA" />


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,14 @@
<f:entry title="Teampath" field="scaTeamPath">
<f:textbox value="${instance.dependencyScanConfig.scaTeamPath}"/>
</f:entry>


<f:entry title="Project Custom Tags" field="scaProjectCustomTags">
<f:textbox value="${instance.dependencyScanConfig.scaProjectCustomTags}"/>
</f:entry>
<f:entry title="Scan Custom Tags" field="scaScanCustomTags">
<f:textbox value="${instance.dependencyScanConfig.scaScanCustomTags}"/>
</f:entry>

<f:entry title="SCA Scan timeout (minutes)" field="scaTimeout">
<f:textbox value="${descriptor.dependencyScanConfig.scaTimeout}"/>
</f:entry>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
A project tag is a key:value pair, and multiple tags can be seperated using comma(,).(E.g: a:b, c:d)
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
A scan tag is a key:value pair, and multiple tags can be seperated using comma(,).(E.g: a:b, c:d)
</div>