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

Omit empty packages #312

Merged
merged 4 commits into from
Jan 22, 2021
Merged

Omit empty packages #312

merged 4 commits into from
Jan 22, 2021

Conversation

luhring
Copy link
Contributor

@luhring luhring commented Jan 22, 2021

Closes #311

This PR changes the parsing of package.json such that files that don't include the minimally required fields (currently name and version) will not be surfaced as packages. A DEBUG level message is logged in this case.

@luhring luhring requested review from alfredodeza and zhill January 22, 2021 19:01
@luhring luhring self-assigned this Jan 22, 2021
@@ -172,6 +173,12 @@ func parsePackageJSON(_ string, reader io.Reader) ([]pkg.Package, error) {
return nil, fmt.Errorf("failed to parse package.json file: %w", err)
}

if !p.hasMinimumRequiredValues() {
log.Debug("encountered package.json file without the minimum number of field values required for" +
Copy link
Contributor

Choose a reason for hiding this comment

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

which fields? (I know, but a user will probably not)

}

if len(actual) != 0 {
t.Errorf("no packages should've been returned")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
t.Errorf("no packages should've been returned")
t.Errorf("no packages should've been returned, but got %d", len(actual))

@@ -1,2 +1,5 @@
FROM alpine:latest
RUN apk add tzdata vim alpine-sdk
FROM alpine@sha256:d9a7354e3845ea8466bb00b22224d9116b183e594527fb5b6c3d30bc01a20378
Copy link
Contributor

Choose a reason for hiding this comment

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

yassss

@luhring luhring force-pushed the omit-empty-packages branch from e5bfbaa to 9ec3ad5 Compare January 22, 2021 19:03
@luhring luhring requested a review from alfredodeza January 22, 2021 20:25
@luhring luhring merged commit 7bcdafe into main Jan 22, 2021
@luhring luhring deleted the omit-empty-packages branch January 22, 2021 21:10
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
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.

Partial package.json files lead to empty packages in output
2 participants