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

feat: Use custom pathtree library instead of third party trie #1341

Merged
merged 11 commits into from
Oct 25, 2024

Conversation

another-rex
Copy link
Collaborator

Turns out we don't need most of the functionality of the third party tire library. Built a simple and focused library pathtree which is just a tree with insert and get functions to allow us to implement a virtual filesystem easily.

v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/tarball"
"github.com/google/osv-scanner/internal/image/internal/pathtree"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to only have one internal in the path?
like google/osv-scanner/internal/pathtree or google/osv-scanner/internal/image/pathtree?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 is there a reason to have a nested internal here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove the second layer of internal, it is originally here since pathtree features are tied quite closely to image scanning.

v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/tarball"
"github.com/google/osv-scanner/internal/image/internal/pathtree"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 is there a reason to have a nested internal here?

}

// Get retrieves all the direct children of this given path
func (node *Node[V]) GetChildren(path string) []*V {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there any callers of this besides tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is needed for scalibr filesystem to implement ReadDIr, which is part of the parent PR.

@another-rex another-rex reopened this Oct 25, 2024
@another-rex another-rex changed the base branch from v2 to main October 25, 2024 05:27
@another-rex another-rex changed the base branch from main to v2 October 25, 2024 05:43
@codecov-commenter
Copy link

codecov-commenter commented Oct 25, 2024

Codecov Report

Attention: Patch coverage is 86.95652% with 12 lines in your changes missing coverage. Please review.

Project coverage is 68.49%. Comparing base (a78c74d) to head (55d2b0b).
Report is 1 commits behind head on v2.

Files with missing lines Patch % Lines
internal/image/pathtree/pathtree.go 88.15% 6 Missing and 3 partials ⚠️
internal/image/image.go 62.50% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v2    #1341      +/-   ##
==========================================
+ Coverage   68.44%   68.49%   +0.05%     
==========================================
  Files         184      185       +1     
  Lines       17739    17817      +78     
==========================================
+ Hits        12141    12204      +63     
- Misses       4929     4939      +10     
- Partials      669      674       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@another-rex another-rex enabled auto-merge (squash) October 25, 2024 06:38
@another-rex another-rex merged commit 4069367 into google:v2 Oct 25, 2024
13 checks passed
another-rex added a commit that referenced this pull request Nov 1, 2024
This PR contains all the code required to move to osv-scalibr while
making the existing code compile and pass all tests (container tests not
passing because of a bug in the scalibr alpine extractor).

Changes not mentioned in the following list will be split off in
separate PRs which should land before this PR.

Those are:
- [x] #1337 
- [x] #1331 
- [x] #1338 
- [x] #1341
- [x] #1345


Changes in this PR:
- Fixture changes:
- Scalibr Python requirements.txt extractor currently doesn't support
packages without versions, so added some version strings to the test
files
- Image package required quite a bit of reworking to successfully
update.
- Add the ability to iterate through a directory via the pathtree
library
  - Support scalibr FS interface for Layers
- Add conversion code to convert inventories from osv-scalibr back to
v1's lockfile and Inventory
- This is done to minimize snapshot changes. Followup PRs should remove
this conversion
- Add `internal/lockfilescalibr` package:
  - `errors.go` adds common extraction errors we want to translate.
- `translation.go` adds helper functions and translation logic between
osv-scanner v1 extractor names, and osv-scalibr extractor names.



Changes in followup PRs:
- Delete lockfiles package and migrate everything to use osv-scalibr
extractors
- Remove conversion code in image

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Gareth Jones <[email protected]>
Co-authored-by: Xueqin Cui <[email protected]>
Co-authored-by: Michael Kedar <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
another-rex added a commit that referenced this pull request Nov 29, 2024
Turns out we don't need most of the functionality of the third party
tire library. Built a simple and focused library pathtree which is just
a tree with insert and get functions to allow us to implement a virtual
filesystem easily.
another-rex added a commit that referenced this pull request Nov 29, 2024
This PR contains all the code required to move to osv-scalibr while
making the existing code compile and pass all tests (container tests not
passing because of a bug in the scalibr alpine extractor).

Changes not mentioned in the following list will be split off in
separate PRs which should land before this PR.

Those are:
- [x] #1337
- [x] #1331
- [x] #1338
- [x] #1341
- [x] #1345

Changes in this PR:
- Fixture changes:
- Scalibr Python requirements.txt extractor currently doesn't support
packages without versions, so added some version strings to the test
files
- Image package required quite a bit of reworking to successfully
update.
- Add the ability to iterate through a directory via the pathtree
library
  - Support scalibr FS interface for Layers
- Add conversion code to convert inventories from osv-scalibr back to
v1's lockfile and Inventory
- This is done to minimize snapshot changes. Followup PRs should remove
this conversion
- Add `internal/lockfilescalibr` package:
  - `errors.go` adds common extraction errors we want to translate.
- `translation.go` adds helper functions and translation logic between
osv-scanner v1 extractor names, and osv-scalibr extractor names.

Changes in followup PRs:
- Delete lockfiles package and migrate everything to use osv-scalibr
extractors
- Remove conversion code in image

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Gareth Jones <[email protected]>
Co-authored-by: Xueqin Cui <[email protected]>
Co-authored-by: Michael Kedar <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants