Skip to content

Commit

Permalink
tests and implementation of multi-language scan settings mercedes-ben…
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeeppler authored and de-jcup committed Aug 4, 2020
1 parent b44eaf2 commit 5388e43
Show file tree
Hide file tree
Showing 14 changed files with 678 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ public interface CheckmarxAdapterConfig extends AdapterConfig {

String getClientSecret();

String getEngineConfigurationName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class CheckmarxConfig extends AbstractCodeScanAdapterConfig implements Ch
public Long presetIdForNewProjects;
private String clientSecret;// client secret just ensures it is a checkmarx instance - we use default value,
// but we make it configurable if this changes ever in future

private String engineConfigurationName;

private CheckmarxConfig() {
}
Expand All @@ -46,6 +48,11 @@ public InputStream getSourceCodeZipFileInputStream() {
return sourceCodeZipFileInputStream;
}

@Override
public String getEngineConfigurationName() {
return engineConfigurationName;
}

public static CheckmarxConfigBuilder builder() {
return new CheckmarxConfigBuilder();
}
Expand All @@ -58,6 +65,8 @@ public static class CheckmarxConfigBuilder extends AbstractCodeScanAdapterConfig

private String clientSecret = DEFAULT_CLIENT_SECRET; // per default use default client secret

private String engineConfigurationName = CheckmarxEngineConfigurationOptions.DEFAULT_CHECKMARX_ENGINECONFIGURATION_MULTILANGANGE_SCAN_NAME;

/**
* When we create a new project this is the team ID to use
*
Expand All @@ -73,6 +82,11 @@ public CheckmarxConfigBuilder setClientSecret(String newClientSecret) {
this.clientSecret = newClientSecret;
return this;
}

public CheckmarxConfigBuilder setEngineConfigurationName(String engineConfigurationName) {
this.engineConfigurationName = engineConfigurationName;
return this;
}

/**
* When we create a new project this is the team ID to use
Expand All @@ -96,6 +110,7 @@ protected void customBuild(CheckmarxConfig config) {
config.presetIdForNewProjects = presetIdForNewProjects;
config.sourceCodeZipFileInputStream = sourceCodeZipFileInputStream;
config.clientSecret = clientSecret;
config.engineConfigurationName = engineConfigurationName;
}

@Override
Expand All @@ -116,7 +131,5 @@ protected void assertTeamIdSet() {
throw new IllegalStateException("no team id given");
}
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: MIT
package com.daimler.sechub.adapter.checkmarx;

import java.util.Objects;

public class CheckmarxEngineConfiguration {
private Long id;
private String name;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Override
public String toString() {
return "CheckmarxEngineConfiguration [id=" + id + ", name=" + name + "]";
}

@Override
public int hashCode() {
return Objects.hash(id, name);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CheckmarxEngineConfiguration other = (CheckmarxEngineConfiguration) obj;
return Objects.equals(id, other.id) && Objects.equals(name, other.name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: MIT
package com.daimler.sechub.adapter.checkmarx;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
* Checkmarx defines a few engine configurations.
*
* This enum maps the Checkmarx engine configuration options to constant values.
*
* The possible options can be found in the Checkmarx documentation:
* - https://checkmarx.atlassian.net/wiki/spaces/KC/pages/223543515/Get+All+Engine+Configurations+-+GET+sast+engineConfigurations+v8.6.0+and+up
*
* Only the names of the engine configurations are mapped and not the ids, assuming Checkmarx can
* add/remove engineConfigurations or change the ids in the future.
*
* @author Jeremias Eppler
*/

@Component
public class CheckmarxEngineConfigurationOptions {

public static final String DEFAULT_CHECKMARX_ENGINECONFIGURATION_MULTILANGANGE_SCAN_NAME = "Multi-language Scan";

@Value("{sechub.adapter.checkmarx.engineconfiguration.name:"+DEFAULT_CHECKMARX_ENGINECONFIGURATION_MULTILANGANGE_SCAN_NAME+"}")
private String checkmarxName = DEFAULT_CHECKMARX_ENGINECONFIGURATION_MULTILANGANGE_SCAN_NAME;

CheckmarxEngineConfigurationOptions(String checkmarxName) {
this.checkmarxName = checkmarxName;
}

/* getNameUsedForCheckmarxEngineConfigurationIDFetching*/
public String getCheckmarxName() {
return checkmarxName;
}
}
Loading

0 comments on commit 5388e43

Please sign in to comment.