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

ignore minor parsing error when reading dpkg status files #786

Merged
merged 12 commits into from
Feb 17, 2022

Conversation

jonasagx
Copy link
Contributor

@jonasagx jonasagx commented Feb 1, 2022

Fixes #733

Question: should we add a smarter parser to guess approximate installed-size
value?
A: yes, this PR uses go-humanize to parse storage metadata better

This PR also drops dpkg cataloger from returning parsing errors, they should not stop Syft. Warning with context were added.

Signed-off-by: Jonas Galvão Xavier [email protected]

@jonasagx jonasagx marked this pull request as draft February 1, 2022 21:42
@jonasagx jonasagx marked this pull request as ready for review February 3, 2022 05:42
@jonasagx jonasagx requested a review from a team February 4, 2022 17:51
@jonasagx jonasagx force-pushed the 733-fix-dpkg-parser branch from 28b3ab8 to 75e5b0f Compare February 7, 2022 21:40
@jonasagx jonasagx requested a review from wagoodman February 7, 2022 22:04
@jonasagx jonasagx self-assigned this Feb 8, 2022
@jonasagx jonasagx requested a review from a team February 8, 2022 17:06
Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

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

A couple suggestions I think might help maintainability and unclear about a couple error handling path changes. The main bit of the go-humanize addition looks great, though!

@jonasagx jonasagx force-pushed the 733-fix-dpkg-parser branch from 75e5b0f to 63f75cc Compare February 9, 2022 08:19
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.

This comment: #786 (comment) was resolved but it doesn't look like there's a corresponding change or additional conversation here.

@jonasagx jonasagx force-pushed the 733-fix-dpkg-parser branch from 63f75cc to 0b97c2f Compare February 10, 2022 00:01
helps with anchore#733

Question: should we add a smarter parser to guess approximate installed-size
value?

Signed-off-by: Jonas Galvão Xavier <[email protected]>
added unit tests to expand coverage of dpkg parsing

Signed-off-by: Jonas Galvão Xavier <[email protected]>
added unit tests to handleNewKeyValue

Signed-off-by: Jonas Galvão Xavier <[email protected]>
Signed-off-by: Jonas Galvão Xavier <[email protected]>
Signed-off-by: Jonas Galvão Xavier <[email protected]>
Signed-off-by: Jonas Galvão Xavier <[email protected]>
Signed-off-by: Jonas Galvão Xavier <[email protected]>
log warning with relevant context

Signed-off-by: Jonas Galvão Xavier <[email protected]>
Signed-off-by: Jonas Galvão Xavier <[email protected]>
simpler error assertion

Signed-off-by: Jonas Galvão Xavier <[email protected]>
Signed-off-by: Jonas Galvão Xavier <[email protected]>
@jonasagx jonasagx force-pushed the 733-fix-dpkg-parser branch from 3c83f16 to 75b0fde Compare February 16, 2022 20:49
@jonasagx jonasagx requested a review from a team February 16, 2022 21:25
Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

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

LGTM; just a couple suggestions that I wouldn't hold this up for

}{
{
name: "Test Single Package",
name: "Test Single Package",
fixturePath: filepath.Join("test-fixtures", "status", "single"),
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW all OSes can handle test-fixtures/status/single, including Windows

Copy link
Contributor

@spiffcs spiffcs left a comment

Choose a reason for hiding this comment

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

small comment about how we are parsing the size variables

@jonasagx jonasagx merged commit 4b16737 into anchore:main Feb 17, 2022
spiffcs pushed a commit that referenced this pull request Feb 18, 2022
* ignore minor parsing error when reading dpkg status files

helps with #733

Question: should we add a smarter parser to guess approximate installed-size
value?

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* add datasize lib to help dpkg parsing

added unit tests to expand coverage of dpkg parsing

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* drop parse error

added unit tests to handleNewKeyValue

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* don't return parsing errors from dpkg

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* go mod tidy

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* test higher level functions

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* return parsing err to let cataloger handle it

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* feedback changes

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* ignore key parsing error

log warning with relevant context

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* go mod tidy

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* add context info to log lines

simpler error assertion

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* use error.As to assert error in chain

Signed-off-by: Jonas Galvão Xavier <[email protected]>
spiffcs added a commit that referenced this pull request Feb 18, 2022
…hore/syft into 510-attach-sbomb-attestation

* '510-attach-sbomb-attestation' of https://github.com/anchore/syft: (63 commits)
  adjust attest options to be 12-factor-like
  update go.mod to latest cosign version
  update go mod
  update exported function for tests
  tests are passing
  configure failing tests
  ignore minor parsing error when reading dpkg status files (#786)
  update nit comments
  test harness for password verification
  update password select mechanism
  comment out test for future work
  Base64 encoder closing (#822)
  dog food attestation on syft image
  update function usage
  update correct predicate type formats for JSON
  update ci workflow to boostrap tools on cli tests
  update to bootstrap go
  update to find cosign temp
  access local temp directory
  check if cache issue
  ...
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
* ignore minor parsing error when reading dpkg status files

helps with anchore#733

Question: should we add a smarter parser to guess approximate installed-size
value?

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* add datasize lib to help dpkg parsing

added unit tests to expand coverage of dpkg parsing

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* drop parse error

added unit tests to handleNewKeyValue

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* don't return parsing errors from dpkg

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* go mod tidy

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* test higher level functions

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* return parsing err to let cataloger handle it

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* feedback changes

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* ignore key parsing error

log warning with relevant context

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* go mod tidy

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* add context info to log lines

simpler error assertion

Signed-off-by: Jonas Galvão Xavier <[email protected]>

* use error.As to assert error in chain

Signed-off-by: Jonas Galvão Xavier <[email protected]>
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.

unable to catalog dpkg package=/var/lib/dpkg/status
4 participants