-
Notifications
You must be signed in to change notification settings - Fork 748
Add symbol extraction for binaries #4454
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
Draft
wagoodman
wants to merge
12
commits into
main
Choose a base branch
from
add-go-symbol-extract
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+8,002
−77
Conversation
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
Signed-off-by: Alex Goodman <[email protected]>
Signed-off-by: Alex Goodman <[email protected]>
Signed-off-by: Alex Goodman <[email protected]>
Signed-off-by: Alex Goodman <[email protected]>
Signed-off-by: Alex Goodman <[email protected]>
Signed-off-by: Alex Goodman <[email protected]>
dcf76f6 to
a05608a
Compare
Signed-off-by: Alex Goodman <[email protected]>
22b25c6 to
703edff
Compare
Signed-off-by: Alex Goodman <[email protected]>
Signed-off-by: Alex Goodman <[email protected]>
Contributor
Author
|
Though this is feature complete, there is work in grype that needs to be done to validate this work. Since this changes the top level API there is no reason to merge this quite yet. |
Signed-off-by: Alex Goodman <[email protected]>
This comment was marked as outdated.
This comment was marked as outdated.
Signed-off-by: Alex Goodman <[email protected]>
Signed-off-by: Alex Goodman <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
This PR enhances the executable cataloger to extract symbol names and toolchain information from binaries (EL, Mach-O, and PE formats). This capability enables deeper analysis of what code is embedded in executables, which is particularly useful for vulnerability detection in Go binaries where symbols provide insight into which functions are actually compiled into the binary.
This ultimately supports anchore/grype#2960 in order to be able to use the go vulnerability dataset to prune vulnerabilities by symbols present.
There are two main enhancements:
Toolchain Detection
The executable cataloger now identifies the compiler/toolchain used to build binaries:
debug/buildinfo, extracts the Go version (e.g.,go1.21.5).commentsection (e.g.,gcc 13.2.0).commentsection (e.g.,clang 17.0.6)Toolchain information is surfaced in the SBOM under the
files[].executable.toolchainssection:{ "toolchains": [ { "name": "go", "version": "go1.21.5", "kind": "compiler" } ] }This is primarily necessary to detect and only extract symbols for golang binaries and not other binaries, however, we can expand the toolchains implementations detected (e.g. rust audit binaries) as well as kinds detected (such as linkers and runtimes).
Symbol Extraction
Symbols can be extracted from the binary's symbol table (using the same norms as the standard
nmoutput) and filtered based on configuration. Symbol extraction is disabled by default and must be explicitly enabled via configuration.These are configurable to the user via the following
syft.yamlconfigurations:symbols.capture: Which binaries to extract symbols from. Currently onlygolangis supported. Default is empty (disabled).symbols.types: Which nm-style symbol types to capture (T,t,R,r,D,d,B,b,C,U). Default:["T", "t"].symbols.go.standard-library: Include Go stdlib symbols. Default:true.symbols.go.extended-standard-library: Includegolang.org/x/*symbols. Default:true.symbols.go.third-party-modules: Include third-party module symbols. Default:true.The Go API (
executable.Config) exposes additional fine-grained controls not available via CLI:Symbols.Go.NormalizeVendoredModules: Stripvendor/prefix from module paths. Default:true.Symbols.Go.ExportedSymbols: Include exported (public) symbols. Default:true.Symbols.Go.UnexportedSymbols: Include unexported (private) symbols. Default:false.Symbols.Go.TypeEqualityFunctions: Include compiler-generatedtype:.eq.*functions. Default:false.Symbols.Go.GCShapeStencils: Include GC shape stencil functions for generics. Default:false.