-
Notifications
You must be signed in to change notification settings - Fork 856
Drop whiteout/opaque files and warn when pkg lacks Name/Version #1017
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
Closed
jonasagx
wants to merge
15
commits into
anchore:main
from
jonasagx:warn-python-pkg-without-basic-fields
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ec6e832
Warn when Python pkg lacks basic fields
jonasagx f41ad04
add test for missing data warning
jonasagx a562a67
drop redundant log warn
jonasagx 76922c2
update integration tests
jonasagx a276835
log path to problematic package file
jonasagx ebabc18
filter whiteout/opaque files from dictory resolver
jonasagx 0bacdd6
fix tests
jonasagx db9ae9b
add new image fixture for empty files
jonasagx 48aac42
move fixtures
jonasagx fa78aaf
clean up
jonasagx 2b93f95
fix diff
jonasagx e45a1a6
fix diff
jonasagx 02f2a26
cleaner unit and integration tests
jonasagx 5b4dd36
use image from GetFixtureImage in tests
jonasagx b6b84b2
undo test change
jonasagx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,14 @@ func (p *Package) OverrideID(id artifact.ID) { | |
| } | ||
|
|
||
| func (p *Package) SetID() { | ||
| if p.Name == "" { | ||
| log.Warnf("%s: missing package name, that is necessary for further metadata extraction. Please take a look at %s", p.FoundBy, p.Locations.ToSlice()) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning log to inform user which package has missing Name and/or Version. |
||
| } | ||
|
|
||
| if p.Version == "" { | ||
| log.Warnf("%s: missing package version, that is necessary for further metadata extraction. Please take a look at %s", p.FoundBy, p.Locations.ToSlice()) | ||
| } | ||
|
|
||
| id, err := artifact.IDByHash(p) | ||
| if err != nil { | ||
| // TODO: what to do in this case? | ||
|
|
||
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
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
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
Empty file.
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| content |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package cli | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/anchore/syft/syft" | ||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestPackageMissingNameAndVersion(t *testing.T) { | ||
| formats := syft.FormatIDs() | ||
| commonAssertions := []traitAssertion{ | ||
| func(tb testing.TB, _, stderr string, _ int) { | ||
| tb.Helper() | ||
| assert.Contains(tb, stderr, "python-package-cataloger: missing package name, that is necessary for further metadata extraction") | ||
| assert.Contains(tb, stderr, "python-package-cataloger: missing package version, that is necessary for further metadata extraction") | ||
| }, | ||
| assertSuccessfulReturnCode, | ||
| } | ||
|
|
||
| for _, o := range formats { | ||
| t.Run(fmt.Sprintf("format:%s", o), func(t *testing.T) { | ||
| cmd, stdout, stderr := runSyft(t, nil, "dir:./test-fixtures/image-empty-files/", "-o", string(o)) | ||
| for _, traitFn := range commonAssertions { | ||
| traitFn(t, stdout, stderr, cmd.ProcessState.ExitCode()) | ||
| } | ||
| if t.Failed() { | ||
| t.Log("STDOUT:\n", stdout) | ||
| t.Log("STDERR:\n", stderr) | ||
| t.Log("COMMAND:", strings.Join(cmd.Args, " ")) | ||
| } | ||
| }) | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| FROM scratch | ||
| COPY pkgs/ . |
Empty file.
1 change: 1 addition & 0 deletions
1
test/cli/test-fixtures/image-empty-files/pkgs/broken-1.0.0-py3.8.egg-info
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| broken |
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
Empty file.
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
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.
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.
This log line seems unnecessary with the new warning that works for all formats