-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat(report): update gitlab template to populate operating_system value #7735
Merged
knqyf263
merged 5 commits into
aquasecurity:main
from
aarongoldenthal:gitlab-template-os
Oct 24, 2024
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fb88ee8
feat(report): update gitlab template to populate operating_system value
aarongoldenthal a35ddbc
feat(report): update gitlab template with default operating_system value
aarongoldenthal 2536016
feat(report): update gitlab template to avoid using regex
aarongoldenthal 4a5ad14
feat(report): update gitlab template to check for os packages to dete…
aarongoldenthal 7c7c62a
feat(report): add test with gitlab template and unknown os and image
aarongoldenthal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am worried that filepath might contain
(
:trivy/pkg/scanner/langpkg/scan.go
Line 52 in 56dbe1f
Can
Class
field be used to detect OS package vulnerabilities?trivy/pkg/scanner/ospkg/scan.go
Lines 40 to 41 in 56dbe1f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My goal here was to replicate the data from GitLab's container scanning tool using Trivy directly. Within GitLab, the format is unique to container scanning (i.e. container images in a registry). In that use case, there's shouldn't be parentheses in the
.Target
value as they're invalid. If it's being used in other cases with file paths then parentheses could be an issue, but then spaces could also be an issue with line 31There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the
Class
question, GitLab actually displays the results, not just looking to identify OS packages, for example:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm.. you are right.
We need to think about language-specific files from container.
I think we can check all targets to find
os
andimage
and use them for all targets.Something like this:
wdyt?
test:
Before:
After:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DmitriyLewen I like it. I did a quick test and it is slightly different than what GitLab output, but I think it's more logical. By default they run with
--vuln-type os
, which I had forgotten, but after overriding they output"operating_system": "Unknown"
for non-OS packages. There are some cases, for example I can think of some npm package examples, that have language-specific installations (installing binaries), so I think the OS is useful data.At the moment there's one test for this template, which I had updated, but what are your thoughts on tests for the "Unknown" cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... You can add test for testdata/fixtures/images/vulnimage.tar.gz (use
low
severity to skip a few vulns).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually thinking the other direction - an image, maybe something
FROM scratch
, that would report"operating_system": "Unknown"
, just to test the defaults. I'm not sure it's critical, but didn't see an image in the existing testcases that looked like it would work. I think the image/os values are already covered in the test forintegration/testdata/alpine-310.gitlab.golden
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have provided
vulnimage.tar.gz
to show that vulnerabilities for language packages now contain the correctoperating_system
andimage
values.Actual behavior:
We can use
fs
mode (use one dir from repo to check this. In this case OS is not detected.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a test and the actions are all passing in my fork, so from my perspective I think this is ready.