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

docs: improve targets documentation #8305

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

itaysk
Copy link
Contributor

@itaysk itaysk commented Jan 28, 2025

Description

  • define target types and refer to them in relevant places
  • use consistent structure for all targets docs (also simplify it)
  • (also update scanner embedding doc)

Related issues

@itaysk itaysk requested a review from knqyf263 as a code owner January 28, 2025 13:41
@itaysk
Copy link
Contributor Author

itaysk commented Jan 28, 2025

some clarifications about the target docs structure:

  1. start with general description of the target
  2. clearly classify the target pre/post scan
  3. include general usage example the covers supported arguments
  4. state supported scanners, and default scanners for the target
  5. cover additional flags and options

removed some sections/examples that appeared in some of the target and were redundant IMO
for the image scanning specifically, I decided to demote the image config section as it is no so popular and wasn't consistent with the structure, I documented it like all the other flags. Also I wasn't sure the podman detailed description was necessary but left it

@itaysk
Copy link
Contributor Author

itaysk commented Jan 28, 2025

after rebase, I guess cache is also part of the target consistent structure

    - define target types and refer to them in relevant places
    - use consistent structure for all targets docs (also simplify it)
    - (also update scanner embedding doc)
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.

Since this PR contains many changes, what if splitting it into some PRs? For example, docs/docs/advanced/container/embed-in-dockerfile.md, docs/docs/coverage/language/index.md. docs/docs/index.md, etc, don't seem to be blocked by other changes.


### Generation
Copy link
Collaborator

Choose a reason for hiding this comment

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

We got a request from the community to add a section about SBOM generation in this page so that people will not misunderstand Trivy supports only SBOM discovery.


Trivy scans the configuration of container images for
Supported scanners:
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not the case for image metadata scanning. --scanners configures scanners for image contents. We need to consider how we can clarify that. It's not clear now as this section is nested.


## SBOM generation
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here. We should keep it somehow.

## Files inside container images
Container images consist of files.
For instance, new files will be installed if you install a package.
`image` is a post-build target type, which means it scans installed packages. For more information, see [Target types](../coverage/language/index.md#target-types).
Copy link
Collaborator

Choose a reason for hiding this comment

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

#target-types seems like a dead anchor.

```
$ trivy fs ~/src/github.com/aquasecurity/trivy-ci-test/Pipfile.lock
```
`fs` is a pre-build target type, which means it scans package manager lock files. For more information, see [Target types](../coverage/language/index.md#target-types).
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto


## Scan Cache
When scanning git repositories, it stores analysis results in the cache, using the latest commit hash as the key.
Note that the cache is not used when the repository is dirty, otherwise Trivy will miss the files that are not committed.

More details are available in the [cache documentation](../configuration/cache.md#scan-cache-backend).

## References
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nesting these options looks organized to me. These are about specific usages and do not seem to be granular with the other items. Are there any reasons we should avoid it?

- [Scan container](../advanced/container/embed-in-dockerfile.md)
- [Scan unpacked container filesystem](../advanced/container/unpacked-filesystem.md)

`rootfs` is a post-build target type, which means it scans installed packages. For more information, see [Target types](../coverage/language/index.md#target-types).
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

$ trivy vm --scanners license [YOUR_VM_IMAGE]
```

## SBOM generation
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

Comment on lines +10 to +12
Usage:

You can scan a VM image file, Amazon Machine Image (AMI), or Amazon Elastic Block Store (EBS) snapshot.
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
Usage:
You can scan a VM image file, Amazon Machine Image (AMI), or Amazon Elastic Block Store (EBS) snapshot.
You can scan a VM image file, Amazon Machine Image (AMI), or Amazon Elastic Block Store (EBS) snapshot.
Usage:

Comment on lines -153 to -156
### Misconfigurations
It is supported, but it is not useful in most cases.
As mentioned [here](../scanner/misconfiguration/index.md), Trivy mainly supports Infrastructure as Code (IaC) files for misconfigurations.
If your VM image includes IaC files such as Kubernetes YAML files or Terraform files, you should enable this feature with `--scanners misconfig`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would mention this kind of information somewhere. "Misconfigurations" has a broader meaning. Our misconfiguration scanning is IaC-specific and usually doesn't function for container and VM images.

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.

3 participants