-
Notifications
You must be signed in to change notification settings - Fork 15
perf: switch to kubescape/syft v1.32.0-ks.2 + disable file catalogers #798
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
Merged
+21
−3
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b3225ee
perf: disable file-digest/metadata/executable catalogers
slashben ca022e2
deps: switch to kubescape/syft v1.32.0-ks.2 for memory reduction
slashben b4ae37f
fix: check dep.Replace for actual fork version; add cataloger removal…
slashben 5136072
fix: keep syft tool version at required version
matthyx 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 622
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 419
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 410
🌐 Web query:
Go debug.ReadBuildInfo Replace field module replacement version information💡 Result:
In Go, runtime/debug.ReadBuildInfo returns a *debug.BuildInfo struct containing module information from the binary. The Main field and each entry in Deps are *debug.Module structs, which have a Replace *Module field. This field is populated if the module was replaced by a replace directive in go.mod during the build. When a replacement is active, the replaced module's Replace field points to the replacement module details (path, version, sum). In the BuildInfo.String output (used by go version -m), replacements appear as: mod example.com/mod v1.2.3 => example.com/replacement v1.3.0 or for deps similarly. Historically, issue
#37392(opened 2020) noted that BuildInfo did not honor replace directives for the main module containing package main, showing the original instead of replacement. Changes like CL 220645 aimed to fix this by recording replacements in cmd/go/internal/modload.PackageBuildInfo, but some reverts occurred. Current Go documentation and source code (as of go1.26) define and parse the Replace field, indicating support exists today. To access replacement info in code: import "runtime/debug" info, ok := debug.ReadBuildInfo if ok && info.Main.Replace != nil { fmt.Printf("Main replaced by: %s@%s\n", info.Main.Replace.Path, info.Main.Replace.Version) } for _, dep := range info.Deps { if dep.Replace != nil { fmt.Printf("Dep %s replaced by: %s@%s\n", dep.Path, dep.Replace.Path, dep.Replace.Version) } } If replacements are not appearing, verify: - Build with modules enabled (go build in module mode). - Use go build . or specify package path (not file args like main.go) to populate Main properly (Go 1.18+ behavior). - Check go version -m binary output confirms replacements. - No build flags stripping debug info. This provides complete visibility into module replacement version information at runtime.Citations:
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 1994
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 536
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 220
syftfork version does not propagate to runtime metadata and version-gating logic.At Line 472, the module is replaced with
github.com/kubescape/syft v1.32.0-ks.2, butpackageVersion()currently returns onlydep.Versionwithout checkingdep.Replace. This causes the metadata to use the original version (v1.32.0) instead of the replacement version. Since this version is used in version-gating logic at line 312 ofsbom_manager.goand recorded in SBOM metadata, the incorrect version can break conditional processing and produce inaccurate tool metadata.The
packageVersionfunction is defined in two locations (pkg/sbommanager/v1/sbom_manager.go:715andpkg/sbomscanner/v1/server.go:102) and both need the same fix:Proposed fix
func packageVersion(name string) string { bi, ok := debug.ReadBuildInfo() if ok { for _, dep := range bi.Deps { if dep.Path == name { + if dep.Replace != nil && dep.Replace.Version != "" { + return dep.Replace.Version + } return dep.Version } } } return "unknown" }🤖 Prompt for AI Agents