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

Use of clair report from OCI and CVE leeway #1180

Merged
merged 3 commits into from
Oct 21, 2024

Conversation

zregvart
Copy link
Member

@zregvart zregvart commented Oct 9, 2024

If present the Clair report attached to the image will be used and consulted instead of the aggregate present in SCAN_OUTPUT Task result.

This allows us to filter out the vulnerabilities that are made public within X number of leeway days.

Reference: https://issues.redhat.com/browse/EC-838

@zregvart
Copy link
Member Author

zregvart commented Oct 9, 2024

Created as draft to get early feedback. Currently missing:

  • tests
  • rule data validation
  • a new warning rule, so folk know that there are CVEs but filtered out because of leeway

@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (b0f9edd) to head (27ad2ce).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              main     #1180    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          120       120            
  Lines         6254      6409   +155     
==========================================
+ Hits          6254      6409   +155     
Files with missing lines Coverage Δ
policy/lib/rule_data.rego 100.00% <ø> (ø)
policy/release/cve.rego 100.00% <100.00%> (ø)
policy/release/cve_test.rego 100.00% <100.00%> (ø)

policy/release/cve.rego Outdated Show resolved Hide resolved
policy/release/cve.rego Outdated Show resolved Hide resolved
@zregvart zregvart force-pushed the issue/EC-838 branch 3 times, most recently from bdafcbc to 8679082 Compare October 11, 2024 10:50
@zregvart zregvart marked this pull request as ready for review October 11, 2024 10:51
@zregvart
Copy link
Member Author

This is now ready for review. I think the descriptions/messages could use a bit of finessing. The logic is bit hard (at least for me) to follow, the main idea is not to report any blocking (deny) violations caused by a vulnerability that was made public (issued date) after the effective date - leeway for the severity, and the same should be reported as a warning.

policy/release/cve.rego Outdated Show resolved Hide resolved
policy/release/cve.rego Outdated Show resolved Hide resolved
report_blob := object.union(input_image, {"digest": layer.digest})
report_blob_ref := image.str(report_blob)

report := json.unmarshal(ec.oci.blob(report_blob_ref))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably have some data validation on the report itself. Maybe as a follow up?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't want to make this bigger, but I might, let's see how enthusiastic I'll end up being...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #1199 for the follwup.

If present the Clair report attached to the image will be used and
consulted instead of the aggregate present in `SCAN_OUTPUT` Task result.

This allows us to filter out the vulnerabilities that are made public
within X number of leeway days.

Reference: https://issues.redhat.com/browse/EC-838
Sets the `effective_on` when vulnerabilities are not reported as
blocking violations due to the leeway policy. Now the evaluation
considers a period instead of the leeway cut-off date, so the
functions/expressions can be reused between the different rules. This
makes the violations resulting from vulnerabilities found within the
leeway period effectively a warning.

The zero period refers to the period with no leeway, i.e. from beginning
of (Unix) time till the current effective date; and the configured
period includes the time up to the leeway cut-off date, i.e. from
beginning of (Unix) time up to the leeway cut-off date.

Reference: https://issues.redhat.com/browse/EC-838
@zregvart
Copy link
Member Author

I'm very close to merging this, I think everything is addressed in the latest version and there is one approving review albeit for the older version.

@zregvart zregvart merged commit 2194dba into enterprise-contract:main Oct 21, 2024
4 checks passed
@zregvart zregvart deleted the issue/EC-838 branch October 21, 2024 09:06
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 this pull request may close these issues.

3 participants