Skip to content

Commit 5e46b45

Browse files
geroplcorneliusludmann
authored andcommitted
CLC-1361: Ignore ephemeral packages during scanning
This is required to be able to do a scan without building them. Ignoring those is ok, because they don't contribute build artifacts that need scanning.
1 parent dc1aee4 commit 5e46b45

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

cmd/sbom-scan.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,17 @@ If no package is specified, the workspace's default target is used.`,
5454
deps := pkg.GetTransitiveDependencies()
5555
log.Infof("Scanning SBOMs for %s and %d dependencies to %s", pkg.FullName(), len(deps), outputDir)
5656

57-
allpkg = append(allpkg, deps...)
57+
// Skip ephemeral packages as they're not meant to be cached
58+
var filteredDeps []*leeway.Package
59+
for _, p := range deps {
60+
if p.Ephemeral {
61+
log.Infof("Skipping vulnerability scan for ephemeral package %s\n", p.FullName())
62+
continue
63+
}
64+
filteredDeps = append(filteredDeps, p)
65+
}
66+
67+
allpkg = append(allpkg, filteredDeps...)
5868
}
5969

6070
// Download packages from remote cache when needed

pkg/leeway/sbom-scan.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ func scanAllPackagesForVulnerabilities(buildctx *buildContext, packages []*Packa
8080
return xerrors.Errorf(string(errMsg))
8181
}
8282

83+
// Skip ephemeral packages as they're not meant to be cached
84+
if p.Ephemeral {
85+
buildctx.Reporter.PackageBuildLog(p, false, []byte(fmt.Sprintf("Skipping vulnerability scan for ephemeral package %s\n", p.FullName())))
86+
continue
87+
}
88+
8389
location, exists := buildctx.LocalCache.Location(p)
8490
if !exists {
8591
errMsg := fmt.Appendf(nil, "Package %s not found in local cache, cannot scan for vulnerabilities\n", p.FullName())

0 commit comments

Comments
 (0)