diff --git a/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTest.groovy b/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTest.groovy index 9208258d..74ca7796 100644 --- a/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTest.groovy +++ b/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTest.groovy @@ -61,9 +61,9 @@ class ImageScanningTest extends BaseSpecification { where: "data inputs are: " - imageName | policyName | tag - "jenkins/jenkins:lts" | "Fixable CVSS >= 7" | "lts" - "nginx:latest" | "Latest tag" | "latest" + imageName | policyName | tag + "jenkins/jenkins:2.77" | "Fixable CVSS >= 7" | "2.77" + "nginx:latest" | "Latest tag" | "latest" } @Unroll diff --git a/stackrox-container-image-scanner/pom.xml b/stackrox-container-image-scanner/pom.xml index 075aeb5d..1a93b9de 100644 --- a/stackrox-container-image-scanner/pom.xml +++ b/stackrox-container-image-scanner/pom.xml @@ -81,6 +81,11 @@ 4.5.13 test + + javax + javaee-api + 7.0 + com.google.guava guava @@ -130,13 +135,13 @@ org.openapitools jackson-databind-nullable - 0.2.2 + 0.2.3 org.jetbrains.kotlin kotlin-stdlib-common - 1.7.0 + 1.7.10 @@ -144,7 +149,7 @@ org.junit junit-bom - 5.8.2 + 5.9.0 pom import @@ -193,7 +198,7 @@ org.openapitools openapi-generator-maven-plugin - 5.4.0 + 6.1.0 @@ -214,6 +219,7 @@ java8 true src/gen/java/main + true diff --git a/stackrox-container-image-scanner/src/test/java/com/stackrox/jenkins/plugins/services/ImageServiceTest.java b/stackrox-container-image-scanner/src/test/java/com/stackrox/jenkins/plugins/services/ImageServiceTest.java index 9c51321d..021291f6 100644 --- a/stackrox-container-image-scanner/src/test/java/com/stackrox/jenkins/plugins/services/ImageServiceTest.java +++ b/stackrox-container-image-scanner/src/test/java/com/stackrox/jenkins/plugins/services/ImageServiceTest.java @@ -73,6 +73,19 @@ public void shouldNotFailOnMissingData() throws IOException { assertEquals(expected, actual); } + @Test + public void shouldNotFailOnUnknownEnumValue() throws IOException { + MOCK_SERVER.stubFor(postImagesScan().willReturn( + ok().withBodyFile("v1/images/scan/unknown-enum.json"))); + List actual = imageService.getImageScanResults("nginx:latest"); + ImmutableList expected = ImmutableList.of( + new CVE(null, null, new StorageEmbeddedVulnerability() + .cve("CVE-MISSING-DATA") + .scoreVersion(V2)) + ); + assertEquals(expected, actual); + } + private MappingBuilder postImagesScan() { return post(urlEqualTo("/v1/images/scan")) .withHeader("Authorization", equalTo("Bearer {some token}")) diff --git a/stackrox-container-image-scanner/src/test/java/com/stackrox/jenkins/plugins/services/ServiceExceptionTest.java b/stackrox-container-image-scanner/src/test/java/com/stackrox/jenkins/plugins/services/ServiceExceptionTest.java index 035f22d2..64da0c80 100644 --- a/stackrox-container-image-scanner/src/test/java/com/stackrox/jenkins/plugins/services/ServiceExceptionTest.java +++ b/stackrox-container-image-scanner/src/test/java/com/stackrox/jenkins/plugins/services/ServiceExceptionTest.java @@ -13,8 +13,14 @@ class ServiceExceptionTest { @DisplayName("ServiceException message") @ParameterizedTest(name = "should be \"{2}\" when response body \"{0}\"") @CsvSource({ - ",,Status code: 500.", - ",API Message,Status code: 500. Error: API Message", + ",,'Status code: 500. Error: Message: null\n" + + "HTTP response code: 500\n" + + "HTTP response body: null\n" + + "HTTP response headers: null'", + ",API Message,'Status code: 500. Error: Message: API Message\n" + + "HTTP response code: 500\n" + + "HTTP response body: null\n" + + "HTTP response headers: null'", "{},,Status code: 500.", "{\"message\":\"some error\"},,Status code: 500. Error: some error", "not a json,,Status code: 500. Response body: not a json" diff --git a/stackrox-container-image-scanner/src/test/resources/__files/v1/images/scan/unknown-enum.json b/stackrox-container-image-scanner/src/test/resources/__files/v1/images/scan/unknown-enum.json new file mode 100644 index 00000000..70740eeb --- /dev/null +++ b/stackrox-container-image-scanner/src/test/resources/__files/v1/images/scan/unknown-enum.json @@ -0,0 +1,16 @@ +{ + "scan": { + "components": [ + { + "vulns": [ + { + "cve": "CVE-MISSING-DATA" + } + ] + } + ], + "notes": [ + "UNKNOWN VALUE" + ] + } +}