-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: parse OS version from result of trivy-scan #1444
feat: parse OS version from result of trivy-scan #1444
Conversation
Bumps [github.com/aquasecurity/trivy](https://github.com/aquasecurity/trivy) from 0.24.2 to 0.25.4. - [Release notes](https://github.com/aquasecurity/trivy/releases) - [Changelog](https://github.com/aquasecurity/trivy/blob/main/goreleaser.yml) - [Commits](aquasecurity/trivy@v0.24.2...v0.25.4) --- updated-dependencies: - dependency-name: github.com/aquasecurity/trivy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
…ub.com/aquasecurity/trivy-0.25.4 chore(deps): bump github.com/aquasecurity/trivy from 0.24.2 to 0.25.4
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.
LGTM
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.
How about rewriting it this way?
func setScanResultMeta(scanResult *models.ScanResult, report *types.Report) error {
if report.Metadata.OS != nil {
scanResult.Family = report.Metadata.OS.Family
scanResult.Release = report.Metadata.OS.Name
scanResult.ServerName = fmt.Sprintf("%s %s", scanResult.Family, scanResult.Release)
} else {
scanResult.Family = constant.ServerTypePseudo
scanResult.ServerName = "library scan by trivy"
}
scanResult.ScannedAt = time.Now()
scanResult.ScannedBy = "trivy"
scanResult.ScannedVia = "trivy"
if len(report.Results) == 0 {
return xerrors.Errorf("scanned images or libraries are not supported by Trivy. see https://aquasecurity.github.io/trivy/dev/vulnerability/detection/os/, https://aquasecurity.github.io/trivy/dev/vulnerability/detection/language/")
}
// check vuls expected os or library
for _, r := range report.Results {
if !pkg.IsVulsExpectedOS(r.Type) && !pkg.IsVulsExpectedLib(r.Type) {
return xerrors.Errorf("vuls not supported images or libraries. r.Type: %s", r.Type)
}
}
return nil
}
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
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.
LGTM
What did you implement:
Currently, trivy-to-vuls don't parse OS version .
I made trivy-to-vuls parse it.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Checklist:
You don't have to satisfy all of the following.
make fmt
make test
Reference