Skip to content
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

Add relationships to ELF packages #2715

Merged
merged 30 commits into from May 9, 2024
Merged

Add relationships to ELF packages #2715

merged 30 commits into from May 9, 2024

Conversation

brian-ebarb
Copy link
Contributor

@brian-ebarb brian-ebarb commented Mar 14, 2024

This PR adds DependencyOf relationships when ELF packages have been discovered by the binary cataloger. The discovered file.Executable type has a []ImportedLibraries that's read from the file when discovered by syft. By mapping these imported libraries back to the package collection, syft is able to create relationships showing which packages are dependencies of other packages by just reading metadata from the ELF executable.

Testing

The integration test found under cmd/syft/internal/test/integration/package_binary_elf_relationships_test.go covers a sample image where the following graph is true:

"glibc": {
	"libhello_world.so",
	"syfttestfixture",
},
"libstdc++": {
	"syfttestfixture",
},
"libhello_world.so": {
	"syfttestfixture",
},

The above data structure can be read as glibc IS A DEPENDENCY OF syfttestfixture

For more information about the fixture see this document:
https://github.com/anchore/syft/blob/4fe0c98d0fe85417be596836d8798b7b10d43b1f/syft/pkg/cataloger/binary/test-fixtures/elf-test-fixtures/README.md

@github-actions github-actions bot added the json-schema Changes the json schema label Mar 14, 2024

This comment has been minimized.

This comment has been minimized.

@github-actions github-actions bot removed the json-schema Changes the json schema label Apr 17, 2024
@wagoodman wagoodman changed the title feat - add package to package and package to file relationships Add relationships to ELF packages Apr 25, 2024
@spiffcs
Copy link
Contributor

spiffcs commented Apr 25, 2024

I've updated the unit tests and SA on this PR - there are maybe 2 more cases to cover, but we're very close.

The one issue in particular I'm keen on testing is if the relationships are still created IF an RPM package shadows/overrides an ELF binary package. We need a way to pass the import paths discovered up to the RPM package so that these don't get dropped

wagoodman and others added 14 commits April 26, 2024 15:21
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Brian Ebarb <ebarb.brian@gmail.com>
Signed-off-by: Brian Ebarb <ebarb.brian@gmail.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
…uive base path

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
@spiffcs
Copy link
Contributor

spiffcs commented Apr 29, 2024

From my perspective there is one final TODO on this PR:

A case needs to be covered where syft does some clean up during Finalize and removes duplicate packages (this code has not yet been written).

Example: if ELF Package (a) is a part of RPM Package (b), then ELF Package (a) is deleted as a duplicate from the SBOM... this means that RPM Package (b) should all get all of ELF Package (A)s relationships.

I'm working on this now as the final addition.

If @wagoodman could look at the whole PR and give his final thoughts on if we're missing anything else that would be very much appreciated

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
@spiffcs spiffcs force-pushed the main branch 3 times, most recently from ec71fb9 to 6bf7ca2 Compare May 8, 2024 11:32
@spiffcs spiffcs marked this pull request as ready for review May 8, 2024 11:34
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
@spiffcs spiffcs merged commit 4194a2c into anchore:main May 9, 2024
11 checks passed
@spiffcs spiffcs added the enhancement New feature or request label May 9, 2024
@spiffcs spiffcs mentioned this pull request May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants