-
Couldn't load subscription status.
- Fork 727
Add cataloging of macho multi-architecture binaries #657
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
Conversation
Signed-off-by: Alex Goodman <[email protected]>
Signed-off-by: Alex Goodman <[email protected]>
Benchmark Test ResultsBenchmark results from the latest changes vs base branch |
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.
I tried it out and it works like a charm! See comments on code specifics, curious for your thoughts 😃
syft/pkg/cataloger/golang/exe.go
Outdated
| return []exe{&machoExe{file, e}}, nil | ||
| } | ||
|
|
||
| if bytes.HasPrefix(data, []byte("\xCA\xFE\xBA\xBE")) || bytes.HasPrefix(data[1:], []byte("\xCA\xFE\xBA\xBF")) { |
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.
It'd be good to add a sense of meaning to this if line in order to motivate these bytes.HasPrefix calls for the reader. If these conditions "mean" something, that'd be great as a factored out function, named for what it's doing. WDYT?
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.
I can add some clarity here for the new code added, however, for code that was copied out of the stdlib I have a preference to leave as is (that is, consistent with the other code around it. If we refactor the stdlib code, when we incorporate new stdlib code we need to re-re-factor it, which isn't fun).
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.
LGTM - 👍 to @luhring comments, but nothing else to add. Since the code was copied from the standard lib adding comments might make diffing in the future interesting, but I'm all for improvements.
exe.go does have
// This code was copied from the Go std library.
// https://github.com/golang/go/blob/master/src/cmd/go/internal/version/exe.go
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
@wagoodman did add some improvements regarding arch discoverability and stringifying some nasty values.
Signed-off-by: Alex Goodman <[email protected]>
|
Looks like in the future we might be able to get this from exported stdlib code (not released yet though, so not today) golang/go@b37a539 |
* add cataloging within universal binaries Signed-off-by: Alex Goodman <[email protected]> * update json test fixtures Signed-off-by: Alex Goodman <[email protected]> * add comments + correct 32 bit multi arch magic check Signed-off-by: Alex Goodman <[email protected]> Signed-off-by: fsl <[email protected]>
* add cataloging within universal binaries Signed-off-by: Alex Goodman <[email protected]> * update json test fixtures Signed-off-by: Alex Goodman <[email protected]> * add comments + correct 32 bit multi arch magic check Signed-off-by: Alex Goodman <[email protected]>
Adds the ability to catalog Macho multiarchitecture binaries that are built by the go compiler.
Additionally this PR:
This relates to goreleaser/goreleaser#2648 (comment)