Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #290 from dcanar9/master
Browse files Browse the repository at this point in the history
Moving remoteCreate default entry logic to appropriate File
  • Loading branch information
tatlax3636 authored Aug 16, 2022
2 parents e38eeef + 9efea43 commit 246ad4c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 15 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>api</artifactId>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<version>3.4.45</version>
<version>3.4.46</version>
<description>Hygieia Rest API Layer</description>
<url>https://github.com/Hygieia/api</url>

Expand Down Expand Up @@ -59,7 +59,7 @@

<properties>
<!-- Dependencies -->
<com.capitalone.dashboard.core.version>3.15.41</com.capitalone.dashboard.core.version>
<com.capitalone.dashboard.core.version>3.15.43</com.capitalone.dashboard.core.version>
<spring-security.version>4.2.18.RELEASE</spring-security.version>
<tomcat.version>8.5.70</tomcat.version>
<commons-beanutils.version>1.9.4</commons-beanutils.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Arrays;

public class DashboardRemoteRequest extends BaseRequest {
@Valid
Expand Down Expand Up @@ -239,18 +238,6 @@ public CollectorItem toCollectorItem(Collector collector) throws HygieiaExceptio
throw new HygieiaException(toolName + " collector does not support field: " + key, HygieiaException.COLLECTOR_ITEM_CREATE_ERROR);
}
}
// set options with defaults
if (collector.getName().equals("WhiteSource") && !options.keySet().contains("localConfig")){
collectorItem.getOptions().put("localConfig", false);
}
else if(collector.getName().equals("Checkmarx")){
if(!options.keySet().contains("fileExclusions") || options.get("fileExclusions").equals("")){
collectorItem.getOptions().put("fileExclusions", " ");
}
if(!options.keySet().contains("folderExclusions") || options.get("folderExclusions").equals("")){
collectorItem.getOptions().put("folderExclusions", " ");
}
}
return collectorItem;
} else {
throw new HygieiaException("Missing required fields. " + toolName + " collector required fields are: " + String.join(", ", collector.getUniqueFields().keySet()), HygieiaException.COLLECTOR_ITEM_CREATE_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,28 @@ private List< Dashboard > findExistingDashboardsFromRequest( DashboardRemoteRequ

private CollectorItem entryToCollectorItem(DashboardRemoteRequest.Entry entry, Collector collector) throws HygieiaException {
CollectorItem item = entry.toCollectorItem(collector);
checkDefaults(collector, item);
item.setCollectorId(collector.getId());
return collectorService.createCollectorItemSelectOptions(item, collector, collector.getAllFields(), item.getOptions());
}

// will check if certain entry options were passed in the request
private void checkDefaults(Collector collector, CollectorItem item){
if (collector.getName().equals(apiSettings.getLibraryPolicyCollectorName())){
if(!item.getOptions().containsKey("localConfig") || !(item.getOptions().get("localConfig") instanceof Boolean)){
item.getOptions().put("localConfig", false);
}
}
else if(collector.getName().equals(apiSettings.getSecurityScanCollectorName())){
if(!item.getOptions().containsKey("fileExclusions")){
item.getOptions().put("fileExclusions", "");
}
if(!item.getOptions().containsKey("folderExclusions")){
item.getOptions().put("folderExclusions", "");
}
}
}

/**
* Creates a widget from entry
* @param dashboard
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/capitalone/dashboard/settings/ApiSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public class ApiSettings {
private Map<String,String> performance;
private String unit;

private String libraryPolicyCollectorName;

private String securityScanCollectorName;

@Value("${encryptRemoteCreatePayload:true}")
private boolean encryptRemoteCreatePayload;

Expand All @@ -75,6 +79,22 @@ public class ApiSettings {

private String hygieia_ui_url="";

public String getSecurityScanCollectorName() {
return securityScanCollectorName;
}

public void setSecurityScanCollectorName(String securityScanCollectorName) {
this.securityScanCollectorName = securityScanCollectorName;
}

public String getLibraryPolicyCollectorName() {
return libraryPolicyCollectorName;
}

public void setLibraryPolicyCollectorName(String libraryPolicyCollectorName) {
this.libraryPolicyCollectorName = libraryPolicyCollectorName;
}

public Map<String, String> getFunctional() {
return functional;
}
Expand Down

0 comments on commit 246ad4c

Please sign in to comment.