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

Autodetect compressed tarballs and fix --scan-images flag #37

Merged
merged 2 commits into from
Jan 29, 2022

Conversation

puerco
Copy link
Member

@puerco puerco commented Jan 28, 2022

What type of PR is this?

/kind bug

What this PR does / why we need it:

This PR fixes two bugs:

  1. Compressed tarballs are now autodetected and correctly handled by checking the first bytes in the header.
  2. There was a missing bit in the new --scan-images flag that missed some plumbing. Fixed now.

Which issue(s) this PR fixes:

Fixes #36

Special notes for your reviewer:

Does this PR introduce a user-facing change?

- Tarball headers are now checked to see if they are compressed. Previously we relied on file extensions which made the tarball handling code flaky
- Fixed a proble where `--scan-images` was unresponsive because a bug in the internal plumbing 

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 28, 2022
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 28, 2022
There was a missing piece in the code to plumb the ScanImages option from
the cmdline to the spdx object. This commit fixes it.

Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 28, 2022
@puerco puerco changed the title Tar bytes Autodetect compressed tarballs and fix --scan-images flag Jan 28, 2022
@kfaseela
Copy link
Contributor

kfaseela commented Jan 28, 2022

/lgtm thanks @puerco

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kfaseela, puerco

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kfaseela
Copy link
Contributor

/lgtm

@k8s-ci-robot
Copy link
Contributor

@kfaseela: changing LGTM is restricted to collaborators

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

pkg/osinfo/layer_scanner.go Outdated Show resolved Hide resolved
pkg/osinfo/layer_scanner.go Outdated Show resolved Hide resolved
pkg/osinfo/layer_scanner.go Outdated Show resolved Hide resolved
@@ -86,8 +86,22 @@ func (di *spdxDefaultImplementation) ExtractTarballTmp(tarPath string) (tmpDir s
}
defer f.Close()

// Read the first bytes to determine if the file is compressed
var sample [2]byte
Copy link
Member

Choose a reason for hiding this comment

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

same observations as above ... do we want to put this in a method that can be called from both places?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, yes I'm aware of this. I'm working on a PR to move this functionality to our tar package and once we cut a release there I will refactor all the tar code in the project.

Tar functions will now detect compressed files and
open them accordingly without relying on the file
extension.

Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
@puerco
Copy link
Member Author

puerco commented Jan 29, 2022

Thanks a lot @dims I've addressed your comments, PTAL :)

@puerco puerco added this to the v0.3.0 milestone Jan 29, 2022
@dims
Copy link
Member

dims commented Jan 29, 2022

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 29, 2022
@k8s-ci-robot k8s-ci-robot merged commit bdc0fa7 into kubernetes-sigs:main Jan 29, 2022
@puerco puerco deleted the tar-bytes branch January 29, 2022 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image layer code should inspect bytes instead of relying on file extension
4 participants