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

Add support to tar flag for docker scan #30

Closed

Conversation

guyshe-jfrog
Copy link
Contributor

@guyshe-jfrog guyshe-jfrog commented Feb 25, 2024

  • The pull request is targeting the dev branch.
  • The code has been validated to compile successfully by running go vet ./....
  • The code has been formatted properly using go fmt ./....
  • All static analysis checks passed.
  • All tests have passed. If this feature is not already covered by the tests, new tests have been added.
  • All changes are detailed at the description. if not already covered at JFrog Documentation, new documentation have been added.

Part of jfrog/jfrog-cli#2451

@attiasas attiasas added improvement Automatically generated release notes safe to test Approve running integration tests on a pull request labels Feb 26, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Feb 26, 2024
Copy link
Contributor

@attiasas attiasas left a comment

Choose a reason for hiding this comment

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

  1. Change the description and name of the Argument, now that it is not only a tag (at cli/docs/scan/dockerscan/help.go)

  2. Add integration tests that runs scan on .tar file

cli/docs/flags.go Outdated Show resolved Hide resolved
Comment on lines 73 to 82
if dsc.progress != nil {
dsc.progress.SetHeadlineMsg("Creating image archive 📦")
}
log.Info("Creating image archive...")
dockerSaveCmd := exec.Command("docker", "save", dsc.imageTag, "-o", imageTarPath)
var stderr bytes.Buffer
dockerSaveCmd.Stderr = &stderr
err = dockerSaveCmd.Run()
if err != nil {
return fmt.Errorf("failed running command: '%s' with error: %s - %s", strings.Join(dockerSaveCmd.Args, " "), err.Error(), stderr.String())
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
if dsc.progress != nil {
dsc.progress.SetHeadlineMsg("Creating image archive 📦")
}
log.Info("Creating image archive...")
dockerSaveCmd := exec.Command("docker", "save", dsc.imageTag, "-o", imageTarPath)
var stderr bytes.Buffer
dockerSaveCmd.Stderr = &stderr
err = dockerSaveCmd.Run()
if err != nil {
return fmt.Errorf("failed running command: '%s' with error: %s - %s", strings.Join(dockerSaveCmd.Args, " "), err.Error(), stderr.String())
if dsc.progress != nil {
dsc.progress.SetHeadlineMsg("Creating image archive 📦")
}
log.Info("Creating image archive...")
dockerSaveCmd := exec.Command("docker", "save", dsc.imageTag, "-o", imageTarPath)
var stderr bytes.Buffer
dockerSaveCmd.Stderr = &stderr
err = dockerSaveCmd.Run()
if err != nil {
return fmt.Errorf("failed running command: '%s' with error: %s - %s", strings.Join(dockerSaveCmd.Args, " "), err.Error(), stderr.String())

You can move it to a separated method to help with readability

commands/scan/dockerscan.go Outdated Show resolved Hide resolved
Comment on lines +60 to +63
func (auditCmd *AuditCommand) SetIsTar(isTar bool) *AuditCommand {
auditCmd.IsTar = isTar
return auditCmd
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why you need it in audit command? this is just for docker scan....

Co-authored-by: Assaf Attias <[email protected]>
Co-authored-by: Assaf Attias <[email protected]>
@attiasas
Copy link
Contributor

attiasas commented Jun 9, 2024

You can use the scan command to scan binary

@attiasas attiasas closed this Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Automatically generated release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants