Skip to content

Commit

Permalink
Fixed upgrade issues
Browse files Browse the repository at this point in the history
  • Loading branch information
GhannamZ committed Oct 24, 2020
1 parent 46f22bf commit c2c8a18
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
description = Provides automatic scan of code by Checkmarx server and shows results summary and trend in Jenkins interface.
group = com.checkmarx.jenkins
version = 2020.4.2
version = 2020.4.3

repositoryVersion=

Expand Down
47 changes: 46 additions & 1 deletion src/main/java/com/checkmarx/jenkins/CxScanBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,11 @@ public boolean isOsaEnabled() {
return osaEnabled;
}

@DataBoundSetter
public void setOsaEnabled(boolean osaEnabled) {
this.osaEnabled = osaEnabled;
}

@Nullable
public Integer getOsaHighThreshold() {
return osaHighThreshold;
Expand Down Expand Up @@ -468,21 +473,41 @@ public String getExcludeOpenSourceFolders() {
return excludeOpenSourceFolders;
}

@DataBoundSetter
public void setExcludeOpenSourceFolders(@Nullable String excludeOpenSourceFolders) {
this.excludeOpenSourceFolders = excludeOpenSourceFolders;
}

@Nullable
public String getIncludeOpenSourceFolders() {
return includeOpenSourceFolders;
}

@DataBoundSetter
public void setIncludeOpenSourceFolders(@Nullable String includeOpenSourceFolders) {
this.includeOpenSourceFolders = includeOpenSourceFolders;
}

@Nullable
public String getOsaArchiveIncludePatterns() {
return osaArchiveIncludePatterns;
}

@DataBoundSetter
public void setOsaArchiveIncludePatterns(@Nullable String osaArchiveIncludePatterns) {
this.osaArchiveIncludePatterns = osaArchiveIncludePatterns;
}

@Nullable
public boolean isOsaInstallBeforeScan() {
return osaInstallBeforeScan;
}

@DataBoundSetter
public void setOsaInstallBeforeScan(boolean osaInstallBeforeScan) {
this.osaInstallBeforeScan = osaInstallBeforeScan;
}

public boolean isGeneratePdfReport() {
return generatePdfReport;
}
Expand Down Expand Up @@ -855,6 +880,17 @@ private CxScanConfig resolveConfiguration(Run<?, ?> run, DescriptorImpl descript
}
}

if (isOsaEnabled() && getDependencyScanConfig() == null) {
DependencyScanConfig config = new DependencyScanConfig();
config.overrideGlobalConfig = true;
config.dependencyScannerType = DependencyScannerType.OSA;
config.dependencyScanPatterns = getIncludeOpenSourceFolders();
config.dependencyScanExcludeFolders = getExcludeOpenSourceFolders();
config.osaArchiveIncludePatterns = getOsaArchiveIncludePatterns();
config.osaInstallBeforeScan = isOsaInstallBeforeScan();
setDependencyScanConfig(config);
}

configureDependencyScan(run, descriptor, env, ret);

if (!ret.getSynchronous()) {
Expand Down Expand Up @@ -884,7 +920,16 @@ private void configureDependencyScan(Run<?, ?> run, DescriptorImpl descriptor, E
return;
}

config.addScannerType(effectiveConfig.dependencyScannerType);
ScannerType scannerType = null;
if (effectiveConfig.dependencyScannerType == DependencyScannerType.OSA) {
scannerType = ScannerType.OSA;
} else if (effectiveConfig.dependencyScannerType == DependencyScannerType.SCA) {
scannerType = ScannerType.AST_SCA;
}

if (scannerType != null) {
config.addScannerType(scannerType);
}

config.setOsaFilterPattern(env.expand(effectiveConfig.dependencyScanPatterns));
config.setOsaFolderExclusions(env.expand(effectiveConfig.dependencyScanExcludeFolders));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.checkmarx.jenkins;

import com.cx.restclient.dto.ScannerType;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

Expand All @@ -22,7 +21,7 @@ public class DependencyScanConfig {
public String dependencyScanExcludeFolders;

@DataBoundSetter
public ScannerType dependencyScannerType;
public DependencyScannerType dependencyScannerType;

@DataBoundSetter
public String osaArchiveIncludePatterns;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.checkmarx.jenkins;

public enum DependencyScannerType {
OSA,
SCA
}
3 changes: 1 addition & 2 deletions src/main/java/com/checkmarx/jenkins/PluginDataMigration.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.checkmarx.jenkins;

import com.cx.restclient.dto.ScannerType;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -43,7 +42,7 @@ private boolean needToMigrate(CxScanBuilder builder) {
private DependencyScanConfig extractDependencyScanConfig(CxScanBuilder builder) {
DependencyScanConfig config = new DependencyScanConfig();
config.overrideGlobalConfig = true;
config.dependencyScannerType = ScannerType.OSA;
config.dependencyScannerType = DependencyScannerType.OSA;
config.dependencyScanPatterns = builder.getIncludeOpenSourceFolders();
config.dependencyScanExcludeFolders = builder.getExcludeOpenSourceFolders();
config.osaArchiveIncludePatterns = builder.getOsaArchiveIncludePatterns();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@
</f:nested>
</f:radioBlock>

<f:radioBlock checked="${instance.dependencyScanConfig.dependencyScannerType == 'AST_SCA'}"
inline="true" name="dependencyScannerType" title="Use CxSCA dependency scanner" value="AST_SCA">
<f:radioBlock checked="${instance.dependencyScanConfig.dependencyScannerType == 'SCA'}"
inline="true" name="dependencyScannerType" title="Use CxSCA dependency scanner" value="SCA">
<f:nested>
<f:entry title="CxSCA API URL" field="scaServerUrl">
<f:textbox default="${descriptor.DEFAULT_SCA_SERVER_URL}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@
</f:nested>
</f:radioBlock>

<f:radioBlock checked="${descriptor.dependencyScanConfig.dependencyScannerType == 'AST_SCA'}"
inline="true" name="dependencyScannerType" title="Use CxSCA dependency scanner" value="AST_SCA">
<f:radioBlock checked="${descriptor.dependencyScanConfig.dependencyScannerType == 'SCA'}"
inline="true" name="dependencyScannerType" title="Use CxSCA dependency scanner" value="SCA">
<f:nested>
<f:entry title="CxSCA API URL" field="scaServerUrl">
<f:textbox default="${descriptor.DEFAULT_SCA_SERVER_URL}"
Expand Down

0 comments on commit c2c8a18

Please sign in to comment.