-
Notifications
You must be signed in to change notification settings - Fork 148
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(azure): Add Azure Linux support #409
Conversation
Azure Linux is a rebranding of CBL-Mariner, starting at version 3.0, so this reuses the existing Mariner parsing function.
pkg/vulnsrc/mariner/mariner.go
Outdated
@@ -36,21 +27,31 @@ type resolvedTest struct { | |||
} | |||
|
|||
type VulnSrc struct { | |||
dbc db.Operation | |||
Dbc db.Operation | |||
VulnListDir string |
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.
VulnListDir
is usually vuln-list
dir.
Let's use more obvious name
VulnListDir string | |
MarinerDir string |
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 renamed. (I called it vulnListDir as that's the variable used in the redhat and nvd vuln srcs)
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.
azure
is a renamed mariner
.
So I think we can use one package for them:
➜ trivy-db git:(azure-linux) ✗ ls -hl ./pkg/vulnsrc/azure
total 36K
-rw-rw-r-- 1 dmitriy dmitriy 690 июл 2 13:12 azure.go
-rw-rw-r-- 1 dmitriy dmitriy 2,4K июл 2 13:12 azure_test.go
-rw-rw-r-- 1 dmitriy dmitriy 6,9K июл 2 13:39 mariner.go
-rw-rw-r-- 1 dmitriy dmitriy 6,1K июн 20 10:12 mariner_test.go
drwxrwxr-x 2 dmitriy dmitriy 4,0K июл 2 13:57 oval
drwxrwxr-x 4 dmitriy dmitriy 4,0K июл 2 13:12 testdata
-rw-rw-r-- 1 dmitriy dmitriy 206 окт 25 2022 types.go
I suggest the following refactoring:
- move logic from
mariner.go
toazure.go
- create only
NewMarinerVulnSrc()
function inmariner.go
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've done this refactoring. Happy to rebase and git mv
the mariner package if it makes reviewing easier.
pkg/vulnsrc/azure/azure.go
Outdated
ErrNotSupported = xerrors.New("format not supported") | ||
) | ||
|
||
func NewVulnSrc() mariner.VulnSrc { |
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.
You need to add this function to this map
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.
Thanks, done.
{ | ||
name: "happy path", | ||
dir: filepath.Join("testdata", "happy"), | ||
wantValues: []vulnsrctest.WantValues{ |
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.
what about vulnerability-detail
?
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.
Added this.
@tofay I did some refactoring. |
LGTM, thanks. (I noted that the mariner URL changed from https://github.com/microsoft/CBL-MarinerVulnerabilityData to https://github.com/microsoft/AzureLinuxVulnerabilityData, which should be fine as the former repo was renamed to the latter) |
Cool 👍 You can use |
LGTM. As @DmitriyLewen suggested, we need to test this change with Trivy before merging it. |
I've tested this changes with aquasecurity/trivy#7186. Testing setup:
Testing
|
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.
Thanks! |
Another part of aquasecurity/trivy#6673, along with aquasecurity/vuln-list-update#294.
Azure Linux is a rebranding of CBL-Mariner, starting at version 3.0, so this updates the existing Mariner parsing code to be used by both azure linux/cbl-mariner vulnsrcs.