Skip to content

feat(sbom): add a dedicated sbom command#1799

Merged
knqyf263 merged 21 commits intoaquasecurity:mainfrom
tamirkiviti13:sbom-subcommand
Mar 23, 2022
Merged

feat(sbom): add a dedicated sbom command#1799
knqyf263 merged 21 commits intoaquasecurity:mainfrom
tamirkiviti13:sbom-subcommand

Conversation

@tamirkiviti13
Copy link
Contributor

Description

This PR adds a new dedicated SBOM generation subcommand - trivy sbom.

Related issues

@CLAassistant
Copy link

CLAassistant commented Mar 6, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@knqyf263 knqyf263 left a comment

Choose a reason for hiding this comment

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

Flags: []cli.Flag{
&formatFlag,
&outputFlag,
&exitCodeFlag,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like sbom doesn't need --exit-code since this option makes the job fail when critical vulnerabilities are found.


func analyzeArtifactPath(artifactPath string) (ArtifactType, string) {
// The user can specify the input artifact type by using the "<artifact-type>:" prefix before the artifact path
// e.g docker:ubuntu, package:/path/to/express
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// e.g docker:ubuntu, package:/path/to/express
// e.g docker:ubuntu, dir:/path/to/express

Comment on lines +525 to +527
ArgsUsage: "artifact",
Usage: "generate sbom for an artifact",
Action: artifact.SbomRun,
Copy link
Collaborator

Choose a reason for hiding this comment

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

In addition to usage, we may want to add a description since this subcommand is a bit complex.

Suggested change
ArgsUsage: "artifact",
Usage: "generate sbom for an artifact",
Action: artifact.SbomRun,
ArgsUsage: "ARTIFACT",
Usage: "generate sbom for an artifact",
Description: fmt.Sprintf(`"ARTIFACT" uses a "transport":"details" format.
Supported transports:
%s
`, artifact.ArtifactTypes.String()),

type ArtifactType string

const (
DockerImageArtifact ArtifactType = "docker"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Trivy also supports Podman and we're trying to add support for Containerd. How about image?

Suggested change
DockerImageArtifact ArtifactType = "docker"
ContainerImageArtifact ArtifactType = "image"

@tamirkiviti13 tamirkiviti13 changed the title faet(sbom): add a dedicated sbom command feat(sbom): add a dedicated sbom command Mar 7, 2022
Supported types: %s`, artifact.ArtifactTypes),
Action: artifact.SbomRun,
Flags: []cli.Flag{
&formatFlag,
Copy link
Collaborator

Choose a reason for hiding this comment

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

table and template don't make sense. We should restrict formats that can be specified.

</details>

!!! caution
It doesn't support vulnerabilities yet, but installed packages.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@@ -0,0 +1,21 @@
# Sbom
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit

Suggested change
# Sbom
# SBOM

mkdocs.yml Outdated
- Repository: getting-started/cli/repo.md
- Client: getting-started/cli/client.md
- Server: getting-started/cli/server.md
- Sbom: getting-started/cli/sbom.md
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Sbom: getting-started/cli/sbom.md
- SBOM: getting-started/cli/sbom.md

@knqyf263 knqyf263 merged commit f36d9b6 into aquasecurity:main Mar 23, 2022
@knqyf263
Copy link
Collaborator

Thanks

@hazcod
Copy link

hazcod commented Mar 24, 2022

Thank you @tamirkiviti13 !

ankk13 referenced this pull request in ankk13/trivy Mar 28, 2022
Co-authored-by: knqyf263 <knqyf263@gmail.com>
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.

Adding a dedicated subcommand for SBOM generation

5 participants