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(scan): support offline option #1511

Merged
merged 4 commits into from
Dec 24, 2021
Merged

feat(scan): support offline option #1511

merged 4 commits into from
Dec 24, 2021

Conversation

knqyf263
Copy link
Collaborator

@knqyf263 knqyf263 commented Dec 24, 2021

Description

This option allows avoiding Internet access. The results with/without the option may differ. For example, the offline mode will not try to resolve transitive dependencies in pom.xml when the dependency doesn't exist in the local repositories. On the other hand, the online mode will resolve those dependencies in the remote repositories. It means the dependencies might be fewer in offline mode.

Supported

  • pom.xml
  • JAR

Issues

Close #1294
Close #1290
Close #1173
Close #1057
Close #982

Blockers

@knqyf263 knqyf263 self-assigned this Dec 24, 2021
@knqyf263 knqyf263 marked this pull request as ready for review December 24, 2021 08:45
@knqyf263 knqyf263 changed the title feat: support offline option feat(scan): support offline option Dec 24, 2021
### Run Trivy with --skip-update option
In an air-gapped environment, specify `--skip-update` so that Trivy doesn't attempt to download the latest database file.
### Run Trivy with --skip-update and --offline option
In an air-gapped environment, specify `--skip-update` and `--offline` so that Trivy doesn't attempt to download the latest database file and issue any API requests for vulnerability scanning.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would mention that it affects Maven only (as of Dec 2021)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done 558b8b7

@@ -22,6 +22,7 @@ OPTIONS:
--timeout value timeout (default: 5m0s) [$TRIVY_TIMEOUT]
--ignore-policy value specify the Rego file to evaluate each vulnerability [$TRIVY_IGNORE_POLICY]
--list-all-pkgs enabling the option will output all packages regardless of vulnerability (default: false) [$TRIVY_LIST_ALL_PKGS]
--offline try to scan without Internet access (default: false) [$TRIVY_OFFLINE]
Copy link
Contributor

Choose a reason for hiding this comment

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

description is a bit ambiguous. Some new users may think it's enough to run trivy in air-gapped environment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Any suggestion?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

--offline-scan is better?

Copy link
Contributor

Choose a reason for hiding this comment

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

Something like this:
"Do not download extra information about dependencies . Some dependency parsers (like Maven) uses public API to download entire dependency tree. Use this option to disable that behavior"

Copy link
Contributor

Choose a reason for hiding this comment

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

--parse-offline?

Copy link
Contributor

Choose a reason for hiding this comment

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

or --parse-deps-offline

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks. It is a bit long for a help message. I fixed it based on your suggestion. I think it is clear enough to understand this option doesn't affect DB download.
558b8b7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment