Add file-based toolchain detection#4990
Open
wagoodman wants to merge 1 commit into
Open
Conversation
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This comment was marked as outdated.
This comment was marked as outdated.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Expands the executable cataloger to detect build tools such as compilers and linkers that actually built a binary. Results show up as a new
toolchainsfield on the executable file metadata, so you can tell a GCC-built binary from a Clang one, or spot which linker was used, straight from the file itself.Each detected entry records a name, a version (when we can pull one), and a
component(compiler vs linker today, with room to grow into assemblers and runtimes later).Example entry in the
.filessection of the syft json output:{ "id": "dae2c7632f4d4a42", "location": { "path": "/usr/lib/x86_64-linux-gnu/libubsan.so.1.0.0", "layerID": "sha256:eb20a6a75cbe349fec27d8830233974f8d1bfd356878792060042e7b48b31811" }, ... "executable": { ... "toolchains": [ { "name": "gcc", "version": "14.2.0", "component": "compiler" } ] } }Note: this feature was extracted out of a defunct PR #4454
What it detects today:
How it works (no new catalogers, this all rides on the existing executable cataloger):
.commentsection for the producer strings these compilers leave behind. icx is checked before clang since it's a clang fork that carries both strings, and clang is checked before gcc for the same reasonGCC: (...) <version>comment, so we disambiguate them by the language-specific runtime symbols they pull in (e.g.MAIN__/_gfortran_*,_Dmain,__go_go,adainit/__gnat_*). This also keeps a cgo-enabled gc binary from being misread as gccgo. Falls back to plaingcc.comment; gold drops a.note.gnu.gold-versionnote section. GNU ld (BFD) leaves no marker, so it's intentionally not detectedDetailed changes:
.commentstrings and the static + dynamic symbol tables are parsed once per binary and shared across detectors rather than re-read per checkToolchainandToolchainComponenttypes onfile.Executabletoolchains.godocumenting the next detectors we'd want and where their signal lives (rustc commit hashes, Swift, Haskell GHC, GNU as/ld, MSVC rich header, .NET CLR, Mach-O Swift, etc.)Schema bumped to 16.1.5 for the new field.