diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 49f3f672..2ebb9042 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -13,6 +13,8 @@ on: env: # StackRox internal certificate for central is issued for this name. ROX_INTERNAL_CENTRAL_NAME: 'central.stackrox' + # Frozen test data published by https://github.com/stackrox/stackrox/pull/23544. + SCANNER_V4_MATCHER_VULNERABILITIES_URL: https://definitions.stackrox.io/v4/vulnerability-bundles/ci-minimal-bab3cec6e362f74bbe0c4f6a2e552ce1bac983feb836c449929f20cfd88bf4ce/vulnerabilities.zip jobs: build: @@ -68,12 +70,13 @@ jobs: run: | envrc_file="$(mktemp)" cd stackrox + # Keep envVars in one --set expression; separate flags replace the list. roxie deploy central \ --envrc "$envrc_file" \ --resources=tiny \ --set roxie.imageRegistry=quay.io/stackrox-io \ --set central.namespace=stackrox \ - --set 'central.spec.customize.envVars[0].name=SCANNER_V4_MATCHER_READINESS,central.spec.customize.envVars[0].value=vulnerability' \ + --set "central.spec.customize.envVars[0].name=SCANNER_V4_MATCHER_READINESS,central.spec.customize.envVars[0].value=vulnerability,central.spec.customize.envVars[1].name=SCANNER_V4_MATCHER_VULNERABILITIES_URL,central.spec.customize.envVars[1].value=$SCANNER_V4_MATCHER_VULNERABILITIES_URL" \ --early-readiness=false \ --central-wait 60m source "$envrc_file" diff --git a/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTest.groovy b/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTest.groovy index 00f2c47a..048f89de 100644 --- a/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTest.groovy +++ b/functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTest.groovy @@ -9,6 +9,10 @@ import com.offbytwo.jenkins.model.BuildResult import com.stackrox.model.StorageEnforcementAction import com.stackrox.model.StorageListPolicy import com.stackrox.model.StoragePolicy +import com.stackrox.model.StoragePolicyGroup +import com.stackrox.model.StoragePolicySection +import com.stackrox.model.StoragePolicyValue +import com.stackrox.model.StorageSeverity import util.Config @@ -22,7 +26,7 @@ class ImageScanningTest extends BaseSpecification { @Unroll def "image scanning test with toggle enforcement(#imageName, #policyName, #enforcements, #endStatus)"() { given: - updatePolicy("Fixable CVSS >= 7", []) + updatePolicy("Fixable CVSS >= 5", []) updatePolicy("Fixable Severity at least Important", []) when: @@ -66,7 +70,7 @@ class ImageScanningTest extends BaseSpecification { where: "data inputs are: " imageName | policyName | tag - "nginx-alpine:1.2.1" | "Fixable CVSS >= 7" | "1.2.1" + "nginx-alpine:1.2.1" | "Fixable CVSS >= 5" | "1.2.1" "nginx-alpine:latest" | "Latest tag" | "latest" } @@ -104,6 +108,17 @@ class ImageScanningTest extends BaseSpecification { StoragePolicy updatePolicy(String policyName, List enforcements) { List policies = restApiClient.policies def policyId = policies.find { it.name == policyName }?.id + if (policyId == null && policyName == "Fixable CVSS >= 5") { + // The minimal bundle includes fixable CVE-2022-2097 with CVSS 5.3 for the test image. + return restApiClient.policyServiceApi.policyServicePostPolicy(new StoragePolicy( + name: policyName, policyVersion: "1.1", severity: StorageSeverity.MEDIUM_SEVERITY, + categories: ["Vulnerability Management"], disabled: false, + lifecycleStages: [BUILD, DEPLOY], enforcementActions: enforcements, + policySections: [new StoragePolicySection(policyGroups: + ["Fixed By": ".*", "CVSS": ">= 5"].collect { field, value -> + new StoragePolicyGroup(fieldName: field, values: [new StoragePolicyValue(value: value)]) + })]), true) + } assert policyId != null def policy = restApiClient.getPolicy(policyId)