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

feat: Update docker container scanning flag #1350

Merged
merged 6 commits into from
Oct 30, 2024

Conversation

another-rex
Copy link
Collaborator

@another-rex another-rex commented Oct 29, 2024

Resolves #1316

Update the --docker flag to:

  • Only accept one image to scan at a time (to make displaying results easier)
  • Call new image scanning function internally.
  • Acts like a convenience function for
docker save <image-name> > img-name.tar && osv-scanner --experimental-oci-image=img.name.tar

TODO:

  • Add an ACCEPTANCE test which uses docker to pull down a stable image.
  • Include a docker pull first, as docker save only saves images already on device and does not pull images online.

@another-rex another-rex marked this pull request as ready for review October 30, 2024 00:55
@codecov-commenter
Copy link

codecov-commenter commented Oct 30, 2024

Codecov Report

Attention: Patch coverage is 78.08219% with 16 lines in your changes missing coverage. Please review.

Project coverage is 68.73%. Comparing base (1ef84e7) to head (3aec658).

Files with missing lines Patch % Lines
pkg/osvscanner/osvscanner.go 68.62% 11 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v2    #1350      +/-   ##
==========================================
+ Coverage   68.43%   68.73%   +0.30%     
==========================================
  Files         187      187              
  Lines       17872    17884      +12     
==========================================
+ Hits        12230    12293      +63     
+ Misses       4968     4915      -53     
- Partials      674      676       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

pkg/osvscanner/osvscanner.go Outdated Show resolved Hide resolved

err = cmd.Start()
r.Infof("Pulling docker image (%q)...\n", dockerImageName)
err = runCommandLogError(r, "docker", "pull", "-q", dockerImageName)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the CLI output if docker doesn't exist on the user's system?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

            Failed to run docker command ("docker pull -q alpine:non-existent-tag"): exec: "docker": executable file not found in $PATH
            exec: "docker": executable file not found in $PATH

Copy link
Collaborator

Choose a reason for hiding this comment

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

nice! that's pretty clear to the user.

@another-rex another-rex merged commit 1638434 into google:v2 Oct 30, 2024
14 checks passed
another-rex added a commit to another-rex/osv-scanner that referenced this pull request Nov 1, 2024
Resolves google#1316 

Update the --docker flag to:
- Only accept one image to scan at a time (to make displaying results
easier)
- Call new image scanning function internally.
- Acts like a convenience function for 
```
docker save <image-name> > img-name.tar && osv-scanner --experimental-oci-image=img.name.tar
```

TODO: 
- [x] Add an ACCEPTANCE test which uses docker to pull down a stable
image.
- [x] Include a docker pull first, as docker save only saves images
already on device and does not pull images online.
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.

4 participants