Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per vulnerability policy rules #1182

Closed
zregvart opened this issue Oct 10, 2024 · 3 comments · Fixed by #1294
Closed

Per vulnerability policy rules #1182

zregvart opened this issue Oct 10, 2024 · 3 comments · Fixed by #1294

Comments

@zregvart
Copy link
Member

From #1180 (review), given that we have access to the full Clair vulnerability report, rather than the aggregate, this now enables per-vulnerability rules. For example term-based exclusion on a per-vulnerability basis.

@lcarva
Copy link
Member

lcarva commented Jan 10, 2025

Today, if there's a critical CVE violation, EC will emit something like this: cve.cve_blockers:critical. This only allows users to exclude a violation based on the CVE severity not the CVE itself. This has its uses, e.g. you may want a more lenient config to gate promotion to staging vs production.

However, what has become increasingly clear is that excluding all the CVEs for a particular severity is too heavy handed in most cases. Thus this GitHub issue.

Let's tweak the existing policy rules to emit violations like this: cve.cve_blockers:CVE-123-456. This will allow users to ignore a certain CVE. However, a violation can only emit a single term (the thing after :). Users will no longer be able to use cve.cve_blockers:critical to ignore a whole severity of CVEs. To still allow that use case, users can override the rule data instead, e.g. restrict_cve_security_levels.

So for example, if this is your current policy config:

---
spec:
  sources:
    - data:
        - github.com/release-engineering/rhtap-ec-policy//data
        - oci::quay.io/konflux-ci/tekton-catalog/data-acceptable-bundles:latest
      name: Release Policies
      policy:
        - oci::quay.io/enterprise-contract/ec-release-policy:latest
      config:
        exclude:
          - cve.cve_blockers:critical
        include:
          - "@redhat"

If you want to continue excluding all critical CVEs, then:

---
spec:
  sources:
    - data:
        - github.com/release-engineering/rhtap-ec-policy//data
        - oci::quay.io/konflux-ci/tekton-catalog/data-acceptable-bundles:latest
      name: Release Policies
      policy:
        - oci::quay.io/enterprise-contract/ec-release-policy:latest
      ruleData:
         # Override default value to exclude "critical"
         restrict_cve_security_levels: ["high"]
         # Optionally, report "critical" as a warning
         warn_cve_security_levels: ["critical"]
      config:
        include:
          - "@redhat"

And if you want to only exclude a single CVE:

---
spec:
  sources:
    - data:
        - github.com/release-engineering/rhtap-ec-policy//data
        - oci::quay.io/konflux-ci/tekton-catalog/data-acceptable-bundles:latest
      name: Release Policies
      policy:
        - oci::quay.io/enterprise-contract/ec-release-policy:latest
      config:
        exclude:
          - cve.cve_blockers:CVE-123-456
        include:
          - "@redhat"

Of course, this will require a small migration of the existing EC policy configs, but I do believe this will bring us to a much better state.

(There's also the desire to only apply an exclusion to some of the components. That is orthogonal to this work.)

@simonbaird
Copy link
Member

I like it.

@arewm
Copy link
Contributor

arewm commented Jan 24, 2025

Oh, I thought it was already possible to grant an exception for specific CVEs. :)

lcarva added a commit to lcarva/ec-policies that referenced this issue Feb 11, 2025
This commit changes the CVE policy rules to inspect the full CVE report
available in the OCI registry. By doing so, the policies now have the
list of CVEs found, instead of just a summary.

The policy rules have been rewritten to emit the CVE name as the term.
This allows users to add exceptions for a particular CVE. Previously, it
was only possible to add exceptions for a certain CVE level/severity.

The leeway feature was also tweaked. Now, every violation contains an
`effective_on` which is the issue date of the vulnerability plus any
leeway days that may have been configured. The policies rely on the EC
CLI to downgrade violations to warnings when the effective_on date is in
the future.

Fixes enterprise-contract#1182
Ref: EC-921

Signed-off-by: Luiz Carvalho <[email protected]>
lcarva added a commit to lcarva/ec-policies that referenced this issue Feb 11, 2025
This commit changes the CVE policy rules to inspect the full CVE report
available in the OCI registry. By doing so, the policies now have the
list of CVEs found, instead of just a summary.

The policy rules have been rewritten to emit the CVE name as the term.
This allows users to add exceptions for a particular CVE. Previously, it
was only possible to add exceptions for a certain CVE level/severity.

The leeway feature was also tweaked. Now, every violation contains an
`effective_on` which is the issue date of the vulnerability plus any
leeway days that may have been configured. The policies rely on the EC
CLI to downgrade violations to warnings when the effective_on date is in
the future.

Fixes enterprise-contract#1182
Ref: EC-921

Signed-off-by: Luiz Carvalho <[email protected]>
lcarva added a commit to lcarva/ec-policies that referenced this issue Feb 11, 2025
This commit changes the CVE policy rules to inspect the full CVE report
available in the OCI registry. By doing so, the policies now have the
list of CVEs found, instead of just a summary.

The policy rules have been rewritten to emit the CVE name as the term.
This allows users to add exceptions for a particular CVE. Previously, it
was only possible to add exceptions for a certain CVE level/severity.

The leeway feature was also tweaked. Now, every violation contains an
`effective_on` which is the issue date of the vulnerability plus any
leeway days that may have been configured. The policies rely on the EC
CLI to downgrade violations to warnings when the effective_on date is in
the future.

Fixes enterprise-contract#1182
Ref: EC-921

Signed-off-by: Luiz Carvalho <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants