Fixing airgap conditional , correcting the use of policy severities
@@ -26,9 +26,12 @@ package com.blackducksoftware.integration.hub.detect;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.stream.Collectors;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
@@ -42,6 +45,7 @@ import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySource;
import org.springframework.stereotype.Component;
+import com.blackducksoftware.integration.hub.api.enumeration.PolicySeverityType;
import com.blackducksoftware.integration.hub.detect.bomtool.BomTool;
import com.blackducksoftware.integration.hub.detect.bomtool.docker.DockerBomTool;
import com.blackducksoftware.integration.hub.detect.bomtool.gradle.GradleBomTool;
@@ -178,6 +182,18 @@ public class DetectConfiguration {
final boolean atLeastOnePolicySeverity = StringUtils.isNotBlank(policyCheckFailOnSeverities);
if (atLeastOnePolicySeverity) {
+ boolean allSeverities = false;
+ String[] splitSeverities = policyCheckFailOnSeverities.split(",");
+ for (String severity : splitSeverities) {
+ if (severity.equalsIgnoreCase("ALL")) {
+ allSeverities = true;
+ break;
+ }
+ }
+ if (allSeverities) {
+ List<String> allPolicyTypes = Arrays.stream(PolicySeverityType.values()).filter(type -> type != PolicySeverityType.UNSPECIFIED).map(type -> type.toString()).collect(Collectors.toList());
+ policyCheckFailOnSeverities = StringUtils.join(allPolicyTypes,",");
+ }
if (policyCheck) {
requestDeprecation("policyCheck");
} else {
@@ -356,7 +372,7 @@ public class DetectConfiguration {
}
private String getInspectorAirGapPath(final String inspectorLocationProperty, final String inspectorName) {
- if (StringUtils.isNotBlank(inspectorLocationProperty)) {
+ if (StringUtils.isBlank(inspectorLocationProperty)) {
try {
final File detectJar = new File(guessDetectJarLocation()).getCanonicalFile();
final File inspectorsDirectory = new File(detectJar.getParentFile(), "packaged-inspectors");
