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 new Path filter function to index paths based on the filter #151

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

gnmahanth
Copy link

Signed-off-by: gnmahanth <mahanth@deepfence.io>
Signed-off-by: gnmahanth <mahanth@deepfence.io>
Signed-off-by: gnmahanth <mahanth@deepfence.io>
Signed-off-by: gnmahanth <mahanth@deepfence.io>
Copy link
Contributor

@wagoodman wagoodman left a comment

Choose a reason for hiding this comment

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

I like the improvement to the visitor 👍 I have a couple of comments:

  1. My preference on the changes at the top-level API is to lean into the existing functional options (type Option) approach and allow for a filter to be optional. In that sense, passing a default function that always returns true is alright, but a slightly more preferable approach would be to pass nil by default and not call the filter if it doesn't exist down in the visitor.
  2. A test is needed to show the effect of the path filter on the visitor.

Shout out if you want to chat more about this!

bradleyjones and others added 21 commits June 15, 2023 17:06
* feat: update golang to 1.19

Go 1.18 will become EOL with the upcoming 1.20 release

Signed-off-by: Bradley Jones <bradley.jones@anchore.com>

* chore: update golangci lint

Move to a newer version of golangci lint compatibile with go 1.19 and
remove now deprecated linters.

Signed-off-by: Bradley Jones <bradley.jones@anchore.com>

* chore: update deprecated ioutil functions

Signed-off-by: Bradley Jones <bradley.jones@anchore.com>

* chore: add crypto/internal/boring to bouncer ignore list

Signed-off-by: Bradley Jones <bradley.jones@anchore.com>

* fix: nolintlint formatting updated

Signed-off-by: Bradley Jones <bradley.jones@anchore.com>

---------

Signed-off-by: Bradley Jones <bradley.jones@anchore.com>
* add additional catalog indexes for performance

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* [wip] link resolution

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add leaf link resolution on tree responses (defer ancestor link resolution)

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add filetree search context

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add tests for new search context object

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* remove unused tar header fields from file.Metadata struct

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* use singular file type definitions

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add logging for filetree searches

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add limited support for glob classes and alternatives

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add failing test to show that index shortcircuits correct behavior

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add link resolution via filetree search context

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* allow index symlink resolution to function through cycles

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add tests for filetree.Index

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add search by parent basename and fix requirements filtering

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* sort search results

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* change file.Type to int + fix layer 0 squashed search context

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* more cleanup

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* switch to generic set implementation

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* update linter

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* replace generic set implemetation with plain set (unstable in go1.19)

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* introduce filtree builter and foster usage of reader interfaces

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* rename content helper functions

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* update docs with background

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* fix get_xid for cross compilation

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* upgrade CI validations workflow

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* fix snapshot builds

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add tests for file.Index.GetByFileType

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* rename file.Type and file.Resolution

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* ensure that glob results match search facade

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* replace stringset implementation + move resolution tests

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add note about podman dependency for testing

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* address PR comments

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* remove extra whitespace

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* constrain OS build support

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* update/remove TODO comments

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

---------

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Weston Steimel <weston.steimel@anchore.com>
* test: add failing test for cycle case

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>

* test: test updates sym links

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>

* change the filetree recursive pathset to represent open calls

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add another cycle test

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* change filetree attempting path set to counters

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* remove comment

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* fix linting

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

---------

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Co-authored-by: Christopher Phillips <christopher.phillips@anchore.com>
* test: add failing test for cycle case

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>

* test: test updates sym links

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>

* change the filetree recursive pathset to represent open calls

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add another cycle test

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* change filetree attempting path set to counters

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* remove comment

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* fix linting

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* feat: decrement stack depth

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>

* test: remove old wip test name

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>

* chore: style updates

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>

* feat: move maxLinkDepth decrement to inside ancestor loop

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>

* feat: move maxLinkDepth decrement into resolveNodeLinks loop

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>

* feat: move detection to top and write minimal test case

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>

* test: update linkResolution test to use internal value

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>

---------

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Co-authored-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Kushal Beniwal <kbeniwal2305@gmail.com>
…n. (anchore#164)

* Add Authenticator as an explicit option.

Signed-off-by: Ville Aikas <vaikas@chainguard.dev>

* wire in keychain also.

Signed-off-by: Ville Aikas <vaikas@chainguard.dev>

---------

Signed-off-by: Ville Aikas <vaikas@chainguard.dev>
* fix tmpDirGenerator chain of responsibility associated with anchore#132

Signed-off-by: Joseph Barnett <jb@slim.ai>
Signed-off-by: jb@slim.ai <jb@slim.ai>

* reduce log message to debug
Signed-off-by: Joseph Barnett <jb@slim.ai>

Signed-off-by: jb@slim.ai <jb@slim.ai>

* restore global cleanup function

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

---------

Signed-off-by: Joseph Barnett <jb@slim.ai>
Signed-off-by: jb@slim.ai <jb@slim.ai>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Co-authored-by: Alex Goodman <alex.goodman@anchore.com>
…re#152)

* set the default platform for select sources based on host arch

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* decompose into smaller function and add tests for setting default platform

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

---------

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 20.10.12+incompatible to 20.10.24+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](moby/moby@v20.10.12...v20.10.24)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* bind file times to metadata

Signed-off-by: Adrian Wobito <adrian.wobito@gmail.com>

* expose link strategy to walkConditions

Signed-off-by: Adrian Wobito <adrian.wobito@gmail.com>

* update: test times

Signed-off-by: Adrian Wobito <adrian.wobito@gmail.com>

* update: link options api

Signed-off-by: Adrian Wobito <adrian.wobito@gmail.com>

* stub mod time for dynamic tar test fixtures

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* set mtime on tar fixture explicitly

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* always interpret tar header timestamps as UTC

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* interpret all file metadata timestamps as UTC

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

---------

Signed-off-by: Adrian Wobito <adrian.wobito@gmail.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Co-authored-by: Alex Goodman <alex.goodman@anchore.com>
* fix linting

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add format make target

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add developing reference to format target

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

---------

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
* refactor: embed fs.FileInfo within file.Metadata

Embed the original `fs.FileInfo` directly within the `file.Metadata
struct`, replacing the previous `Size`, `IsDir`, `Mode`, and `ModTime`
fields.

Signed-off-by: Adam Hughes <9903835+tri-adam@users.noreply.github.com>

* add ManualInfo helper struct

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

---------

Signed-off-by: Adam Hughes <9903835+tri-adam@users.noreply.github.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Co-authored-by: Alex Goodman <alex.goodman@anchore.com>
Otherwise, "make integration" will fail on M1 Macs. Note that this is a
workaround which assumes that, if "make integration" is run on an arm64
host, that host is able to run containers from amd64 images. This change
enables development on stereoscope on M1 Macs, but may not enable it on
other arm64 machines.

Signed-off-by: Will Murphy <will.murphy@anchore.com>
Bumps [github.com/docker/distribution](https://github.com/docker/distribution) from 2.8.1+incompatible to 2.8.2+incompatible.
- [Release notes](https://github.com/docker/distribution/releases)
- [Commits](distribution/distribution@v2.8.1...v2.8.2)

---
updated-dependencies:
- dependency-name: github.com/docker/distribution
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This reverts commit d7551b7.

Defaulting to platform for all providers resulted in syft having unnecessary
when pulling an image that had a particular digest, if that digest didn't match
the architecture of the host running the pull. Revert commit
d7551b7, which introduced that error, but then
add platform defaulting logic back for the OCI Registry Provider, since
defaulting there has been specifically requested. Add integ tests to cover the
new behavior. Also, update integ tests to use the manifest ID for assertsion,
since the RepoDigests array can be empty.

Signed-off-by: Will Murphy <will.murphy@anchore.com>
@wagoodman
Copy link
Contributor

@gnmahanth would you like help incorporating the above comments?

@wagoodman wagoodman removed their assignment Feb 26, 2024
@wagoodman wagoodman self-assigned this May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Stalled
Development

Successfully merging this pull request may close these issues.

syft memory usage is high