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(image): add support for passing architecture and OS #3012

Conversation

ShubhamPalriwala
Copy link
Contributor

Description

Adds support for passing an architecture and OS to the image command:
They can be used as:

Pass a --platform argument with a valid architecture and OS combination on the remote image:

$ trivy image --platform=architecture/os image

Example:

$ trivy image --platform=arm/linux python:latest-alpine

This PR also introduces the tests for the same in image_test.go

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@@ -35,6 +35,195 @@ Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 1, HIGH: 0, CRITICAL: 0)

</details>

### Scan the image on a specific Architecture and OS
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment on lines 237 to 239
# Scan a container image on a specific architecture and os
$ trivy image --platform=arm/linux python:3.4-alpine

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for adding, but we can remove the example. I'd like to list here only the frequently used flags.

@@ -25,6 +26,17 @@ func tryRemote(ctx context.Context, imageName string, ref name.Reference, option
remoteOpts = append(remoteOpts, remote.WithTransport(t))
}

if option.Platform != "" {
platform := strings.Split(option.Platform, "/")
Copy link
Collaborator

Choose a reason for hiding this comment

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

@ShubhamPalriwala
Copy link
Contributor Author

@knqyf263 Thank you for your feedback! Made the required and necessary changes! Please take a look :))

@knqyf263 knqyf263 merged commit 8ae4627 into aquasecurity:main Oct 25, 2022
@knqyf263
Copy link
Collaborator

Thanks for your great contribution!

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.

Request for Trivy OSS support for multiple architecture scan
2 participants