mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-12 07:40:48 -08:00
fix: handle empty OS family (#2768)
This commit is contained in:
4
.github/workflows/release.yaml
vendored
4
.github/workflows/release.yaml
vendored
@@ -10,7 +10,7 @@ jobs:
|
||||
uses: ./.github/workflows/reusable-release.yaml
|
||||
with:
|
||||
goreleaser_config: goreleaser.yml
|
||||
goreleaser_options: '--rm-dist --timeout 60m'
|
||||
goreleaser_options: '--rm-dist --timeout 90m'
|
||||
secrets: inherit
|
||||
|
||||
deploy-packages:
|
||||
@@ -54,4 +54,4 @@ jobs:
|
||||
run: echo -e "${{ secrets.GPG_KEY }}" | gpg --import
|
||||
|
||||
- name: Create deb repository
|
||||
run: ci/deploy-deb.sh
|
||||
run: ci/deploy-deb.sh
|
||||
|
||||
2
.github/workflows/test.yaml
vendored
2
.github/workflows/test.yaml
vendored
@@ -113,7 +113,7 @@ jobs:
|
||||
uses: goreleaser/goreleaser-action@v3
|
||||
with:
|
||||
version: v1.4.1
|
||||
args: release --snapshot --rm-dist --skip-publish --timeout 60m
|
||||
args: release --snapshot --rm-dist --skip-publish --timeout 90m
|
||||
|
||||
build-documents:
|
||||
name: Documentation Test
|
||||
|
||||
@@ -80,6 +80,11 @@ func (s Scanner) Scan(ctx context.Context, target, artifactKey string, blobKeys
|
||||
case errors.Is(err, analyzer.ErrUnknownOS):
|
||||
log.Logger.Debug("OS is not detected.")
|
||||
|
||||
// Packages may contain OS-independent binary information even though OS is not detected.
|
||||
if len(artifactDetail.Packages) != 0 {
|
||||
artifactDetail.OS = &ftypes.OS{Family: "none"}
|
||||
}
|
||||
|
||||
// If OS is not detected and repositories are detected, we'll try to use repositories as OS.
|
||||
if artifactDetail.Repository != nil {
|
||||
log.Logger.Debugf("Package repository: %s %s", artifactDetail.Repository.Family, artifactDetail.Repository.Release)
|
||||
@@ -167,12 +172,10 @@ func (s Scanner) Scan(ctx context.Context, target, artifactKey string, blobKeys
|
||||
}
|
||||
|
||||
func (s Scanner) osPkgsToResult(target string, detail ftypes.ArtifactDetail, options types.ScanOptions) *types.Result {
|
||||
if len(detail.Packages) == 0 {
|
||||
if len(detail.Packages) == 0 || detail.OS == nil {
|
||||
return nil
|
||||
}
|
||||
if detail.OS != nil {
|
||||
target = fmt.Sprintf("%s (%s %s)", target, detail.OS.Family, detail.OS.Name)
|
||||
}
|
||||
|
||||
pkgs := detail.Packages
|
||||
if options.ScanRemovedPackages {
|
||||
pkgs = mergePkgs(pkgs, detail.HistoryPackages)
|
||||
@@ -181,7 +184,7 @@ func (s Scanner) osPkgsToResult(target string, detail ftypes.ArtifactDetail, opt
|
||||
return strings.Compare(pkgs[i].Name, pkgs[j].Name) <= 0
|
||||
})
|
||||
return &types.Result{
|
||||
Target: target,
|
||||
Target: fmt.Sprintf("%s (%s %s)", target, detail.OS.Family, detail.OS.Name),
|
||||
Class: types.ClassOSPkg,
|
||||
Type: detail.OS.Family,
|
||||
Packages: pkgs,
|
||||
|
||||
Reference in New Issue
Block a user