Skip to content

Commit bbd025d

Browse files
authored
Merge pull request #1294 from lcarva/EC-921
Rework CVE policies to allow per CVE exceptions
2 parents 044b0ab + 724e20e commit bbd025d

File tree

6 files changed

+425
-927
lines changed

6 files changed

+425
-927
lines changed

antora/docs/modules/ROOT/pages/release_policy.adoc

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -447,72 +447,60 @@ cve_leeway:
447447

448448
The SLSA Provenance attestation for the image is inspected to ensure CVEs that have a known fix and meet a certain security level have not been detected. If detected, this policy rule will fail. By default, only CVEs of critical and high security level cause a failure. This is configurable by the rule data key `restrict_cve_security_levels`. The available levels are critical, high, medium, low, and unknown. In addition to that leeway can be granted per severity using the `cve_leeway` rule data key containing days of allowed leeway, measured as time between found vulnerability's public disclosure date and current effective time, per severity level.
449449

450-
*Solution*: Make sure to address any CVE's related to the image. The CVEs are detected by the task that runs a Clair scan and emits a result named `SCAN_OUTPUT`.
450+
*Solution*: Make sure to address any CVE's related to the image.
451451

452452
* Rule type: [rule-type-indicator failure]#FAILURE#
453-
* FAILURE message: `Found %d CVE vulnerabilities of %s security level`
453+
* FAILURE message: `Found %q vulnerability of %s security level`
454454
* Code: `cve.cve_blockers`
455-
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/cve/cve.rego#L132[Source, window="_blank"]
455+
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/cve/cve.rego#L113[Source, window="_blank"]
456456

457457
[#cve__unpatched_cve_blockers]
458458
=== link:#cve__unpatched_cve_blockers[Blocking unpatched CVE check]
459459

460460
The SLSA Provenance attestation for the image is inspected to ensure CVEs that do NOT have a known fix and meet a certain security level have not been detected. If detected, this policy rule will fail. By default, the list of security levels used by this policy is empty. This is configurable by the rule data key `restrict_unpatched_cve_security_levels`. The available levels are critical, high, medium, low, and unknown. In addition to that leeway can be granted per severity using the `cve_leeway` rule data key containing days of allowed leeway, measured as time between found vulnerability's public disclosure date and current effective time, per severity level.
461461

462-
*Solution*: CVEs without a known fix can only be remediated by either removing the impacted dependency, or by waiting for a fix to be available. The CVEs are detected by the task that emits a result named `SCAN_OUTPUT`.
462+
*Solution*: CVEs without a known fix can only be remediated by either removing the impacted dependency, or by waiting for a fix to be available.
463463

464464
* Rule type: [rule-type-indicator failure]#FAILURE#
465-
* FAILURE message: `Found %d unpatched CVE vulnerabilities of %s security level`
465+
* FAILURE message: `Found %q unpatched vulnerability of %s security level`
466466
* Code: `cve.unpatched_cve_blockers`
467-
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/cve/cve.rego#L172[Source, window="_blank"]
467+
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/cve/cve.rego#L147[Source, window="_blank"]
468468

469469
[#cve__cve_results_found]
470470
=== link:#cve__cve_results_found[CVE scan results found]
471471

472472
Confirm that clair-scan task results are present in the SLSA Provenance attestation of the build pipeline.
473473

474-
*Solution*: Make sure there is a successful task in the build pipeline that runs a Clair scan and creates a task result called `SCAN_OUTPUT`.
474+
*Solution*: Make sure there is a successful task in the build pipeline that runs a Clair scan.
475475

476476
* Rule type: [rule-type-indicator failure]#FAILURE#
477477
* FAILURE message: `Clair CVE scan results were not found`
478478
* Code: `cve.cve_results_found`
479-
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/cve/cve.rego#L214[Source, window="_blank"]
480-
481-
[#cve__deprecated_cve_result_name]
482-
=== link:#cve__deprecated_cve_result_name[Deprecated CVE result name]
483-
484-
The `CLAIR_SCAN_RESULT` result name has been deprecated, and has been replaced with `SCAN_OUTPUT`. If any task results with the old name are found, this rule will raise a warning.
485-
486-
*Solution*: Use the newer `SCAN_OUTPUT` result name.
487-
488-
* Rule type: [rule-type-indicator warning]#WARNING#
489-
* WARNING message: `CVE scan uses deprecated result name`
490-
* Code: `cve.deprecated_cve_result_name`
491-
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/cve/cve.rego#L110[Source, window="_blank"]
479+
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/cve/cve.rego#L183[Source, window="_blank"]
492480

493481
[#cve__cve_warnings]
494482
=== link:#cve__cve_warnings[Non-blocking CVE check]
495483

496484
The SLSA Provenance attestation for the image is inspected to ensure CVEs that have a known fix and meet a certain security level have not been detected. If detected, this policy rule will raise a warning. By default, the list of CVE security levels used by this policy is empty. However, this is configurable by the rule data key `warn_cve_security_levels`. The available levels are critical, high, medium, low, and unknown.
497485

498-
*Solution*: Make sure to address any CVE's related to the image. The CVEs are detected by the task that runs a Clair scan and emits a result named `SCAN_OUTPUT`.
486+
*Solution*: Make sure to address any CVE's related to the image.
499487

500488
* Rule type: [rule-type-indicator warning]#WARNING#
501-
* WARNING message: `Found %d non-blocking CVE vulnerabilities of %s security level`
489+
* WARNING message: `Found %q non-blocking vulnerability of %s security level`
502490
* Code: `cve.cve_warnings`
503-
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/cve/cve.rego#L59[Source, window="_blank"]
491+
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/cve/cve.rego#L58[Source, window="_blank"]
504492

505493
[#cve__unpatched_cve_warnings]
506494
=== link:#cve__unpatched_cve_warnings[Non-blocking unpatched CVE check]
507495

508496
The SLSA Provenance attestation for the image is inspected to ensure CVEs that do NOT have a known fix and meet a certain security level have not been detected. If detected, this policy rule will raise a warning. By default, only CVEs of critical and high security level cause a warning. This is configurable by the rule data key `warn_unpatched_cve_security_levels`. The available levels are critical, high, medium, low, and unknown.
509497

510-
*Solution*: CVEs without a known fix can only be remediated by either removing the impacted dependency, or by waiting for a fix to be available. The CVEs are detected by the task that emits a result named `SCAN_OUTPUT`.
498+
*Solution*: CVEs without a known fix can only be remediated by either removing the impacted dependency, or by waiting for a fix to be available.
511499

512500
* Rule type: [rule-type-indicator warning]#WARNING#
513-
* WARNING message: `Found %d non-blocking unpatched CVE vulnerabilities of %s security level`
501+
* WARNING message: `Found %q non-blocking unpatched vulnerability of %s security level`
514502
* Code: `cve.unpatched_cve_warnings`
515-
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/cve/cve.rego#L84[Source, window="_blank"]
503+
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/cve/cve.rego#L85[Source, window="_blank"]
516504

517505
[#cve__rule_data_provided]
518506
=== link:#cve__rule_data_provided[Rule data provided]
@@ -524,7 +512,7 @@ Confirm the expected rule data keys have been provided in the expected format. T
524512
* Rule type: [rule-type-indicator failure]#FAILURE#
525513
* FAILURE message: `%s`
526514
* Code: `cve.rule_data_provided`
527-
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/cve/cve.rego#L239[Source, window="_blank"]
515+
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/cve/cve.rego#L209[Source, window="_blank"]
528516

529517
[#external_parameters_package]
530518
== link:#external_parameters_package[External parameters]

antora/docs/modules/ROOT/partials/release_policy_nav.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
**** xref:release_policy.adoc#cve__cve_blockers[Blocking CVE check]
2828
**** xref:release_policy.adoc#cve__unpatched_cve_blockers[Blocking unpatched CVE check]
2929
**** xref:release_policy.adoc#cve__cve_results_found[CVE scan results found]
30-
**** xref:release_policy.adoc#cve__deprecated_cve_result_name[Deprecated CVE result name]
3130
**** xref:release_policy.adoc#cve__cve_warnings[Non-blocking CVE check]
3231
**** xref:release_policy.adoc#cve__unpatched_cve_warnings[Non-blocking unpatched CVE check]
3332
**** xref:release_policy.adoc#cve__rule_data_provided[Rule data provided]

policy/lib/image/image.rego

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,11 @@ equal_ref(ref1, ref2) if {
7878
_get(ary, index, default_value) := value if {
7979
value := ary[index]
8080
} else := default_value
81+
82+
# Returns a value if the reference is for an Image Index.
83+
is_image_index(ref) if {
84+
ec.oci.descriptor(ref).mediaType in {
85+
"application/vnd.oci.image.index.v1+json",
86+
"application/vnd.docker.distribution.manifest.list.v2+json",
87+
}
88+
}

policy/lib/image/image_test.rego

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,20 @@ test_str if {
7979
lib.assert_equal("registry.io/repository:tag", image.str({"repo": "registry.io/repository", "tag": "tag"}))
8080
lib.assert_equal("registry.io/repository@digest", image.str({"repo": "registry.io/repository", "digest": "digest"}))
8181
}
82+
83+
test_is_image_index if {
84+
ref := "registry.io/repository:tag@digest"
85+
86+
image_index := {"mediaType": "application/vnd.oci.image.index.v1+json"}
87+
image.is_image_index(ref) with ec.oci.descriptor as image_index
88+
89+
manifest_list := {"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json"}
90+
image.is_image_index(ref) with ec.oci.descriptor as manifest_list
91+
92+
image_manifest := {"mediaType": "application/vnd.oci.image.manifest.v1+json"}
93+
not image.is_image_index(ref) with ec.oci.descriptor as image_manifest
94+
95+
not image.is_image_index(ref) with ec.oci.descriptor as {}
96+
97+
not image.is_image_index(ref) with ec.oci.descriptor as false
98+
}

0 commit comments

Comments
 (0)