Skip to content

Commit 4175787

Browse files
committed
issue #3733 change code to allow all images if DOCKER_SECURITY_TOOL_OS is empty (as in was previously)
1 parent bb04f99 commit 4175787

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

api/src/main/java/com/epam/pipeline/manager/pipeline/ToolManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,7 @@ public boolean isToolOSVersionAllowed(final ToolOSVersion toolOSVersion) {
828828
final String allowedOSes = preferenceManager.getPreference(SystemPreferences.DOCKER_SECURITY_TOOL_OS);
829829
final String allowedWithWarningOSes = preferenceManager.getPreference(
830830
SystemPreferences.DOCKER_SECURITY_TOOL_OS_WITH_WARNING);
831-
if ((StringUtils.isEmpty(allowedOSes) && StringUtils.isEmpty(allowedWithWarningOSes))
832-
|| toolOSVersion == null) {
831+
if (StringUtils.isEmpty(allowedOSes) || toolOSVersion == null) {
833832
return true;
834833
}
835834
return toolOSVersion.isMatched(allowedOSes) || toolOSVersion.isMatched(allowedWithWarningOSes);

api/src/test/java/com/epam/pipeline/manager/docker/scan/AggregatingToolScanManagerTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,33 @@ public void testAllowOnAllowedOSVersion() {
456456

457457
@Test
458458
public void testAllowOnAllowedOSInToolOsWithWarning() {
459+
when(preferenceManager.getPreference(SystemPreferences.DOCKER_SECURITY_TOOL_OS))
460+
.thenReturn("centos");
461+
when(preferenceManager.getPreference(SystemPreferences.DOCKER_SECURITY_TOOL_OS_WITH_WARNING))
462+
.thenReturn("ubuntu:14");
463+
TestUtils.generateScanResult(0, 0,
464+
1, toolScanResult, new ToolOSVersion("ubuntu", "14"));
465+
Assert.assertTrue(aggregatingToolScanManager.checkTool(testTool, LATEST_VERSION).isAllowed());
466+
}
467+
468+
@Test
469+
public void testAllowIfAllowedOSsIsEmpty() {
459470
when(preferenceManager.getPreference(SystemPreferences.DOCKER_SECURITY_TOOL_OS_WITH_WARNING))
460471
.thenReturn("ubuntu:14");
461472
TestUtils.generateScanResult(0, 0,
462473
1, toolScanResult, new ToolOSVersion("ubuntu", "14"));
463474
Assert.assertTrue(aggregatingToolScanManager.checkTool(testTool, LATEST_VERSION).isAllowed());
464475
}
465476

477+
@Test
478+
public void testAllowIfAllowedOSsIsEmptyAndAllowedOSesWithWarningDoesntAllow() {
479+
when(preferenceManager.getPreference(SystemPreferences.DOCKER_SECURITY_TOOL_OS_WITH_WARNING))
480+
.thenReturn("centos");
481+
TestUtils.generateScanResult(0, 0,
482+
1, toolScanResult, new ToolOSVersion("ubuntu", "14"));
483+
Assert.assertTrue(aggregatingToolScanManager.checkTool(testTool, LATEST_VERSION).isAllowed());
484+
}
485+
466486
@Test
467487
public void testDenyOnHigh() {
468488
TestUtils.generateScanResult(MAX_CRITICAL_VULNERABILITIES, MAX_HIGH_VULNERABILITIES + 1,

0 commit comments

Comments
 (0)