Compare commits

..

112 Commits

Author SHA1 Message Date
Teppei Fukuda
bc0836623c fix(cli): pass integer to exit-on-eol (#3716) 2023-03-01 12:18:11 +02:00
Itay Shakury
23cdac02ee feat: add kubernetes pss compliance (#3498)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-03-01 12:10:34 +02:00
Kalyana Krishna Varanasi
302c8ae24c feat: Adding --module-dir and --enable-modules (#3677)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-03-01 12:09:53 +02:00
Teppei Fukuda
34120f4201 feat: add special IDs for filtering secrets (#3702) 2023-03-01 09:51:11 +02:00
simar7
e399ed8439 chore(deps): Update defsec (#3713)
* chore(deps): Update defsec

* fix tests
2023-03-01 08:10:03 +02:00
simar7
ef7b762e48 docs(misconf): Add guide on input schema (#3692)
* docs(misconf): Add guide on input schema

* Update docs/docs/misconfiguration/custom/schema.md

Co-authored-by: Itay Shakury <itay@itaysk.com>

* make schema usage more descriptive

* docs: point to the full page

* update docs

Signed-off-by: Simar <simar@linux.com>

---------

Signed-off-by: Simar <simar@linux.com>
Co-authored-by: Itay Shakury <itay@itaysk.com>
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-28 15:55:49 -08:00
Teppei Fukuda
00daebc161 feat(go): support dependency graph and show only direct dependencies in the tree (#3691) 2023-02-28 13:24:53 +02:00
chenk
98d1031552 feat: docker multi credential support (#3631)
Signed-off-by: chenk <hen.keinan@gmail.com>
2023-02-28 11:42:37 +02:00
Teppei Fukuda
b791362871 feat: summarize vulnerabilities in compliance reports (#3651) 2023-02-28 00:09:00 +02:00
Teppei Fukuda
719fdb1b11 feat(python): parse pyproject.toml alongside poetry.lock (#3695)
Co-authored-by: DmitriyLewen <dmitriy.lewen@smartforce.io>
2023-02-27 20:48:55 +02:00
DmitriyLewen
3ff5699b4b feat(python): add dependency tree for poetry lock file (#3665)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-26 16:15:00 +02:00
Masahiro331
33909d9df3 fix(cyclonedx): incompliant affect ref (#3679) 2023-02-26 16:04:29 +02:00
Manuel Morejón
d85a3e087b chore(helm): update skip-db-update environment variable (#3657)
Signed-off-by: Manuel Morejon <manuel@mmorejon.io>
2023-02-26 14:16:17 +02:00
Masahiro331
551899c24e fix(spdx): change CreationInfo timestamp format RFC3336Nano to RFC3336 (#3675) 2023-02-26 10:11:47 +02:00
Teppei Fukuda
3aaa2cfb75 fix(sbom): export empty dependencies in CycloneDX (#3664) 2023-02-25 18:33:59 +02:00
Dmitry Ivankov
9d1300c3e7 docs: java-db air-gap doc tweaks (#3561)
Downloaded file name is `javadb.tar.gz` rather than `db.tar.gz`.
Also `--skip-update` is deprecated in favor of `--skip-db-update` and `--skip-java-db-update`.
2023-02-24 17:54:29 +02:00
Teppei Fukuda
793cc43d4c feat(go): license support (#3683) 2023-02-24 17:52:35 +02:00
AndreyLevchenko
6a3294e476 feat(ruby): add dependency tree/location support for Gemfile.lock (#3669)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-23 23:47:28 +02:00
chenk
e9dc21d88a fix(k8s): k8s label size (#3678)
Signed-off-by: chenk <hen.keinan@gmail.com>
2023-02-23 15:09:27 +02:00
Masahiro331
12976d42df fix(cyclondx): fix array empty value, null to [] (#3676) 2023-02-23 13:35:59 +02:00
Teppei Fukuda
1dc2b349c6 refactor: rewrite gomod analyzer as post-analyzer (#3674) 2023-02-23 13:35:08 +02:00
chenk
92eaf636ca feat: config outdated-api result filtered by k8s version (#3578)
Signed-off-by: chenk <hen.keinan@gmail.com>
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-22 15:41:37 +02:00
Alexander Lauster
9af436b999 fix: Update to Alpine 3.17.2 (#3655)
Fix CVE-2023-0286
2023-02-21 19:38:20 +02:00
Teppei Fukuda
88ee68d0c6 feat: add support for virtual files (#3654) 2023-02-20 17:20:57 +02:00
Teppei Fukuda
75c96bd968 feat: add post-analyzers (#3640)
Co-authored-by: DmitriyLewen <dmitriy.lewen@smartforce.io>
2023-02-20 13:08:26 +02:00
Edoardo Vacchi
baea3997d2 chore(deps): updates wazero to 1.0.0-pre.9 (#3653)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-02-20 13:03:28 +02:00
dependabot[bot]
7ca0db17ea chore(deps): bump github.com/go-openapi/runtime from 0.24.2 to 0.25.0 (#3528)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-20 13:01:33 +02:00
dependabot[bot]
866999e454 chore(deps): bump github.com/containerd/containerd from 1.6.15 to 1.6.18 (#3633)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-20 10:11:01 +02:00
DmitriyLewen
b7bfb9a207 feat(python): add dependency locations for Pipfile.lock (#3614) 2023-02-20 09:51:42 +02:00
dependabot[bot]
9badef27ac chore(deps): bump golang.org/x/net from 0.5.0 to 0.7.0 (#3648)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-19 15:51:12 +02:00
DmitriyLewen
d856595b8e fix(java): fix groupID selection by ArtifactID for jar files. (#3644) 2023-02-18 09:07:08 +02:00
dependabot[bot]
fe7c26a741 chore(deps): bump github.com/aws/aws-sdk-go-v2/service/ec2 from 1.63.1 to 1.85.0 (#3607)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-17 12:44:55 +02:00
Gio Rodriguez
f251dfc5ce fix(aws): Adding a fix for update-cache flag that is not applied on AWS scans. (#3619)
* adding a fix for update-cache that was not applied on AWS scans.

* removing unneeded code

---------

Co-authored-by: Gio Rodriguez <giovanni.rodriguez@aquasec.com>
2023-02-16 22:49:20 +02:00
didiermichel
9be8062c10 feat(cli): add command completion (#3061)
Co-authored-by: congbang-le <lecongbang314@gmail.com>
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-15 13:29:03 +02:00
Duy Nguyen
370098dbf4 docs(misconf): update dockerfile link (#3627) 2023-02-15 11:54:56 +02:00
Jack Lin
32acd293fd feat(flag): add exit-on-eosl option (#3423)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-15 10:51:15 +02:00
dependabot[bot]
aa8e185e03 chore(deps): bump github.com/go-git/go-git/v5 from 5.4.2 to 5.5.2 (#3533)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-14 16:17:28 +02:00
Alexej Disterhoft
86603bb9c5 fix(cli): make java db repository configurable (#3595)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-14 15:01:15 +02:00
chenk
7b1e173f51 chore: bump trivy-kubernetes (#3613)
Signed-off-by: chenk <hen.keinan@gmail.com>
2023-02-14 13:23:45 +02:00
Helge Eichelberg
85d5d61bc7 chore(helm): update Trivy from v0.36.1 to v0.37.2 (#3574)
* chore(helm): update Trivy from v0.36.1 to v0.37.1

Signed-off-by: elchenberg <elchenberg@users.noreply.github.com>

* chore(helm): bump Trivy to v0.37.2

Signed-off-by: elchenberg <elchenberg@users.noreply.github.com>

---------

Signed-off-by: elchenberg <elchenberg@users.noreply.github.com>
2023-02-14 13:10:07 +02:00
dependabot[bot]
2c17260ba8 chore(deps): bump github.com/spf13/viper from 1.14.0 to 1.15.0 (#3536)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-14 13:09:43 +02:00
Teppei Fukuda
c54f1aa8f0 chore(deps): bump golang/x/mod to v0.8.0 (#3606) 2023-02-14 07:02:26 +02:00
dependabot[bot]
625ea58122 chore(deps): bump golang.org/x/crypto from 0.3.0 to 0.5.0 (#3529)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-13 16:15:12 +02:00
dependabot[bot]
623c7f9432 chore(deps): bump helm.sh/helm/v3 from 3.10.3 to 3.11.1 (#3580)
Co-authored-by: DmitriyLewen <dmitriy.lewen@smartforce.io>
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-13 16:14:25 +02:00
DmitriyLewen
d291c34f51 ci: quote pros in c++ for semantic pr (#3605) 2023-02-13 14:05:35 +02:00
DmitriyLewen
6cac6c917f fix(image): check proxy settings from env for remote images (#3604) 2023-02-13 12:54:38 +02:00
DmitriyLewen
12b563b974 BREAKING: use normalized trivy-java-db (#3583)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-10 02:16:37 +02:00
DmitriyLewen
72a14c67af fix(image): add timeout for remote images (#3582)
* add timeout for remote image

* fix linter error
2023-02-09 14:19:17 +02:00
dependabot[bot]
4c01d73fb7 chore(deps): bump golang.org/x/mod from 0.6.0 to 0.7.0 (#3532)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-07 08:38:25 +02:00
dependabot[bot]
10dd5d1a95 chore(deps): bump golang.org/x/text from 0.5.0 to 0.6.0 (#3534)
Co-authored-by: Teppei Fukuda <knqyf263@gmail.com>
2023-02-07 06:51:49 +02:00
simar7
439c541fd3 fix(misconf): handle dot files better (#3550) 2023-02-05 09:10:10 +09:00
Teppei Fukuda
200e04a767 chore: bump Go to 1.19 (#3551) 2023-02-03 15:08:01 +09:00
dependabot[bot]
a533ca87e6 chore(deps): bump alpine from 3.17.0 to 3.17.1 (#3522) 2023-02-03 04:21:25 +02:00
dependabot[bot]
4bccbe6e1c chore(deps): bump docker/build-push-action from 3 to 4 (#3523) 2023-02-03 04:20:52 +02:00
dependabot[bot]
d0562085df chore(deps): bump actions/cache from 3.2.2 to 3.2.4 (#3524) 2023-02-03 04:20:15 +02:00
dependabot[bot]
f5e65749b4 chore(deps): bump golangci/golangci-lint-action from 3.3.0 to 3.4.0 (#3525) 2023-02-03 04:17:39 +02:00
dependabot[bot]
d3da459d45 chore(deps): bump aquaproj/aqua-installer from 1.2.0 to 2.0.2 (#3526) 2023-02-03 04:15:56 +02:00
Teppei Fukuda
7f8868b7d8 fix(sbom): download the Java DB when generating SBOM (#3539) 2023-02-01 17:33:09 +02:00
Teppei Fukuda
364379b7b2 fix: use cgo free sqlite driver (#3521)
* fix: use cgo free sqlite driver

* chore: add CGO_ENABLED=0

* chore(deps): bump go-rpmdb
2023-02-01 17:06:12 +02:00
afdesk
0205475fa9 ci: fix path to dist folder (#3527) 2023-02-01 16:44:01 +02:00
Teppei Fukuda
e9d2af9174 fix(image): close layers (#3517) 2023-02-01 13:36:48 +02:00
Naimuddin Shaik
b169424089 refactor: db client changed (#3515)
changed the constructor to accept interface.
2023-02-01 13:15:36 +02:00
DmitriyLewen
7bf1e192ec feat(java): use trivy-java-db to get GAV (#3484)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-01 11:48:05 +02:00
Batuhan Apaydın
023e45b896 docs: add note about the limitation in Rekor (#3494)
Signed-off-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com>
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-02-01 11:14:47 +02:00
Teppei Fukuda
0fe62a93df docs: aggregate targets (#3503) 2023-02-01 08:48:33 +02:00
Edoardo Vacchi
0373e0822d deps: updates wazero to 1.0.0-pre.8 (#3510)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-02-01 06:48:37 +02:00
DmitriyLewen
a2e21f9b5c docs: add alma 9 and rocky 9 to supported os (#3513) 2023-02-01 06:47:26 +02:00
simar7
7d778b75f7 chore(deps): bump defsec to v0.82.9 (#3512) 2023-02-01 04:14:25 +02:00
Itay Shakury
9e9dbea717 chore: add missing target labels (#3504) 2023-01-31 17:20:56 +02:00
DmitriyLewen
d99a7b82f7 docs: add java vulnerability page (#3429)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-01-31 08:10:24 +02:00
Teppei Fukuda
cb5af0b33b feat(image): add support for Docker CIS Benchmark (#3496)
Co-authored-by: chenk <hen.keinan@gmail.com>
2023-01-31 07:31:59 +02:00
Teppei Fukuda
6eec9ac0a4 feat(image): secret scanning on container image config (#3495) 2023-01-30 16:50:56 +02:00
simar7
1eca973cbf chore(deps): Upgrade defsec to v0.82.8 (#3488)
Signed-off-by: Simar <simar@linux.com>
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-01-30 09:38:17 +02:00
Teppei Fukuda
fb0d8f3f30 feat(image): scan misconfigurations in image config (#3437) 2023-01-30 04:48:29 +02:00
Helge Eichelberg
501d424d1f chore(helm): update Trivy from v0.30.4 to v0.36.1 (#3489)
Signed-off-by: elchenberg <elchenberg@users.noreply.github.com>
2023-01-28 07:12:08 +02:00
chenk
475dc17bc8 feat(k8s): add node info resource (#3482)
Signed-off-by: chenk <hen.keinan@gmail.com>
2023-01-25 22:00:05 +02:00
kunlongli
ed173b8295 perf(secret): optimize secret scanning memory usage (#3453) 2023-01-25 11:45:09 +02:00
Teppei Fukuda
1b368be367 feat: support aliases in CLI flag, env and config (#3481) 2023-01-25 11:33:12 +02:00
chenk
66a83d5cdb fix(k8s): migrate rbac k8s (#3459) 2023-01-25 11:13:41 +02:00
DmitriyLewen
81bee0f11e feat(java): add implementationVendor and specificationVendor fields to detect GroupID from MANIFEST.MF (#3480) 2023-01-24 12:21:19 +02:00
Teppei Fukuda
e1076085d9 refactor: rename security-checks to scanners (#3467) 2023-01-23 16:53:06 +02:00
Teppei Fukuda
aaf845d02e chore: display the troubleshooting URL for the DB denial error (#3474) 2023-01-23 16:12:00 +02:00
Corey Wilson
ed5bb0ba92 docs: yaml tabs to spaces, auto create namespace (#3469) 2023-01-23 10:51:55 +02:00
Anais Urlichs
3158bfe605 docs: adding show-and-tell template to GH discussions (#3391) 2023-01-22 17:34:09 +02:00
Lénaïc Huard
85b6c4aa15 fix: Fix a temporary file leak in case of error (#3465)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-01-22 16:12:56 +02:00
Teppei Fukuda
60bddae64c fix(test): sort cyclonedx components (#3468) 2023-01-22 14:21:20 +02:00
Anais Urlichs
e0bb04c915 docs: fixing spelling mistakes (#3462) 2023-01-22 14:18:15 +02:00
Teppei Fukuda
c25e826bb5 ci: set paths triggering VM tests in PR (#3438) 2023-01-22 11:35:19 +02:00
Raz Cohen
07ddc85a46 docs: typo in --skip-files (#3454) 2023-01-18 14:23:56 +02:00
Srinivas Kandukuri
e88507c999 feat(custom-forward): Extended advisory data (#3444) 2023-01-17 16:06:27 +02:00
Carl Winbäck
e2dfee208f docs: fix spelling error (#3436) 2023-01-16 14:31:43 +00:00
Teppei Fukuda
c575d6f7de refactor(image): extend image config analyzer (#3434) 2023-01-16 13:48:26 +02:00
Lior Vaisman Argon
036d5a8233 fix(nodejs): add ignore protocols to yarn parser (#3433) 2023-01-16 11:27:20 +02:00
DmitriyLewen
e6d7f15762 fix(db): check proxy settings when using insecure flag (#3435) 2023-01-16 10:40:27 +02:00
simar7
a1d4427c8b feat(misconf): Fetch policies from OCI registry (#3015)
Signed-off-by: Simar <simar@linux.com>
2023-01-15 13:37:04 +02:00
DmitriyLewen
682351a131 ci: downgrade Go to 1.18 and use stable and oldstable go versions for unit tests (#3413)
* use stable and oldstable go versions for unit tests

* downgrade Go to 1.18
2023-01-15 12:03:15 +02:00
afdesk
ff0c4516db ci: store URLs to Github Releases in RPM repository (#3414) 2023-01-15 11:59:18 +02:00
DmitriyLewen
ee12442b8d feat(server): add support of skip-db-update flag for hot db update (#3416) 2023-01-15 10:28:50 +02:00
DmitriyLewen
2033e05b6b chore(deps): bump github.com/moby/buildkit from v0.10.6 to v0.11.0 (#3411) 2023-01-12 08:45:07 +02:00
Teppei Fukuda
6bc564e887 fix(image): handle wrong empty layer detection (#3375) 2023-01-11 20:17:12 +02:00
DmitriyLewen
b3b8d4dd6e test: fix integration tests for spdx and cycloneDX (#3412) 2023-01-11 14:02:10 +02:00
Matthieu Maitre
b88bccae6e feat(python): Include Conda packages in SBOMs (#3379)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-01-10 16:11:17 +02:00
DmitriyLewen
fbd8a13d54 feat: add support pubspec.lock files for dart (#3344)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-01-10 13:34:53 +02:00
Kalyana Krishna Varanasi
0f545cfa96 fix(image): parsePlatform is failing with UNAUTHORIZED error (#3326)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2023-01-10 13:26:57 +02:00
DmitriyLewen
76c883dc43 fix(license): change normalize for GPL-3+-WITH-BISON-EXCEPTION (#3405) 2023-01-10 09:24:11 +00:00
Jack Lin
a8b671bc29 feat(server): log errors on server side (#3397) 2023-01-10 10:21:31 +02:00
Teppei Fukuda
a5919ca363 chore(deps): bump defsec to address helm vulnerabilities (#3399) 2023-01-08 15:34:11 +02:00
Itay Shakury
89016da21e docs: rewrite installation docs and general improvements (#3368)
improve installation guide, improve overview pages, rename cli section to docs
2023-01-08 15:16:03 +02:00
Itay Shakury
c3759c6d83 chore: update code owners (#3393) 2023-01-08 15:14:10 +02:00
Itay Shakury
044fb9761e chore: test docs separately from code (#3392) 2023-01-08 11:10:31 +02:00
Teppei Fukuda
ad2e648b33 docs: use the formula maintained by Homebrew (#3389) 2023-01-05 16:25:57 +02:00
Max Usachev
ad25a776cc docs: add Security Management section with SonarQube plugin 2023-01-05 14:59:47 +02:00
321 changed files with 17132 additions and 6574 deletions

6
.github/CODEOWNERS vendored
View File

@@ -2,12 +2,8 @@
* @knqyf263
# Docs
/docs/community/ @knqyf263 @AnaisUrlichs @itaysk
/docs/ecosystem/ @knqyf263 @AnaisUrlichs @itaysk
/docs/getting-started/ @knqyf263 @AnaisUrlichs @itaysk
/docs/tutorials/ @knqyf263 @AnaisUrlichs @itaysk
/docs/** @knqyf263 @AnaisUrlichs @itaysk
/mkdocs.yml @knqyf263 @AnaisUrlichs @itaysk
/docs/index.md @knqyf263 @AnaisUrlichs @itaysk
/README.md @knqyf263 @AnaisUrlichs @itaysk
# Helm chart

View File

@@ -0,0 +1,53 @@
title: "<company name> "
labels: ["adopters"]
body:
- type: textarea
id: links
attributes:
label: "Share Links"
description: "If you would like to share a link to your project or company, please paste it below 🌐"
value: |
...
validations:
required: false
- type: textarea
id: logo
attributes:
label: "Share Logo"
description: "If you have a link to your logo, please provide it in the following text-box 🌐"
value: |
...
validations:
required: false
- type: checkboxes
attributes:
label: Please select all the scan targets that you are using
options:
- label: Container Images
- label: Filesystem
- label: Git Repository
- label: Virtual Machine Images
- label: Kubernetes
- label: AWS
validations:
required: false
- type: checkboxes
attributes:
label: Which scanners are you using on those scan targets?
options:
- label: OS packages and software dependencies in use (SBOM)
- label: Known vulnerabilities (CVEs)
- label: IaC issues and misconfigurations
- label: Sensitive information and secrets
- label: Software licenses
validations:
required: false
- type: textarea
id: info
attributes:
label: "Additional Information"
description: "Please tell us more about your use case of Trivy -- anything that you would like to share 🎉"
value: |
...
validations:
required: false

View File

@@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Restore Trivy binaries from cache
uses: actions/cache@v3.2.2
uses: actions/cache@v3.2.4
with:
path: dist/
key: ${{ runner.os }}-bins-${{github.workflow}}-${{github.sha}}

View File

@@ -24,7 +24,7 @@ jobs:
fetch-depth: 0
- name: Restore Trivy binaries from cache
uses: actions/cache@v3.2.2
uses: actions/cache@v3.2.4
with:
path: dist/
key: ${{ runner.os }}-bins-${{github.workflow}}-${{github.sha}}

View File

@@ -87,7 +87,7 @@ jobs:
## only for canary build
- name: Build and push
if: ${{ inputs.goreleaser_config == 'goreleaser-canary.yml' }}
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
platforms: linux/amd64, linux/arm64
file: ./Dockerfile.canary # path to Dockerfile
@@ -99,7 +99,7 @@ jobs:
public.ecr.aws/aquasecurity/trivy:canary
- name: Cache Trivy binaries
uses: actions/cache@v3.2.2
uses: actions/cache@v3.2.4
with:
path: dist/
# use 'github.sha' to create a unique cache folder for each run.

View File

@@ -69,8 +69,9 @@ jobs:
java
go
c
c++
c\+\+
elixir
dart
os
lang

28
.github/workflows/test-docs.yaml vendored Normal file
View File

@@ -0,0 +1,28 @@
name: Test docs
on:
pull_request:
paths:
- 'docs/**'
- 'mkdocs.yml'
jobs:
build-documents:
name: Documentation Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: true
- uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install dependencies
run: |
pip install -r docs/build/requirements.txt
- name: Configure the git user
run: |
git config user.name "knqyf263"
git config user.email "knqyf263@gmail.com"
- name: Deploy the dev documents
run: mike deploy test

View File

@@ -4,11 +4,16 @@ on:
branches:
- main
paths-ignore:
- '*.md'
- '**.md'
- 'docs/**'
- 'mkdocs.yml'
- 'LICENSE'
pull_request:
paths-ignore:
- '**.md'
- 'docs/**'
- 'mkdocs.yml'
- 'LICENSE'
jobs:
test:
name: Test
@@ -22,7 +27,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
go-version: oldstable
- name: go mod tidy
run: |
@@ -34,7 +39,7 @@ jobs:
if: matrix.operating-system == 'ubuntu-latest'
- name: Lint
uses: golangci/golangci-lint-action@v3.3.0
uses: golangci/golangci-lint-action@v3.4.0
with:
version: v1.49
args: --deadline=30m
@@ -42,7 +47,7 @@ jobs:
if: matrix.operating-system == 'ubuntu-latest'
# Install tools
- uses: aquaproj/aqua-installer@v1.2.0
- uses: aquaproj/aqua-installer@v2.0.2
with:
aqua_version: v1.25.0
@@ -77,7 +82,7 @@ jobs:
go-version-file: go.mod
# Install tools
- uses: aquaproj/aqua-installer@v1.1.2
- uses: aquaproj/aqua-installer@v2.0.2
with:
aqua_version: v1.25.0
@@ -116,24 +121,3 @@ jobs:
version: v1.4.1
args: release --skip-sign --snapshot --rm-dist --skip-publish --timeout 90m
build-documents:
name: Documentation Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: true
- uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install dependencies
run: |
pip install -r docs/build/requirements.txt
- name: Configure the git user
run: |
git config user.name "knqyf263"
git config user.email "knqyf263@gmail.com"
- name: Deploy the dev documents
run: mike deploy test

View File

@@ -9,6 +9,11 @@ on:
- 'pkg/fanal/artifact/vm/**'
- 'integration/vm_test.go'
pull_request:
paths:
- 'pkg/fanal/vm/**'
- 'pkg/fanal/walker/vm.go'
- 'pkg/fanal/artifact/vm/**'
- 'integration/vm_test.go'
jobs:
vm-test:

View File

@@ -21,6 +21,7 @@ linters-settings:
local-prefixes: github.com/aquasecurity
gosec:
excludes:
- G101
- G114
- G204
- G402

View File

@@ -1,4 +1,4 @@
FROM alpine:3.17.0
FROM alpine:3.17.2
RUN apk --no-cache add ca-certificates git
COPY trivy /usr/local/bin/trivy
COPY contrib/*.tpl contrib/

View File

@@ -1,4 +1,4 @@
FROM alpine:3.17.0
FROM alpine:3.17.1
RUN apk --no-cache add ca-certificates git
# binaries were created with GoReleaser

View File

@@ -16,6 +16,8 @@ EXAMPLE_MODULES := $(patsubst %.go,%.wasm,$(EXAMPLE_MODULE_SRCS))
MKDOCS_IMAGE := aquasec/mkdocs-material:dev
MKDOCS_PORT := 8000
export CGO_ENABLED := 0
u := $(if $(update),-u)
# Tools
@@ -130,4 +132,4 @@ mkdocs-serve:
# Generate JSON marshaler/unmarshaler for TinyGo/WebAssembly as TinyGo doesn't support encoding/json.
.PHONY: easyjson
easyjson: $(GOBIN)/easyjson
easyjson pkg/module/serialize/types.go
easyjson pkg/module/serialize/types.go

View File

@@ -31,29 +31,30 @@ Scanners (what Trivy can find there):
- Sensitive information and secrets
- Software licenses
To learn more, go to the [Trivy homepage][homepage] for feature highlights, or to the [Documentation site][docs] for detailed information.
## Quick Start
### Get Trivy
Trivy is available in most common distribution methods. The full list of installation options is available in the [Installation] page, here are a few popular options:
Trivy is available in most common distribution channels. The full list of installation options is available in the [Installation] page. Here are a few popular examples:
- `apt-get install trivy`
- `yum install trivy`
- `brew install aquasecurity/trivy/trivy`
- `brew install trivy`
- `docker run aquasec/trivy`
- Download binary from <https://github.com/aquasecurity/trivy/releases/latest/>
- See [Installation] for more
Trivy is integrated with many popular platforms and applications. The full list of integrations is available in the [Ecosystem] page. Here are a few popular options:
Trivy is integrated with many popular platforms and applications. The complete list of integrations is available in the [Ecosystem] page. Here are a few popular examples:
- [GitHub Actions](https://github.com/aquasecurity/trivy-action)
- [CircleCI](https://circleci.com/developer/orbs/orb/fifteen5/trivy-orb)
- [Kubernetes operator](https://github.com/aquasecurity/trivy-operator)
- [VS Code plugin](https://github.com/aquasecurity/trivy-vscode-extension)
- See [Ecosystem] for more
### General usage
```bash
trivy <target> [--security-checks <scanner1,scanner2>] <subject>
trivy <target> [--scanners <scanner1,scanner2>] <subject>
```
Examples:
@@ -70,7 +71,7 @@ https://user-images.githubusercontent.com/1161307/171013513-95f18734-233d-45d3-a
</details>
```bash
trivy fs --security-checks vuln,secret,config myproject/
trivy fs --scanners vuln,secret,config myproject/
```
<details>
@@ -91,36 +92,6 @@ trivy k8s --report summary cluster
</details>
## Highlights
- Comprehensive vulnerability detection
- OS packages (Alpine Linux, Red Hat Universal Base Image, Red Hat Enterprise Linux, CentOS, AlmaLinux, Rocky Linux, CBL-Mariner, Oracle Linux, Debian, Ubuntu, Amazon Linux, openSUSE Leap, SUSE Enterprise Linux, Photon OS and Distroless)
- **Language-specific packages** (Bundler, Composer, Pipenv, Poetry, npm, yarn, Cargo, NuGet, Maven, and Go)
- High accuracy, especially [Alpine Linux][alpine] and RHEL/CentOS
- Supply chain security (SBOM support)
- Support CycloneDX
- Support SPDX
- Generating and Scanning SBOM
- Leveraging in-toto attestations
- Integrated with [Sigstore]
- Misconfiguration detection (IaC scanning)
- Wide variety of security checks are provided **out of the box**
- Kubernetes, Docker, Terraform, and more
- User-defined policies using [OPA Rego][rego]
- Secret detection
- A wide variety of built-in rules are provided **out of the box**
- User-defined patterns
- Efficient scanning of container images
- Simple
- Available in apt, yum, brew, dockerhub
- **No pre-requisites** such as a database, system libraries, or eny environmental requirements. The binary runs anywhere.
- The first scan will finish within 10 seconds (depending on your network). Consequent scans will finish instantaneously.
- Fits your workflow
- **Great for CI** such as GitHub Actions, Jenkins, GitLab CI, etc.
- Available as extension for IDEs such as vscode, jetbrains, vim
- Available as extension for Docker Desktop, Rancher Desktop
- See [Ecosystem] section in the documentation.
## FAQ
### How to pronounce the name "Trivy"?
@@ -143,6 +114,7 @@ Contact us about any matter by opening a GitHub Discussion [here][discussions]
[docker-pulls]: https://img.shields.io/docker/pulls/aquasec/trivy?logo=docker&label=docker%20pulls%20%2F%20trivy
[license]: https://github.com/aquasecurity/trivy/blob/main/LICENSE
[license-img]: https://img.shields.io/badge/License-Apache%202.0-blue.svg
[homepage]: https://trivy.dev
[docs]: https://aquasecurity.github.io/trivy
[pronunciation]: #how-to-pronounce-the-name-trivy

View File

@@ -1,18 +1,21 @@
#!/bin/bash
TRIVY_VERSION=$(find dist/ -type f -name "*64bit.rpm" -printf "%f\n" | head -n1 | sed -nre 's/^[^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p')
function create_rpm_repo () {
version=$1
rpm_path=rpm/releases/${version}/x86_64
RPM_EL=$(find ../dist/ -type f -name "*64bit.rpm" -printf "%f\n" | head -n1 | sed -e "s/_/-/g" -e "s/-Linux/.el$version/" -e "s/-64bit/.x86_64/")
echo $RPM_EL
mkdir -p $rpm_path
cp ../dist/*64bit.rpm ${rpm_path}/${RPM_EL}
cp ../dist/*64bit.rpm ${rpm_path}/
createrepo_c --update $rpm_path
createrepo_c -u https://github.com/aquasecurity/trivy/releases/download/ --location-prefix="v"$TRIVY_VERSION --update $rpm_path
rm ${rpm_path}/*64bit.rpm
}
echo "Create RPM releases for Trivy v$TRIVY_VERSION"
cd trivy-repo
VERSIONS=(5 6 7 8 9)
@@ -22,6 +25,5 @@ for version in ${VERSIONS[@]}; do
done
git add .
git commit -m "Update rpm packages"
git commit -m "Update rpm packages for Trivy v$TRIVY_VERSION"
git push origin main

View File

@@ -9,6 +9,8 @@ import (
"github.com/aquasecurity/trivy/pkg/commands"
"github.com/aquasecurity/trivy/pkg/log"
"github.com/aquasecurity/trivy/pkg/plugin"
_ "modernc.org/sqlite" // sqlite driver for RPM DB and Java DB
)
var (

View File

@@ -81,6 +81,7 @@ language:
- java
- go
- elixir
- dart
vuln:

View File

@@ -5,6 +5,8 @@ Trivy can be used in air-gapped environments. Note that an allowlist is [here][a
## Air-Gapped Environment for vulnerabilities
### Download the vulnerability database
At first, you need to download the vulnerability database for use in air-gapped environments.
=== "Trivy"
```
@@ -15,7 +17,6 @@ Trivy can be used in air-gapped environments. Note that an allowlist is [here][a
```
=== "oras >= v0.13.0"
At first, you need to download the vulnerability database for use in air-gapped environments.
Please follow [oras installation instruction][oras].
Download `db.tar.gz`:
@@ -25,7 +26,6 @@ Trivy can be used in air-gapped environments. Note that an allowlist is [here][a
```
=== "oras < v0.13.0"
At first, you need to download the vulnerability database for use in air-gapped environments.
Please follow [oras installation instruction][oras].
Download `db.tar.gz`:
@@ -34,41 +34,95 @@ Trivy can be used in air-gapped environments. Note that an allowlist is [here][a
$ oras pull -a ghcr.io/aquasecurity/trivy-db:2
```
### Transfer the DB file into the air-gapped environment
### Download the Java index database[^1]
Java users also need to download the Java index database for use in air-gapped environments.
!!! note
You container image may contain JAR files even though you don't use Java directly.
In that case, you also need to download the Java index database.
=== "Trivy"
```
TRIVY_TEMP_DIR=$(mktemp -d)
trivy --cache-dir $TRIVY_TEMP_DIR image --download-java-db-only
tar -cf ./javadb.tar.gz -C $TRIVY_TEMP_DIR/java-db metadata.json trivy-java.db
rm -rf $TRIVY_TEMP_DIR
```
=== "oras >= v0.13.0"
Please follow [oras installation instruction][oras].
Download `javadb.tar.gz`:
```
$ oras pull ghcr.io/aquasecurity/trivy-java-db:1
```
=== "oras < v0.13.0"
Please follow [oras installation instruction][oras].
Download `javadb.tar.gz`:
```
$ oras pull -a ghcr.io/aquasecurity/trivy-java-db:1
```
### Transfer the DB files into the air-gapped environment
The way of transfer depends on the environment.
```
$ rsync -av -e ssh /path/to/db.tar.gz [user]@[host]:dst
```
=== "Vulnerability db"
```
$ rsync -av -e ssh /path/to/db.tar.gz [user]@[host]:dst
```
### Put the DB file in Trivy's cache directory
You have to know where to put the DB file. The following command shows the default cache directory.
=== "Java index db[^1]"
```
$ rsync -av -e ssh /path/to/javadb.tar.gz [user]@[host]:dst
```
### Put the DB files in Trivy's cache directory
You have to know where to put the DB files. The following command shows the default cache directory.
```
$ ssh user@host
$ trivy -h | grep cache
--cache-dir value cache directory (default: "/home/myuser/.cache/trivy") [$TRIVY_CACHE_DIR]
```
=== "Vulnerability db"
Put the DB file in the cache directory + `/db`.
```
$ mkdir -p /home/myuser/.cache/trivy/db
$ cd /home/myuser/.cache/trivy/db
$ tar xvf /path/to/db.tar.gz -C /home/myuser/.cache/trivy/db
x trivy.db
x metadata.json
$ rm /path/to/db.tar.gz
```
Put the DB file in the cache directory + `/db`.
=== "Java index db[^1]"
Put the DB file in the cache directory + `/java-db`.
```
$ mkdir -p /home/myuser/.cache/trivy/java-db
$ cd /home/myuser/.cache/trivy/java-db
$ tar xvf /path/to/javadb.tar.gz -C /home/myuser/.cache/trivy/java-db
x trivy-java.db
x metadata.json
$ rm /path/to/javadb.tar.gz
```
In an air-gapped environment it is your responsibility to update the Trivy databases on a regular basis, so that the scanner can detect recently-identified vulnerabilities.
### Run Trivy with the specific flags.
In an air-gapped environment, you have to specify `--skip-db-update` and `--skip-java-db-update`[^1] so that Trivy doesn't attempt to download the latest database files.
In addition, if you want to scan `pom.xml` dependencies, you need to specify `--offline-scan` since Trivy tries to issue API requests for scanning Java applications by default.
```
$ mkdir -p /home/myuser/.cache/trivy/db
$ cd /home/myuser/.cache/trivy/db
$ tar xvf /path/to/db.tar.gz -C /home/myuser/.cache/trivy/db
x trivy.db
x metadata.json
$ rm /path/to/db.tar.gz
```
In an air-gapped environment it is your responsibility to update the Trivy database on a regular basis, so that the scanner can detect recently-identified vulnerabilities.
### Run Trivy with `--skip-update` and `--offline-scan` option
In an air-gapped environment, specify `--skip-update` so that Trivy doesn't attempt to download the latest database file.
In addition, if you want to scan Java dependencies such as JAR and pom.xml, you need to specify `--offline-scan` since Trivy tries to issue API requests for scanning Java applications by default.
```
$ trivy image --skip-update --offline-scan alpine:3.12
$ trivy image --skip-db-update --skip-java-db-update --offline-scan alpine:3.12
```
## Air-Gapped Environment for misconfigurations
@@ -84,3 +138,5 @@ $ trivy conf --skip-policy-update /path/to/conf
[allowlist]: ../references/troubleshooting.md
[oras]: https://oras.land/cli/
[^1]: This is only required to scan `jar` files. More information about `Java index db` [here](../vulnerability/languages/java.md)

View File

@@ -1,29 +0,0 @@
# containerd
!!! warning "EXPERIMENTAL"
This feature might change without preserving backwards compatibility.
Scan your image in [containerd][containerd] running locally.
```bash
$ nerdctl images
REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE
aquasec/nginx latest 2bcabc23b454 3 hours ago linux/amd64 149.1 MiB 54.1 MiB
$ trivy image aquasec/nginx
```
If your containerd socket is not the default path (`//run/containerd/containerd.sock`), you can override it via `CONTAINERD_ADDRESS`.
```bash
$ export CONTAINERD_ADDRESS=/run/k3s/containerd/containerd.sock
$ trivy image aquasec/nginx
```
If your scan targets are images in a namespace other than containerd's default namespace (`default`), you can override it via `CONTAINERD_NAMESPACE`.
```bash
$ export CONTAINERD_NAMESPACE=k8s.io
$ trivy image aquasec/nginx
```
[containerd]: https://containerd.io/

View File

@@ -1,17 +0,0 @@
# OCI Image Layout
An image directory compliant with [Open Container Image Layout Specification](https://github.com/opencontainers/image-spec/blob/master/spec.md).
Buildah:
```
$ buildah push docker.io/library/alpine:3.11 oci:/path/to/alpine
$ trivy image --input /path/to/alpine
```
Skopeo:
```
$ skopeo copy docker-daemon:alpine:3.11 oci:/path/to/alpine
$ trivy image --input /path/to/alpine
```

View File

@@ -1,28 +0,0 @@
# Podman
!!! warning "EXPERIMENTAL"
This feature might change without preserving backwards compatibility.
Scan your image in Podman (>=2.0) running locally. The remote Podman is not supported.
Before performing Trivy commands, you must enable the podman.sock systemd service on your machine.
For more details, see [here][sock].
```bash
$ systemctl --user enable --now podman.socket
```
Then, you can scan your image in Podman.
```bash
$ cat Dockerfile
FROM alpine:3.12
RUN apk add --no-cache bash
$ podman build -t test .
$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/test latest efc372d4e0de About a minute ago 7.94 MB
$ trivy image test
```
[sock]: https://github.com/containers/podman/blob/master/docs/tutorials/remote_client.md#enable-the-podman-service-on-the-server-machine

View File

@@ -2,3 +2,34 @@ Trivy uses AWS SDK. You don't need to install `aws` CLI tool.
You can use [AWS CLI's ENV Vars][env-var].
[env-var]: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html
### AWS private registry permissions
You may need to grant permissions to allow Trivy to pull images from private ECR.
It depends on how you want to provide AWS Role to trivy.
- [IAM Role Service account](https://github.com/aws/amazon-eks-pod-identity-webhook)
- [Kube2iam](https://github.com/jtblin/kube2iam) or [Kiam](https://github.com/uswitch/kiam)
#### IAM Role Service account
Add the AWS role in trivy's service account annotations:
```yaml
trivy:
serviceAccount:
annotations: {}
# eks.amazonaws.com/role-arn: arn:aws:iam::ACCOUNT_ID:role/IAM_ROLE_NAME
```
#### Kube2iam or Kiam
Add the AWS role to pod's annotations:
```yaml
podAnnotations: {}
## kube2iam/kiam annotation
# iam.amazonaws.com/role: arn:aws:iam::ACCOUNT_ID:role/IAM_ROLE_NAME
```

View File

@@ -21,7 +21,7 @@ You need to pass `--sbom-sources rekor` so that Trivy will look for SBOM attesta
$ trivy image --sbom-sources rekor otms61/alpine:3.7.3 [~/src/github.com/aquasecurity/trivy]
2022-09-16T17:37:13.258+0900 INFO Vulnerability scanning is enabled
2022-09-16T17:37:13.258+0900 INFO Secret scanning is enabled
2022-09-16T17:37:13.258+0900 INFO If your scanning is slow, please try '--security-checks vuln' to disable secret scanning
2022-09-16T17:37:13.258+0900 INFO If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2022-09-16T17:37:13.258+0900 INFO Please see also https://aquasecurity.github.io/trivy/dev/docs/secret/scanning/#recommendation for faster secret detection
2022-09-16T17:37:14.827+0900 INFO Detected SBOM format: cyclonedx-json
2022-09-16T17:37:14.901+0900 INFO Found SBOM (cyclonedx) attestation in Rekor
@@ -80,6 +80,11 @@ $ trivy plugin install github.com/aquasecurity/trivy-plugin-attest
$ trivy attest --predicate ./bat.cdx --type cyclonedx ./bat-v0.20.0-x86_64-apple-darwin/bat
```
!!! note
The public instance of the Rekor maintained by the Sigstore team limits the attestation size.
If you are using the public instance, please make sure that your SBOM is small enough.
To get more detail, please refer to the Rekor project's [documentation](https://github.com/sigstore/rekor#public-instance).
### Scan a non-packaged binary
Trivy calculates the digest of the `bat` binary and searches for the SBOM attestation by the digest in Rekor.
If it is found, Trivy uses that for vulnerability scanning.
@@ -105,7 +110,7 @@ Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0)
Also, it is applied to non-packaged binaries even in container images.
```bash
$ trivy image --sbom-sources rekor --security-checks vuln alpine-with-bat
$ trivy image --sbom-sources rekor --scanners vuln alpine-with-bat
2022-10-25T13:40:14.920+0300 INFO Vulnerability scanning is enabled
2022-10-25T13:40:18.047+0300 INFO Found SBOM attestation in Rekor: bat
2022-10-25T13:40:18.186+0300 INFO Detected OS: alpine

View File

@@ -1,39 +0,0 @@
# AWS Compliance
!!! warning "EXPERIMENTAL"
This feature might change without preserving backwards compatibility.
This page describes AWS specific compliance reports. For an overview of Trivy's Compliance feature, including working with custom compliance, check out the [Compliance documentation](../../compliance/compliance.md).
## Built in reports
the following reports are available out of the box:
| Compliance | Name for command | More info
--- | --- | ---
AWS CIS Foundations Benchmark v1.2 | `aws-cis-1.2` | [link](https://d0.awsstatic.com/whitepapers/compliance/AWS_CIS_Foundations_Benchmark.pdf)
AWS CIS Foundations Benchmark v1.4 | `aws-cis-1.4` | [link](https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-cis-controls-1.4.0.html)
## Examples
Scan a cloud account and generate a compliance summary report:
```
$ trivy aws --compliance=<compliance_id> --report=summary
```
***Note*** : The `Issues` column represent the total number of failed checks for this control.
Get all of the detailed output for checks:
```
$ trivy aws --compliance=<compliance_id> --report all
```
Report result in JSON format:
```
$ trivy aws --compliance=<compliance_id> --report all --format json
```

View File

@@ -1,66 +0,0 @@
# Amazon Web Services
!!! warning "EXPERIMENTAL"
This feature might change without preserving backwards compatibility.
The Trivy AWS CLI allows you to scan your AWS account for misconfigurations. You can either run the CLI locally or integrate it into your CI/CD pipeline.
Whilst you can already scan the infrastructure-as-code that defines your AWS resources with `trivy config`, you can now scan your live AWS account(s) directly too.
The included checks cover all of the aspects of the [AWS CIS 1.2](https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-standards-cis.html) automated benchmarks.
Trivy uses the same [authentication methods](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) as the AWS CLI to configure and authenticate your access to the AWS platform.
You will need permissions configured to read all AWS resources - we recommend using a group/role with the `ReadOnlyAccess` policy attached.
Once you've scanned your account, you can run additional commands to filter the results without having to run the entire scan again - infrastructure information is cached locally per AWS account/region.
## CLI Commands
Scan a full AWS account (all supported services):
```shell
trivy aws --region us-east-1
```
You can allow Trivy to determine the AWS region etc. by using the standard AWS configuration files and environment variables. The `--region` flag overrides these.
![AWS Summary Report](../../../imgs/trivy-aws.png)
The summary view is the default when scanning multiple services.
Scan a specific service:
```shell
trivy aws --service s3
```
Scan multiple services:
```shell
# --service s3,ec2 works too
trivy aws --service s3 --service ec2
```
Show results for a specific AWS resource:
```shell
trivy aws --service s3 --arn arn:aws:s3:::example-bucket
```
All ARNs with detected issues will be displayed when showing results for their associated service.
## Compliance Spec
Trivy can also run specific checks by spec by specifying the compliance flag:
```shell
trivy aws --compliance=awscis1.2
```
Will only target the checks defined under the AWS CIS 1.2 spec. Currently, we support AWS CIS 1.2 and 1.4 specs. More details [here](compliance.md).
## Cached Results
By default, Trivy will cache a representation of each AWS service for 24 hours. This means you can filter and view results for a service without having to wait for the entire scan to run again. If you want to force the cache to be refreshed with the latest data, you can use `--update-cache`. Or if you'd like to use cached data for a different timeframe, you can specify `--max-cache-age` (e.g. `--max-cache-age 2h`.). Regardless of whether the cache is used or not, rules will be evaluated again with each run of `trivy aws`.
## Custom Policies
You can write custom policies for Trivy to evaluate against your AWS account. These policies are written in [Rego](https://www.openpolicyagent.org/docs/latest/policy-language/), the same language used by [Open Policy Agent](https://www.openpolicyagent.org/). See the [Custom Policies](../../misconfiguration/custom/index.md) page for more information.

View File

@@ -9,21 +9,23 @@ Trivys compliance flag lets you curate a specific set of checks into a report
Compliance report is currently supported in the following targets (trivy sub-commands):
- `trivy image`
- `trivy aws`
- `trivy k8s`
Add the `--compliance` flag to the command line, and set it's value to desired report. For example: `trivy k8s cluster --compliance k8s-nsa` (see below for built-in and custom reports)
Add the `--compliance` flag to the command line, and set it's value to desired report.
For example: `trivy k8s cluster --compliance k8s-nsa` (see below for built-in and custom reports)
### Options
The following flags are compatible with `--compliance` flag and allows customizing it's output:
flag | effect
--- | ---
`--report summary` | shows a summary of the results. for every control shows the number of failed checks.
`--report all` | shows fully detailed results. for every control shows where it failed and why.
`--format table` | shows results in textual table format (good for human readability).
`--format json` | shows results in json format (good for machine readability).
| flag | effect |
|--------------------|--------------------------------------------------------------------------------------|
| `--report summary` | shows a summary of the results. for every control shows the number of failed checks. |
| `--report all` | shows fully detailed results. for every control shows where it failed and why. |
| `--format table` | shows results in textual table format (good for human readability). |
| `--format json` | shows results in json format (good for machine readability). |
## Built-in compliance
@@ -32,8 +34,9 @@ to specify a built-in compliance report, select it by ID like `trivy --complianc
For the list of built-in compliance reports, please see the relevant section:
- [Kubernetes compliance](../kubernetes/cli/compliance.md)
- [AWS compliance](../cloud/aws/compliance.md)
- [Docker compliance](../target/container_image.md#compliance)
- [Kubernetes compliance](../target/kubernetes.md#compliance)
- [AWS compliance](../target/aws.md#compliance)
## Custom compliance

View File

@@ -1,72 +1,5 @@
# Docs
This documentation details how to use Trivy to access the features listed below.
In this section you can find the complete reference documentation for all of the different features and settings that Trivy has to offer.
## Features
- Comprehensive vulnerability detection
- [OS packages][os] (Alpine, Wolfi, Red Hat Universal Base Image, Red Hat Enterprise Linux, CentOS, AlmaLinux, Rocky Linux, CBL-Mariner, Oracle Linux, Debian, Ubuntu, Amazon Linux, openSUSE Leap, SUSE Enterprise Linux, Photon OS and Distroless)
- [**Language-specific packages**][lang] (Bundler, Composer, Pipenv, Poetry, npm, yarn, pnpm, Cargo, NuGet, Maven, and Go)
- Detect IaC misconfigurations
- A wide variety of [built-in policies][builtin] are provided **out of the box**:
- Kubernetes
- Docker
- Terraform
- more coming soon
- Support custom policies
- Simple
- Specify only an image name, a directory containing IaC configs, or an artifact name
- See [Quick Start][quickstart]
- Fast
- The first scan will finish within 10 seconds (depending on your network). Consequent scans will finish in single seconds.
- Unlike other scanners that take long to fetch vulnerability information (~10 minutes) on the first run, and encourage you to maintain a durable vulnerability database, Trivy is stateless and requires no maintenance or preparation.
- Easy installation
- `apt-get install`, `yum install` and `brew install` is possible (See [Installation][installation])
- **No pre-requisites** such as installation of DB, libraries, etc.
- High accuracy
- **Especially Alpine Linux and RHEL/CentOS**
- Other OSes are also high
- DevSecOps
- **Suitable for CI** such as Travis CI, CircleCI, Jenkins, GitLab CI, etc.
- See [CI Example][integrations]
- Support multiple formats
- container image
- A local image in Docker Engine which is running as a daemon
- A local image in [Podman][podman] (>=2.0) which is exposing a socket
- A remote image in Docker Registry such as Docker Hub, ECR, GCR and ACR
- A tar archive stored in the `docker save` / `podman save` formatted file
- An image directory compliant with [OCI Image Format][oci]
- local filesystem and rootfs
- remote git repository
- [SBOM][sbom] (Software Bill of Materials) support
- CycloneDX
- SPDX
- GitHub Dependency Snapshots
Please see [LICENSE][license] for Trivy licensing information.
[installation]: ../getting-started/installation.md
[vuln]: ../docs/vulnerability/scanning/index.md
[misconf]: ../docs/misconfiguration/scanning.md
[kubernetesoperator]: ../docs/kubernetes/operator/index.md
[container]: ../docs/vulnerability/scanning/image.md
[rootfs]: ../docs/vulnerability/scanning/rootfs.md
[filesystem]: ../docs/vulnerability/scanning/filesystem.md
[repo]: ../docs/vulnerability/scanning/git-repository.md
[kubernetes]: ../docs/kubernetes/cli/scanning.md
[standalone]: ../docs/references/modes/standalone.md
[client-server]: ../docs/references/modes/client-server.md
[integrations]: ../tutorials/integrations/index.md
[os]: ../docs/vulnerability/detection/os.md
[lang]: ../docs/vulnerability/detection/language.md
[builtin]: ../docs/misconfiguration/policy/builtin.md
[quickstart]: ../index.md
[podman]: ../docs/advanced/container/podman.md
[sbom]: ../docs/sbom/index.md
[oci]: https://github.com/opencontainers/image-spec
[license]: https://github.com/aquasecurity/trivy/blob/main/LICENSE
👈 Please use the side-navigation on the left in order to browse the different topics.

View File

@@ -1,42 +0,0 @@
# Kubernetes Compliance
!!! warning "EXPERIMENTAL"
This feature might change without preserving backwards compatibility.
This page describes Kubernetes specific compliance reports. For an overview of Trivy's Compliance feature, including working with custom compliance, check out the [Compliance documentation](../../compliance/compliance.md).
## Built in reports
The following reports are available out of the box:
| Compliance | Name for command | More info
--- | --- | ---
NSA, CISA Kubernetes Hardening Guidance v1.2 | `k8s-nsa` | [Link](https://media.defense.gov/2022/Aug/29/2003066362/-1/-1/0/CTR_KUBERNETES_HARDENING_GUIDANCE_1.2_20220829.PDF)
CIS Benchmark for Kubernetes v1.23 | `k8s-cis` | [Link](https://www.cisecurity.org/benchmark/kubernetes)
## Examples
Scan a full cluster and generate a compliance summary report:
```
$ trivy k8s cluster --compliance=<compliance_id> --report summary
```
***Note*** : The `Issues` column represent the total number of failed checks for this control.
Get all of the detailed output for checks:
```
trivy k8s cluster --compliance=<compliance_id> --report all
```
Report result in JSON format:
```
trivy k8s cluster --compliance=<compliance_id> --report summary --format json
```
```
trivy k8s cluster --compliance=<compliance_id> --report all --format json
```

View File

@@ -1,14 +0,0 @@
# Trivy Operator
Trivy has a native [Kubernetes Operator][operator] which continuously scans your Kubernetes cluster for security issues, and generates security reports as Kubernetes [Custom Resources][crd]. It does it by watching Kubernetes for state changes and automatically triggering scans in response to changes, for example initiating a vulnerability scan when a new Pod is created.
> Kubernetes-native security toolkit. ([Documentation][trivy-operator]).
<figure>
<figcaption>Workload reconcilers discover K8s controllers, manage scan jobs, and create VulnerabilityReport and ConfigAuditReport objects.</figcaption>
</figure>
[operator]: https://kubernetes.io/docs/concepts/extend-kubernetes/operator/
[crd]: https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/
[trivy-operator]: https://aquasecurity.github.io/trivy-operator/latest

View File

@@ -25,7 +25,7 @@ In addition to package licenses, Trivy scans source code files, Markdown documen
Currently, the standard license scanning doesn't support filesystem and repository scanning.
| License scnanning | Image | Rootfs | Filesystem | Repository |
| License scanning | Image | Rootfs | Filesystem | Repository |
|:---------------------:|:-----:|:---------:|:----------:|:----------:|
| Standard | ✅ | ✅ | - | - |
| Full (--license-full) | ✅ | ✅ | ✅ | ✅ |
@@ -47,10 +47,10 @@ License checking classifies the identified licenses and map the classification t
This section shows how to scan license in container image and filesystem.
### Standard scanning
Specify an image name with `--security-checks license`.
Specify an image name with `--scanners license`.
``` shell
$ trivy image --security-checks license --severity UNKNOWN,HIGH,CRITICAL alpine:3.15
$ trivy image --scanners license --severity UNKNOWN,HIGH,CRITICAL alpine:3.15
2022-07-13T17:28:39.526+0300 INFO License scanning is enabled
OS Packages (license)
@@ -78,7 +78,7 @@ Total: 6 (UNKNOWN: 0, HIGH: 6, CRITICAL: 0)
Specify `--license-full`
``` shell
$ trivy image --security-checks license --severity UNKNOWN,HIGH,CRITICAL --license-full grafana/grafana
$ trivy image --scanners license --severity UNKNOWN,HIGH,CRITICAL --license-full grafana/grafana
2022-07-13T17:48:40.905+0300 INFO Full license scanning is enabled
OS Packages (license)
@@ -141,7 +141,7 @@ Trivy has number of configuration flags for use with license scanning;
Trivy license scanning can ignore licenses that are identified to explicitly remove them from the results using the `--ignored-licenses` flag;
```shell
$ trivy image --security-checks license --ignored-licenses MPL-2.0,MIT --severity LOW grafana/grafana:latest
$ trivy image --scanners license --ignored-licenses MPL-2.0,MIT --severity LOW grafana/grafana:latest
2022-07-13T18:15:28.605Z INFO License scanning is enabled
OS Packages (license)

View File

@@ -40,7 +40,7 @@ A single package must contain only one policy.
# title: Deployment not allowed
# description: Deployments are not allowed because of some reasons.
# schemas:
# - input: schema.input
# - input: schema["kubernetes"]
# custom:
# id: ID001
# severity: LOW
@@ -124,16 +124,16 @@ All fields are optional. The `schemas` field should be used to enable policy val
schema that will be used is based on the input document type. It is recommended to use this to ensure your policies are
correct and do not reference incorrect properties/values.
| Field name | Allowed values | Default value | In table | In JSON |
|----------------------------|------------------------------------------|:----------------------------:|:----------------:|:----------------:|
| title | Any characters | N/A | :material-check: | :material-check: |
| description | Any characters | | :material-close: | :material-check: |
| schemas.input | `schema.input` | (applied to all input types) | :material-close: | :material-close: |
| custom.id | Any characters | N/A | :material-check: | :material-check: |
| custom.severity | `LOW`, `MEDIUM`, `HIGH`, `CRITICAL` | UNKNOWN | :material-check: | :material-check: |
| custom.recommended_actions | Any characters | | :material-close: | :material-check: |
| custom.input.selector.type | Any item(s) in [this list][source-types] | | :material-close: | :material-check: |
| url | Any characters | | :material-close: | :material-check: |
| Field name | Allowed values | Default value | In table | In JSON |
|----------------------------|-------------------------------------------------------------------|:----------------------------:|:----------------:|:----------------:|
| title | Any characters | N/A | :material-check: | :material-check: |
| description | Any characters | | :material-close: | :material-check: |
| schemas.input | `schema["kubernetes"]`, `schema["dockerfile"]`, `schema["cloud"]` | (applied to all input types) | :material-close: | :material-close: |
| custom.id | Any characters | N/A | :material-check: | :material-check: |
| custom.severity | `LOW`, `MEDIUM`, `HIGH`, `CRITICAL` | UNKNOWN | :material-check: | :material-check: |
| custom.recommended_actions | Any characters | | :material-close: | :material-check: |
| custom.input.selector.type | Any item(s) in [this list][source-types] | | :material-close: | :material-check: |
| url | Any characters | | :material-close: | :material-check: |
Some fields are displayed in scan results.
@@ -196,13 +196,7 @@ You can specify input format via the `custom.input` annotation.
`type` accepts `kubernetes`, `dockerfile`, `cloudformation`, `terraform`, `terraformplan`, `json`, or `yaml`.
### Schemas
You can explore the format of input documents by browsing the schema for the relevant input type:
- [Cloud](https://github.com/aquasecurity/defsec/blob/master/pkg/rego/schemas/cloud.json)
- [Dockerfile](https://github.com/aquasecurity/defsec/blob/master/pkg/rego/schemas/dockerfile.json)
- [Kubernetes](https://github.com/aquasecurity/defsec/blob/master/pkg/rego/schemas/kubernetes.json)
- [RBAC](https://github.com/aquasecurity/defsec/blob/master/pkg/rego/schemas/rbac.json)
See [here](./schema.md) for the detail.
[rego]: https://www.openpolicyagent.org/docs/latest/policy-language/
[package]: https://www.openpolicyagent.org/docs/latest/policy-language/#packages

View File

@@ -0,0 +1,93 @@
# Input Schema
## Overview
Policies can be defined with custom schemas that allow inputs to be verified against them. Adding a policy schema
enables Trivy to show more detailed error messages when an invalid input is encountered.
In Trivy we have been able to define a schema for a [Dockerfile](https://github.com/aquasecurity/defsec/blob/master/pkg/rego/schemas/dockerfile.json).
Without input schemas, a policy would be as follows:
!!! example
```
# METADATA
package mypackage
deny {
input.evil == "foo bar"
}
```
If this policy is run against offending Dockerfile(s), there will not be any issues as the policy will fail to evaluate.
Although the policy's failure to evaluate is legitimate, this should not result in a positive result for the scan.
For instance if we have a policy that checks for misconfigurations in a `Dockerfile`, we could define the
schema as such
!!! example
```
# METADATA
# schemas:
# - input: schema["dockerfile"]
package mypackage
deny {
input.evil == "foo bar"
}
```
Here `input: schema["dockerfile"]` points to a schema that expects a valid `Dockerfile` as input. An example of this
can be found [here](https://github.com/aquasecurity/defsec/blob/master/pkg/rego/schemas/dockerfile.json)
Now if this policy is evaluated against, a more descriptive error will be available to help fix the problem.
```bash
1 error occurred: testpolicy.rego:8: rego_type_error: undefined ref: input.evil
input.evil
^
have: "evil"
want (one of): ["Stages"]
```
Currently, out of the box the following schemas are supported natively:
1. [Docker](https://github.com/aquasecurity/defsec/blob/master/pkg/rego/schemas/dockerfile.json)
2. [Kubernetes](https://github.com/aquasecurity/defsec/blob/master/pkg/rego/schemas/kubernetes.json)
3. [Cloud](https://github.com/aquasecurity/defsec/blob/master/pkg/rego/schemas/cloud.json)
## Custom Policies with Custom Schemas
You can also bring a custom policy that defines one or more custom schema.
!!! example
```
# METADATA
# schemas:
# - input: schema["fooschema"]
# - input: schema["barschema"]
package mypackage
deny {
input.evil == "foo bar"
}
```
The policies can be placed in a structure as follows
!!! example
```
/Users/user/my-custom-policies
├── my_policy.rego
└── schemas
└── fooschema.json
└── barschema.json
```
To use such a policy with Trivy, use the `--config-policy` flag that points to the directory where the schemas and policies
are contained.
```bash
$ trivy --config-policy=/Users/user/my-custom-policies <path/to/iac>
```
For more details on how to define schemas within Rego policies, please see the [OPA guide](https://www.openpolicyagent.org/docs/latest/schemas/#schema-annotations) that describes it in more detail.

View File

@@ -19,10 +19,18 @@ For suggestions or issues regarding policy content, please open an issue under t
Helm Chart scanning will resolve the chart to Kubernetes manifests then run the [kubernetes][kubernetes] checks.
Ansible scanning is coming soon.
## Policy Distribution
defsec policies are distributed as an OPA bundle on [GitHub Container Registry][ghcr] (GHCR).
When misconfiguration detection is enabled, Trivy pulls the OPA bundle from GHCR as an OCI artifact and stores it in the cache.
Those policies are then loaded into Trivy OPA engine and used for detecting misconfigurations.
If Trivy is unable to pull down newer policies, it will use the embedded set of policies as a fallback. This is also the case in air-gap environments where `--skip-policy-update` might be passed.
[rego]: https://www.openpolicyagent.org/docs/latest/policy-language
## Update Interval
Trivy checks for updates to OPA bundle on GHCR every 24 hours and pulls it if there are any updates.
[rego]: https://www.openpolicyagent.org/docs/latest/policy-language/
[defsec]: https://github.com/aquasecurity/defsec
[kubernetes]: https://github.com/aquasecurity/defsec/tree/master/internal/rules/policies/kubernetes
[kubernetes]: https://github.com/aquasecurity/defsec/tree/master/internal/rules/kubernetes
[kubernetes]: https://github.com/aquasecurity/defsec/tree/master/internal/rules/rbac
[docker]: https://github.com/aquasecurity/defsec/tree/master/internal/rules/policies/docker
[rbac]: https://github.com/aquasecurity/defsec/tree/master/internal/rules/policies/rbac
[ghcr]: https://github.com/aquasecurity/defsec/pkgs/container/defsec

View File

@@ -37,28 +37,28 @@ $ trivy config [YOUR_IaC_DIRECTORY]
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
```
You can also enable misconfiguration detection in container image, filesystem and git repository scanning via `--security-checks config`.
You can also enable misconfiguration detection in container image, filesystem and git repository scanning via `--scanners config`.
```bash
$ trivy image --security-checks config IMAGE_NAME
$ trivy image --scanners config IMAGE_NAME
```
```bash
$ trivy fs --security-checks config /path/to/dir
$ trivy fs --scanners config /path/to/dir
```
!!! note
Misconfiguration detection is not enabled by default in `image`, `fs` and `repo` subcommands.
Unlike the `config` subcommand, `image`, `fs` and `repo` subcommands can also scan for vulnerabilities and secrets at the same time.
You can specify `--security-checks vuln,config,secret` to enable vulnerability and secret detection as well as misconfiguration detection.
You can specify `--scanners vuln,config,secret` to enable vulnerability and secret detection as well as misconfiguration detection.
!!! example
``` bash
$ ls myapp/
Dockerfile Pipfile.lock
$ trivy fs --security-checks vuln,config,secret --severity HIGH,CRITICAL myapp/
$ trivy fs --scanners vuln,config,secret --severity HIGH,CRITICAL myapp/
2022-05-16T13:42:21.440+0100 INFO Number of language-specific files: 1
2022-05-16T13:42:21.440+0100 INFO Detecting pipenv vulnerabilities...
2022-05-16T13:42:21.440+0100 INFO Detected config files: 1

View File

@@ -9,13 +9,14 @@ Aliases:
Scan Flags
--offline-scan do not issue API requests to identify dependencies
--security-checks string comma-separated list of what security issues to detect (vuln,config,secret) (default "vuln,secret")
--scanners string comma-separated list of what security issues to detect (vuln,config,secret) (default "vuln,secret")
--skip-dirs strings specify the directories where the traversal is skipped
--skip-files strings specify the file paths to skip traversal
Report Flags
--dependency-tree show dependency origin tree (EXPERIMENTAL)
--exit-code int specify exit code when any security issues are found
--exit-on-eol int exit with the specified code when the os of image ends of service/life
-f, --format string format (table, json, sarif, template, cyclonedx, spdx, spdx-json, github, cosign-vuln) (default "table")
--ignore-policy string specify the Rego file path to evaluate each vulnerability
--ignorefile string specify .trivyignore file (default ".trivyignore")
@@ -36,9 +37,12 @@ Cache Flags
DB Flags
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db")
--download-db-only download/update vulnerability database but don't run a scan
--download-java-db-only download/update java indexes database but don't run a scan
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db")
--no-progress suppress progress bar
--reset remove all caches and database
--skip-db-update skip updating vulnerability database
--skip-java-db-update skip updating java indexes database
Vulnerability Flags
--ignore-unfixed display only fixed vulnerabilities
@@ -47,8 +51,8 @@ Vulnerability Flags
Misconfiguration Flags
--config-data strings specify paths from which data for the Rego policies will be recursively loaded
--config-policy strings specify paths to the Rego policy files directory, applying config files
--file-patterns strings specify config file patterns, available with '--security-checks config'
--include-non-failures include successes and exceptions, available with '--security-checks config'
--file-patterns strings specify config file patterns, available with '--scanners config'
--include-non-failures include successes and exceptions, available with '--scanners config'
--policy-namespaces strings Rego namespaces
--trace enable more verbose trace output for custom queries

View File

@@ -0,0 +1,28 @@
# Completion
```bash
Generate the autocompletion script for trivy for the specified shell.
See each sub-command's help for details on how to use the generated script.
Usage:
trivy completion [command]
Available Commands:
bash Generate the autocompletion script for bash
fish Generate the autocompletion script for fish
powershell Generate the autocompletion script for powershell
zsh Generate the autocompletion script for zsh
Flags:
-h, --help help for completion
Global Flags:
--cache-dir string cache directory (default "/Users/didier/Library/Caches/trivy")
-c, --config string config path (default "trivy.yaml")
-d, --debug debug mode
--generate-default-config write the default config to trivy-default.yaml
--insecure allow insecure server connections when using TLS
-q, --quiet suppress progress bar and log output
--timeout duration timeout (default 5m0s)
-v, --version show version
```

View File

@@ -32,8 +32,8 @@ Cache Flags
Misconfiguration Flags
--config-data strings specify paths from which data for the Rego policies will be recursively loaded
--config-policy strings specify paths to the Rego policy files directory, applying config files
--file-patterns strings specify config file patterns, available with '--security-checks config'
--include-non-failures include successes and exceptions, available with '--security-checks config'
--file-patterns strings specify config file patterns, available with '--scanners config'
--include-non-failures include successes and exceptions, available with '--scanners config'
--policy-namespaces strings Rego namespaces
--trace enable more verbose trace output for custom queries

View File

@@ -18,7 +18,7 @@ Examples:
Scan Flags
--offline-scan do not issue API requests to identify dependencies
--security-checks string comma-separated list of what security issues to detect (vuln,config,secret) (default "vuln,secret")
--scanners string comma-separated list of what security issues to detect (vuln,config,secret) (default "vuln,secret")
--skip-dirs strings specify the directories where the traversal is skipped
--skip-files strings specify the file paths to skip traversal
@@ -44,9 +44,12 @@ Cache Flags
DB Flags
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db")
--download-db-only download/update vulnerability database but don't run a scan
--download-java-db-only download/update java indexes database but don't run a scan
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db")
--no-progress suppress progress bar
--reset remove all caches and database
--skip-db-update skip updating vulnerability database
--skip-java-db-update skip updating java indexes database
Vulnerability Flags
--ignore-unfixed display only fixed vulnerabilities
@@ -55,8 +58,8 @@ Vulnerability Flags
Misconfiguration Flags
--config-data strings specify paths from which data for the Rego policies will be recursively loaded
--config-policy strings specify paths to the Rego policy files directory, applying config files
--file-patterns strings specify config file patterns, available with '--security-checks config'
--include-non-failures include successes and exceptions, available with '--security-checks config'
--file-patterns strings specify config file patterns, available with '--scanners config'
--include-non-failures include successes and exceptions, available with '--scanners config'
--policy-namespaces strings Rego namespaces
--trace enable more verbose trace output for custom queries

View File

@@ -33,12 +33,13 @@ Examples:
Scan Flags
--offline-scan do not issue API requests to identify dependencies
--security-checks string comma-separated list of what security issues to detect (vuln,config,secret) (default "vuln,secret")
--scanners string comma-separated list of what security issues to detect (vuln,config,secret) (default "vuln,secret")
--skip-dirs strings specify the directories where the traversal is skipped
--skip-files strings specify the file paths to skip traversal
Report Flags
--exit-code int specify exit code when any security issues are found
--exit-on-eol int exit with the specified code when the os of image ends of service/life
-f, --format string format (table, json, sarif, template, cyclonedx, spdx, spdx-json, github, cosign-vuln) (default "table")
--ignore-policy string specify the Rego file path to evaluate each vulnerability
--ignorefile string specify .trivyignore file (default ".trivyignore")
@@ -58,9 +59,12 @@ Cache Flags
DB Flags
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db")
--download-db-only download/update vulnerability database but don't run a scan
--download-java-db-only download/update java indexes database but don't run a scan
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db")
--no-progress suppress progress bar
--reset remove all caches and database
--skip-db-update skip updating vulnerability database
--skip-java-db-update skip updating java indexes database
Image Flags
--input string input file path instead of image name
@@ -73,8 +77,8 @@ Vulnerability Flags
Misconfiguration Flags
--config-data strings specify paths from which data for the Rego policies will be recursively loaded
--config-policy strings specify paths to the Rego policy files directory, applying config files
--file-patterns strings specify config file patterns, available with '--security-checks config'
--include-non-failures include successes and exceptions, available with '--security-checks config'
--file-patterns strings specify config file patterns, available with '--scanners config'
--include-non-failures include successes and exceptions, available with '--scanners config'
--policy-namespaces strings Rego namespaces
--trace enable more verbose trace output for custom queries

View File

@@ -21,6 +21,7 @@ Examples:
$ trivy server
Available Commands:
completion Generate the autocompletion script for the specified shell
config Scan config files for misconfigurations
filesystem Scan local filesystem
help Help about any command

View File

@@ -15,7 +15,7 @@ Examples:
Scan Flags
--offline-scan do not issue API requests to identify dependencies
--security-checks string comma-separated list of what security issues to detect (vuln,config,secret) (default "vuln,secret")
--scanners string comma-separated list of what security issues to detect (vuln,config,secret) (default "vuln,secret")
--skip-dirs strings specify the directories where the traversal is skipped
--skip-files strings specify the file paths to skip traversal
@@ -41,9 +41,12 @@ Cache Flags
DB Flags
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db")
--download-db-only download/update vulnerability database but don't run a scan
--download-java-db-only download/update java indexes database but don't run a scan
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db")
--no-progress suppress progress bar
--reset remove all caches and database
--skip-db-update skip updating vulnerability database
--skip-java-db-update skip updating java indexes database
Vulnerability Flags
--ignore-unfixed display only fixed vulnerabilities
@@ -52,8 +55,8 @@ Vulnerability Flags
Misconfiguration Flags
--config-data strings specify paths from which data for the Rego policies will be recursively loaded
--config-policy strings specify paths to the Rego policy files directory, applying config files
--file-patterns strings specify config file patterns, available with '--security-checks config'
--include-non-failures include successes and exceptions, available with '--security-checks config'
--file-patterns strings specify config file patterns, available with '--scanners config'
--include-non-failures include successes and exceptions, available with '--scanners config'
--policy-namespaces strings Rego namespaces
--trace enable more verbose trace output for custom queries

View File

@@ -21,7 +21,7 @@ Scan Flags
--offline-scan do not issue API requests to identify dependencies
--rekor-url string [EXPERIMENTAL] address of rekor STL server (default "https://rekor.sigstore.dev")
--sbom-sources strings [EXPERIMENTAL] try to retrieve SBOM from the specified sources (rekor)
--security-checks strings comma-separated list of what security issues to detect (vuln,config,secret,license) (default [vuln,secret])
--scanners strings comma-separated list of what security issues to detect (vuln,config,secret,license) (default [vuln,secret])
--skip-dirs strings specify the directories where the traversal is skipped
--skip-files strings specify the file paths to skip traversal
@@ -47,9 +47,12 @@ Cache Flags
DB Flags
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db")
--download-db-only download/update vulnerability database but don't run a scan
--download-java-db-only download/update java indexes database but don't run a scan
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db")
--no-progress suppress progress bar
--reset remove all caches and database
--skip-db-update skip updating vulnerability database
--skip-java-db-update skip updating java indexes database
Vulnerability Flags
--ignore-unfixed display only fixed vulnerabilities
@@ -60,7 +63,7 @@ Misconfiguration Flags
--helm-set-file strings specify Helm values from respective files specified via the command line (can specify multiple or separate values with commas: key1=path1,key2=path2)
--helm-set-string strings specify Helm string values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
--helm-values strings specify paths to override the Helm values.yaml files
--include-non-failures include successes and exceptions, available with '--security-checks config'
--include-non-failures include successes and exceptions, available with '--scanners config'
--tf-vars strings specify paths to override the Terraform tfvars files
Secret Flags

View File

@@ -19,7 +19,7 @@ Examples:
Scan Flags
--offline-scan do not issue API requests to identify dependencies
--security-checks string comma-separated list of what security issues to detect (vuln,config,secret) (default "vuln,secret")
--scanners string comma-separated list of what security issues to detect (vuln,config,secret) (default "vuln,secret")
--skip-dirs strings specify the directories where the traversal is skipped
--skip-files strings specify the file paths to skip traversal
@@ -44,9 +44,12 @@ Cache Flags
DB Flags
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db")
--download-db-only download/update vulnerability database but don't run a scan
--download-java-db-only download/update java indexes database but don't run a scan
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db")
--no-progress suppress progress bar
--reset remove all caches and database
--skip-db-update skip updating vulnerability database
--skip-java-db-update skip updating java indexes database
Vulnerability Flags
--ignore-unfixed display only fixed vulnerabilities

View File

@@ -41,7 +41,7 @@ report: all
# Same as '--template'
# Default is empty
template:
template:
# Same as '--dependency-tree'
# Default is false
@@ -63,6 +63,10 @@ ignore-policy:
# Default is 0
exit-code: 0
# Same as '--exit-on-eol'
# Default is 0
exit-on-eol: 0
# Same as '--output'
# Default is empty (stdout)
output:
@@ -92,19 +96,19 @@ scan:
skip-dirs:
- usr/local/
- etc/
# Same as '--skip-files'
# Default is empty
skip-files:
- package-dev.json
# Same as '--offline-scan'
# Default is false
offline-scan: false
# Same as '--security-checks'
# Same as '--scanners'
# Default depends on subcommand
security-checks:
scanners:
- vuln
- config
- secret
@@ -115,23 +119,23 @@ scan:
```yaml
cache:
# Same as '--cache-backend'
# Default is 'fs'
# Default is 'fs'
backend: 'fs'
# Same as '--cache-ttl'
# Default is 0 (no ttl)
# Default is 0 (no ttl)
ttl: 0
# Redis options
redis:
# Same as '--redis-ca'
# Default is empty
ca:
# Same as '--redis-cert'
# Default is empty
cert:
# Same as '--redis-key'
# Default is empty
key:
@@ -144,14 +148,18 @@ db:
# Same as '--skip-db-update'
# Default is false
skip-update: false
# Same as '--no-progress'
# Default is false
no-progress: false
# Same as '--db-repository'
# Default is 'github.com/aquasecurity-trivy-repo'
repository: github.com/aquasecurity-trivy-repo
# Default is 'ghcr.io/aquasecurity/trivy-db'
repository: ghcr.io/aquasecurity/trivy-db
# Same as '--java-db-repository'
# Default is 'ghcr.io/aquasecurity/trivy-java-db'
java-repository: ghcr.io/aquasecurity/trivy-java-db
```
## Image Options
@@ -162,7 +170,7 @@ image:
# Same as '--input' (available with 'trivy image')
# Default is empty
input:
# Same as '--removed-pkgs'
# Default is false
removed-pkgs: false
@@ -178,7 +186,7 @@ vulnerability:
type:
- os
- library
# Same as '--ignore-unfixed'
# Default is false
ignore-unfixed: false
@@ -265,25 +273,25 @@ kubernetes:
# Same as '--context'
# Default is empty
context:
# Same as '--namespace'
# Default is empty
namespace:
```
## Repository Options
Available with git repository scanning (`trivy repo`)
Available with git repository scanning (`trivy repo`)
```yaml
repository:
# Same as '--branch'
# Default is empty
branch:
# Same as '--commit'
# Default is empty
commit:
# Same as '--tag'
# Default is empty
tag:
@@ -297,21 +305,21 @@ server:
# Same as '--server' (available in client mode)
# Default is empty
addr: http://localhost:4954
# Same as '--token'
# Default is empty
token: "something-secret"
# Same as '--token-header'
# Default is 'Trivy-Token'
token-header: 'My-Token-Header'
# Same as '--custom-headers'
# Default is empty
custom-headers:
- scanner: trivy
- x-api-token: xxx
# Same as '--listen' (available in server mode)
# Default is 'localhost:4954'
listen: 0.0.0.0:10000
@@ -325,18 +333,18 @@ Available for cloud scanning (currently only `trivy aws`)
cloud:
# whether to force a cache update for every scan
update-cache: false
# how old cached results can be before being invalidated
max-cache-age: 24h
# aws-specific cloud settings
aws:
# the aws region to use
region: us-east-1
# the aws endpoint to use (not required for general use)
endpoint: https://my.custom.aws.endpoint
# the aws account to use (this will be determined from your environment when not set)
account: 123456789012
```

View File

@@ -39,49 +39,23 @@ https://developer.github.com/v3/#rate-limiting
$ GITHUB_TOKEN=XXXXXXXXXX trivy alpine:3.10
```
### Maven rate limiting / inconsistent jar vulnerability reporting
### Unable to open JAR files
!!! error
``` bash
$ trivy image ...
...
status 403 Forbidden from http://search.maven.org/solrsearch/select
failed to analyze file: failed to analyze usr/lib/jvm/java-1.8-openjdk/lib/tools.jar: unable to open usr/lib/jvm/java-1.8-openjdk/lib/tools.jar: failed to open: unable to read the file: stream error: stream ID 9; PROTOCOL_ERROR; received from peer
```
Trivy calls Maven API for better detection of JAR files, but many requests may exceed rate limiting.
This can easily happen if you are running more than one instance of Trivy which is concurrently scanning multiple images.
Once this starts happening Trivy's vulnerability reporting on jar files may become inconsistent.
There are two options to resolve this issue:
Currently, we're investigating this issue. As a temporary mitigation, you may be able to avoid this issue by downloading the Java DB in advance.
The first is to enable offline scanning using the `--offline-scan` option to stop Trivy from making API requests.
This option affects only vulnerability scanning. The vulnerability database and builtin policies are downloaded as usual.
If you want to skip them as well, you can try `--skip-update` and `--skip-policy-update`.
**Note that a number of vulnerabilities might be fewer than without the `--offline-scan` option.**
The second, more scalable, option is the place Trivy behind a rate-limiting forward-proxy to the Maven Central API.
One way to achieve this is to use nginx. You can use the following nginx config to enable both rate-limiting and caching (the caching greatly reduces the number of calls to the Maven Central API, especially if you are scanning a lot of similar images):
```nginx
limit_req_zone global zone=maven:1m rate=10r/s;
proxy_cache_path /tmp/cache keys_zone=mavencache:10m;
server {
listen 80;
proxy_cache mavencache;
location / {
limit_req zone=maven burst=1000;
proxy_cache_valid any 1h;
proxy_pass https://search.maven.org:443;
}
}
```shell
$ trivy image --download-java-db-only
2023-02-01T16:57:04.322+0900 INFO Downloading the Java DB...
$ trivy image [YOUR_JAVA_IMAGE]
```
This config file will allow a maximum of 10 requests per second to the Maven API, this number was determined experimentally so you might want to use something else if it doesn't fit your needs.
Once nginx is up and running, you need to tell all your Trivy deployments to proxy their Maven API calls through nginx. You can do this by setting the `MAVEN_CENTRAL_URL` environment variable. For example, if your nginx proxy is running at `127.0.0.1`, you can set `MAVEN_CENTRAL_URL=http://127.0.0.1/solrsearch/select`.
### Running in parallel takes same time as series run
When running trivy on multiple images simultaneously, it will take same time as running trivy in series.
This is because of a limitation of boltdb.
@@ -91,23 +65,6 @@ Reference : [boltdb: Opening a database][boltdb].
[boltdb]: https://github.com/boltdb/bolt#opening-a-database
### Error downloading vulnerability DB
!!! error
FATAL failed to download vulnerability DB
If trivy is running behind corporate firewall, you have to add the following urls to your allowlist.
- ghcr.io
- pkg-containers.githubusercontent.com
### Old DB schema
!!! error
--skip-update cannot be specified with the old DB schema.
Trivy v0.23.0 or later requires Trivy DB v2. Please update your local database or follow [the instruction of air-gapped environment][air-gapped].
### Multiple Trivy servers
!!! error
@@ -150,6 +107,37 @@ Try:
$ TMPDIR=/my/custom/path trivy image ...
```
## DB
### Old DB schema
!!! error
--skip-update cannot be specified with the old DB schema.
Trivy v0.23.0 or later requires Trivy DB v2. Please update your local database or follow [the instruction of air-gapped environment][air-gapped].
### Error downloading vulnerability DB
!!! error
FATAL failed to download vulnerability DB
If trivy is running behind corporate firewall, you have to add the following urls to your allowlist.
- ghcr.io
- pkg-containers.githubusercontent.com
### Denied
!!! error
GET https://ghcr.io/token?scope=repository%3Aaquasecurity%2Ftrivy-db%3Apull&service=ghcr.io: DENIED: denied
Your local GHCR (GitHub Container Registry) token might be expired.
Please remove the token and try downloading the DB again.
```shell
docker logout ghcr.io
```
## Homebrew
### Scope error
!!! error

View File

@@ -1,6 +1,4 @@
# CycloneDX
## Generating
# CycloneDX generation
Trivy can generate SBOM in the [CycloneDX][cyclonedx] format.
Note that XML format is not supported at the moment.
@@ -15,7 +13,7 @@ By default, `--format cyclonedx` represents SBOM and doesn't include vulnerabili
```
$ trivy image --format cyclonedx --output result.json alpine:3.15
2022-07-19T07:47:27.624Z INFO "--format cyclonedx" disables security checks. Specify "--security-checks vuln" explicitly if you want to include vulnerabilities in the CycloneDX report.
2022-07-19T07:47:27.624Z INFO "--format cyclonedx" disables security scanning. Specify "--scanners vuln" explicitly if you want to include vulnerabilities in the CycloneDX report.
```
<details>
@@ -239,40 +237,12 @@ $ cat result.json | jq .
</details>
If you want to include vulnerabilities, you can enable vulnerability scanning via `--security-checks vuln`.
If you want to include vulnerabilities, you can enable vulnerability scanning via `--scanners vuln`.
```
$ trivy image --security-checks vuln --format cyclonedx --output result.json alpine:3.15
$ trivy image --scanners vuln --format cyclonedx --output result.json alpine:3.15
```
## Scanning
Trivy can take CycloneDX as an input and scan for vulnerabilities.
To scan SBOM, you can use the `sbom` subcommand and pass the path to your CycloneDX report.
```bash
$ trivy sbom /path/to/cyclonedx.json
cyclonedx.json (alpine 3.7.1)
=========================
Total: 3 (CRITICAL: 3)
┌─────────────┬────────────────┬──────────┬───────────────────┬───────────────┬──────────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Installed Version │ Fixed Version │ Title │
├─────────────┼────────────────┼──────────┼───────────────────┼───────────────┼──────────────────────────────────────────────────────────────┤
│ curl │ CVE-2018-14618 │ CRITICAL │ 7.61.0-r0 │ 7.61.1-r0 │ curl: NTLM password overflow via integer overflow │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2018-14618 │
├─────────────┼────────────────┼──────────┼───────────────────┼───────────────┼──────────────────────────────────────────────────────────────┤
│ libbz2 │ CVE-2019-12900 │ CRITICAL │ 1.0.6-r6 │ 1.0.6-r7 │ bzip2: out-of-bounds write in function BZ2_decompress │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2019-12900 │
├─────────────┼────────────────┼──────────┼───────────────────┼───────────────┼──────────────────────────────────────────────────────────────┤
│ sqlite-libs │ CVE-2019-8457 │ CRITICAL │ 3.21.0-r1 │ 3.25.3-r1 │ sqlite: heap out-of-bound read in function rtreenode()
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2019-8457 │
└─────────────┴────────────────┴──────────┴───────────────────┴───────────────┴──────────────────────────────────────────────────────────────┘
```
!!! note
If you want to generate a CycloneDX report from a CycloneDX input, please be aware that the output stores references to your original CycloneDX report and contains only detected vulnerabilities, not components.
The report is called [BOV][bov].
[cyclonedx]: https://cyclonedx.org/
[sbom]: https://cyclonedx.org/capabilities/sbom/

View File

@@ -1,12 +1,12 @@
# SBOM
# SBOM generation
## Generating
Trivy can generate the following SBOM formats.
- [CycloneDX][cyclonedx]
- [SPDX][spdx]
To generate SBOM, you can use the `--format` option for each subcommand such as `image` and `fs`.
## CLI commands
To generate SBOM, you can use the `--format` option for each subcommand such as `image`, `fs` and `vm`.
```
$ trivy image --format spdx-json --output result.json alpine:3.15
@@ -177,56 +177,27 @@ $ trivy fs --format cyclonedx --output result.json /app/myproject
</details>
## Scanning
Trivy also can take the following SBOM formats as an input and scan for vulnerabilities.
## Supported packages
Trivy supports the following packages.
- CycloneDX
- SPDX
- SPDX JSON
- CycloneDX-type attestation
- [OS packages][os_packages]
- [Language-specific packages][language_packages]
To scan SBOM, you can use the `sbom` subcommand and pass the path to the SBOM.
```bash
$ trivy sbom /path/to/cyclonedx.json
```
See [here][cyclonedx] for the detail.
In addition to the above packages, Trivy also supports the following packages for generating SBOM.
!!! note
CycloneDX XML is not supported at the moment.
These packages are not supported for vulnerability scanning.
```bash
$ trivy sbom /path/to/spdx.json
```
| Language | File | Dependency location[^1] |
|----------|-------------------|:-----------------------:|
| Python | conda package[^2] | - |
| Swift | Podfile.lock | - |
See [here][spdx] for the detail.
You can also scan an SBOM attestation.
In the following example, [Cosign][Cosign] can get an attestation and trivy scan it. You must create CycloneDX-type attestation before trying the example. To learn more about how to create an CycloneDX-Type attestation and attach it to an image, see the [SBOM attestation page][sbom_attestation].
```bash
$ cosign verify-attestation --key /path/to/cosign.pub --type cyclonedx <IMAGE> > sbom.cdx.intoto.jsonl
$ trivy sbom ./sbom.cdx.intoto.jsonl
sbom.cdx.intoto.jsonl (alpine 3.7.3)
=========================
Total: 2 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 2)
┌────────────┬────────────────┬──────────┬───────────────────┬───────────────┬──────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Installed Version │ Fixed Version │ Title │
├────────────┼────────────────┼──────────┼───────────────────┼───────────────┼──────────────────────────────────────────────────────────┤
│ musl │ CVE-2019-14697 │ CRITICAL │ 1.1.18-r3 │ 1.1.18-r4 │ musl libc through 1.1.23 has an x87 floating-point stack │
│ │ │ │ │ │ adjustment im ...... │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2019-14697 │
├────────────┤ │ │ │ │ │
│ musl-utils │ │ │ │ │ │
│ │ │ │ │ │ │
│ │ │ │ │ │ │
└────────────┴────────────────┴──────────┴───────────────────┴───────────────┴──────────────────────────────────────────────────────────┘
```
[^1]: Use `startline == 1 and endline == 1` for unsupported file types
[^2]: `envs/*/conda-meta/*.json`
[cyclonedx]: cyclonedx.md
[spdx]: spdx.md
[Cosign]: https://github.com/sigstore/cosign
[sbom_attestation]: ../attestation/sbom.md#sign-with-a-local-key-pair
[os_packages]: ../vulnerability/detection/os.md
[language_packages]: ../vulnerability/detection/language.md

View File

@@ -1,6 +1,5 @@
# SPDX
# SPDX generation
## Generating
Trivy can generate SBOM in the [SPDX][spdx] format.
You can use the regular subcommands (like `image`, `fs` and `rootfs`) and specify `spdx` with the `--format` option.
@@ -295,50 +294,5 @@ $ cat result.spdx.json | jq .
</details>
## Scanning
Trivy can take the SPDX SBOM as an input and scan for vulnerabilities.
To scan SBOM, you can use the `sbom` subcommand and pass the path to your SPDX report.
The input format is automatically detected.
The following formats are supported:
- Tag-value (`--format spdx`)
- JSON (`--format spdx-json`)
```bash
$ trivy image --format spdx-json --output spdx.json alpine:3.16.0
$ trivy sbom spdx.json
2022-09-15T21:32:27.168+0300 INFO Vulnerability scanning is enabled
2022-09-15T21:32:27.169+0300 INFO Detected SBOM format: spdx-json
2022-09-15T21:32:27.210+0300 INFO Detected OS: alpine
2022-09-15T21:32:27.210+0300 INFO Detecting Alpine vulnerabilities...
2022-09-15T21:32:27.211+0300 INFO Number of language-specific files: 0
spdx.json (alpine 3.16.0)
=========================
Total: 5 (UNKNOWN: 0, LOW: 0, MEDIUM: 2, HIGH: 2, CRITICAL: 1)
┌──────────────┬────────────────┬──────────┬───────────────────┬───────────────┬────────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Installed Version │ Fixed Version │ Title │
├──────────────┼────────────────┼──────────┼───────────────────┼───────────────┼────────────────────────────────────────────────────────────┤
│ busybox │ CVE-2022-30065 │ HIGH │ 1.35.0-r13 │ 1.35.0-r15 │ busybox: A use-after-free in Busybox's awk applet leads to │
│ │ │ │ │ │ denial of service... │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2022-30065 │
├──────────────┼────────────────┼──────────┼───────────────────┼───────────────┼────────────────────────────────────────────────────────────┤
│ libcrypto1.1 │ CVE-2022-2097 │ MEDIUM │ 1.1.1o-r0 │ 1.1.1q-r0 │ openssl: AES OCB fails to encrypt some bytes │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2022-2097 │
├──────────────┤ │ │ │ │ │
│ libssl1.1 │ │ │ │ │ │
│ │ │ │ │ │ │
├──────────────┼────────────────┼──────────┼───────────────────┼───────────────┼────────────────────────────────────────────────────────────┤
│ ssl_client │ CVE-2022-30065 │ HIGH │ 1.35.0-r13 │ 1.35.0-r15 │ busybox: A use-after-free in Busybox's awk applet leads to │
│ │ │ │ │ │ denial of service... │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2022-30065 │
├──────────────┼────────────────┼──────────┼───────────────────┼───────────────┼────────────────────────────────────────────────────────────┤
│ zlib │ CVE-2022-37434 │ CRITICAL │ 1.2.12-r1 │ 1.2.12-r2 │ zlib: a heap-based buffer over-read or buffer overflow in │
│ │ │ │ │ │ inflate in inflate.c... │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2022-37434 │
└──────────────┴────────────────┴──────────┴───────────────────┴───────────────┴────────────────────────────────────────────────────────────┘
```
[spdx]: https://spdx.dev/wp-content/uploads/sites/41/2020/08/SPDX-specification-2-2.pdf

View File

@@ -1,14 +0,0 @@
## Packages that support vulnerability scanning
- [OS packages][os_packages]
- [Language-specific packages][language_packages]
## Other language-specific packages
| Language | File | Dependency location[^1] |
|----------|--------------|:-----------------------:|
| Swift | Podfile.lock | - |
[^1]: Use `startline == 1 and endline == 1` for unsupported file types
[os_packages]: ../vulnerability/detection/os.md
[language_packages]: ../vulnerability/detection/language.md

View File

@@ -15,7 +15,7 @@ $ trivy image --skip-dirs /var/lib --skip-dirs /var/log YOUR_IMAGE
$ trivy fs --skip-dirs ./my-test-dir --skip-dirs ./my-testing-cert/ /path/to/your_project
```
`--skip-fles` also works similarly.
`--skip-files` also works similarly.
## Filter by severity
@@ -48,10 +48,10 @@ aws-account-id
```
## Disable secret scanning
If you need vulnerability scanning only, you can disable secret scanning via the `--security-checks` flag.
If you need vulnerability scanning only, you can disable secret scanning via the `--scanners` flag.
``` shell
$ trivy image --security-checks vuln alpine:3.15
$ trivy image --scanners vuln alpine:3.15
```
## With configuration file
@@ -107,4 +107,4 @@ disable-allow-rules:
$ trivy fs --secret-config ./secret-config/trivy.yaml /path/to/your_project
```
[quick-start]: ./scanning.md#quick-start
[quick-start]: ./scanning.md#quick-start

View File

@@ -106,10 +106,10 @@ All rules are disabled except for the ones you specify, so it runs very fast.
On the other hand, you should use `disable-rules` if you just want to disable some built-in rules.
See the [enable-rules][enable-rules] and [disable-rules][disable-rules] sections for the detail.
If you don't need secret scanning, you can disable it via the `--security-checks` flag.
If you don't need secret scanning, you can disable it via the `--scanners` flag.
```shell
$ trivy image --security-checks vuln alpine:3.15
$ trivy image --scanners vuln alpine:3.15
```

107
docs/docs/target/aws.md Normal file
View File

@@ -0,0 +1,107 @@
# Amazon Web Services
!!! warning "EXPERIMENTAL"
This feature might change without preserving backwards compatibility.
The Trivy AWS CLI allows you to scan your AWS account for misconfigurations.
You can either run the CLI locally or integrate it into your CI/CD pipeline.
Whilst you can already scan the infrastructure-as-code that defines your AWS resources with `trivy config`, you can now scan your live AWS account(s) directly too.
The included checks cover all of the aspects of the [AWS CIS 1.2](https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-standards-cis.html) automated benchmarks.
Trivy uses the same [authentication methods](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) as the AWS CLI to configure and authenticate your access to the AWS platform.
You will need permissions configured to read all AWS resources - we recommend using a group/role with the `ReadOnlyAccess` policy attached.
Once you've scanned your account, you can run additional commands to filter the results without having to run the entire scan again - infrastructure information is cached locally per AWS account/region.
Trivy currently supports the following scanning for AWS accounts.
- Misconfigurations
## CLI Commands
Scan a full AWS account (all supported services):
```shell
trivy aws --region us-east-1
```
You can allow Trivy to determine the AWS region etc. by using the standard AWS configuration files and environment variables. The `--region` flag overrides these.
![AWS Summary Report](../../imgs/trivy-aws.png)
The summary view is the default when scanning multiple services.
Scan a specific service:
```shell
trivy aws --service s3
```
Scan multiple services:
```shell
# --service s3,ec2 works too
trivy aws --service s3 --service ec2
```
Show results for a specific AWS resource:
```shell
trivy aws --service s3 --arn arn:aws:s3:::example-bucket
```
All ARNs with detected issues will be displayed when showing results for their associated service.
## Compliance
This section describes AWS specific compliance reports.
For an overview of Trivy's Compliance feature, including working with custom compliance, check out the [Compliance documentation](../compliance/compliance.md).
### Built in reports
the following reports are available out of the box:
| Compliance | Name for command | More info |
|------------------------------------|------------------|------------------------------------------------------------------------------------------------------|
| AWS CIS Foundations Benchmark v1.2 | `aws-cis-1.2` | [link](https://d0.awsstatic.com/whitepapers/compliance/AWS_CIS_Foundations_Benchmark.pdf) |
| AWS CIS Foundations Benchmark v1.4 | `aws-cis-1.4` | [link](https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-cis-controls-1.4.0.html) |
### Examples
Scan a cloud account and generate a compliance summary report:
```
$ trivy aws --compliance=<compliance_id> --report=summary
```
***Note*** : The `Issues` column represent the total number of failed checks for this control.
Get all of the detailed output for checks:
```
$ trivy aws --compliance=<compliance_id> --report all
```
Report result in JSON format:
```
$ trivy aws --compliance=<compliance_id> --report all --format json
```
## Cached Results
By default, Trivy will cache a representation of each AWS service for 24 hours.
This means you can filter and view results for a service without having to wait for the entire scan to run again.
If you want to force the cache to be refreshed with the latest data, you can use `--update-cache`.
Or if you'd like to use cached data for a different timeframe, you can specify `--max-cache-age` (e.g. `--max-cache-age 2h`.).
Regardless of whether the cache is used or not, rules will be evaluated again with each run of `trivy aws`.
## Custom Policies
You can write custom policies for Trivy to evaluate against your AWS account.
These policies are written in [Rego](https://www.openpolicyagent.org/docs/latest/policy-language/), the same language used by [Open Policy Agent](https://www.openpolicyagent.org/).
See the [Custom Policies](../misconfiguration/custom/index.md) page for more information.

View File

@@ -0,0 +1,450 @@
# Container Image
Trivy supports two targets for container images.
- Files inside container images
- Container image metadata
## Files inside container images
Container images consist of files.
For instance, new files will be installed if you install a package.
Trivy scans the files inside container images for
- Vulnerabilities
- Misconfigurations
- Secrets
- Licenses
By default, vulnerability and secret scanning are enabled, and you can configure that with `--scanners`.
### Vulnerabilities
It is enabled by default.
You can simply specify your image name (and a tag).
It detects known vulnerabilities in your container image.
See [here](../vulnerability/scanning.md) for the detail.
```
$ trivy image [YOUR_IMAGE_NAME]
```
For example:
```
$ trivy image python:3.4-alpine
```
<details>
<summary>Result</summary>
```
2019-05-16T01:20:43.180+0900 INFO Updating vulnerability database...
2019-05-16T01:20:53.029+0900 INFO Detecting Alpine vulnerabilities...
python:3.4-alpine3.9 (alpine 3.9.2)
===================================
Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 1, HIGH: 0, CRITICAL: 0)
+---------+------------------+----------+-------------------+---------------+--------------------------------+
| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |
+---------+------------------+----------+-------------------+---------------+--------------------------------+
| openssl | CVE-2019-1543 | MEDIUM | 1.1.1a-r1 | 1.1.1b-r1 | openssl: ChaCha20-Poly1305 |
| | | | | | with long nonces |
+---------+------------------+----------+-------------------+---------------+--------------------------------+
```
</details>
To enable only vulnerability scanning, you can specify `--scanners vuln`.
```shell
$ trivy image --scanners vuln [YOUR_IMAGE_NAME]
```
### Misconfigurations
It is supported, but it is not useful in most cases.
As mentioned [here](../misconfiguration/scanning.md), Trivy mainly supports Infrastructure as Code (IaC) files for misconfigurations.
If your container image includes IaC files such as Kubernetes YAML files or Terraform files, you should enable this feature with `--scanners config`.
```
$ trivy image --scanners config [YOUR_IMAGE_NAME]
```
### Secrets
It is enabled by default.
See [here](../secret/scanning.md) for the detail.
```shell
$ trivy image [YOUR_IMAGE_NAME]
```
### Licenses
It is disabled by default.
See [here](../licenses/scanning.md) for the detail.
```shell
$ trivy image --scanners license [YOUR_IMAGE_NAME]
```
## Container image metadata
Container images have [configuration](https://github.com/opencontainers/image-spec/blob/2fb996805b3734779bf9a3a84dc9a9691ad7efdd/config.md).
`docker inspect` and `docker history` show the information according to the configuration.
Trivy scans the configuration of container images for
- Misconfigurations
- Secrets
They are disabled by default.
You can enable them with `--image-config-scanners`.
!!! tips
The configuration can be exported as the JSON file by `docker save`.
### Misconfigurations
Trivy detects misconfigurations on the configuration of container images.
The image config is converted into Dockerfile and Trivy handles it as Dockerfile.
See [here](../misconfiguration/scanning.md) for the detail of Dockerfile scanning.
It is disabled by default.
You can enable it with `--image-config-scanners config`.
```
$ trivy image --image-config-scanners config [YOUR_IMAGE_NAME]
```
If you just want to scan the image config, you can disable scanners with `--scanners none`.
For example:
```
$ trivy image --scanners none --image-config-scanners config alpine:3.17.0
```
<details>
<summary>Result</summary>
```
alpine:3.17 (dockerfile)
========================
Tests: 24 (SUCCESSES: 21, FAILURES: 3, EXCEPTIONS: 0)
Failures: 3 (UNKNOWN: 0, LOW: 2, MEDIUM: 0, HIGH: 1, CRITICAL: 0)
HIGH: Specify at least 1 USER command in Dockerfile with non-root user as argument
════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Running containers with 'root' user can lead to a container escape situation. It is a best practice to run containers as non-root users, which can be done by adding a 'USER' statement to the Dockerfile.
See https://avd.aquasec.com/misconfig/ds002
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
LOW: Consider using 'COPY file:e4d600fc4c9c293efe360be7b30ee96579925d1b4634c94332e2ec73f7d8eca1 in /' command instead of 'ADD file:e4d600fc4c9c293efe360be7b30ee96579925d1b4634c94332e2ec73f7d8eca1 in /'
════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
You should use COPY instead of ADD unless you want to extract a tar file. Note that an ADD command will extract a tar file, which adds the risk of Zip-based vulnerabilities. Accordingly, it is advised to use a COPY command, which does not extract tar files.
See https://avd.aquasec.com/misconfig/ds005
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
alpine:3.17:1
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 [ ADD file:e4d600fc4c9c293efe360be7b30ee96579925d1b4634c94332e2ec73f7d8eca1 in /
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
LOW: Add HEALTHCHECK instruction in your Dockerfile
════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
You shoud add HEALTHCHECK instruction in your docker container images to perform the health check on running containers.
See https://avd.aquasec.com/misconfig/ds026
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
```
</details>
!!! tip
You can see how each layer is created with `docker history`.
### Secrets
Trivy detects secrets on the configuration of container images.
The image config is converted into JSON and Trivy scans the file for secrets.
It is especially useful for environment variables that are likely to have credentials by accident.
See [here](../secret/scanning.md) for the detail.
```shell
$ trivy image --image-config-scanners secret [YOUR_IMAGE_NAME]
```
If you just want to scan the image config, you can disable scanners with `--scanners none`.
For example:
```shell
$ trivy image --scanners none --image-config-scanners secret vuln-image
```
<details>
<summary>Result</summary>
```
vuln-image (alpine 3.17.1)
==========================
Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)
vuln-image (secrets)
====================
Total: 2 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 2)
CRITICAL: GitHub (github-pat)
════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
GitHub Personal Access Token
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
test:16
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
14 {
15 "created": "2023-01-09T17:05:20Z",
16 [ "created_by": "ENV secret=****************************************",
17 "comment": "buildkit.dockerfile.v0",
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
CRITICAL: GitHub (github-pat)
════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
GitHub Personal Access Token
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
test:34
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
32 "Env": [
33 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
34 [ "secret=****************************************"
35 ]
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
```
</details>
!!! tip
You can see environment variables with `docker inspect`.
## Supported
### Docker Engine
Trivy tries to looks for the specified image in your local Docker Engine.
It will be skipped if Docker Engine is not running locally.
If your docker socket is not the default path, you can override it via `DOCKER_HOST`.
### containerd
!!! warning "EXPERIMENTAL"
This feature might change without preserving backwards compatibility.
Trivy tries to looks for the specified image in your local [containerd](https://containerd.io/).
It will be skipped if containerd is not running locally.
Specify your image name in containerd running locally.
```bash
$ nerdctl images
REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE
aquasec/nginx latest 2bcabc23b454 3 hours ago linux/amd64 149.1 MiB 54.1 MiB
$ trivy image aquasec/nginx
```
If your containerd socket is not the default path (`//run/containerd/containerd.sock`), you can override it via `CONTAINERD_ADDRESS`.
```bash
$ export CONTAINERD_ADDRESS=/run/k3s/containerd/containerd.sock
$ trivy image aquasec/nginx
```
If your scan targets are images in a namespace other than containerd's default namespace (`default`), you can override it via `CONTAINERD_NAMESPACE`.
```bash
$ export CONTAINERD_NAMESPACE=k8s.io
$ trivy image aquasec/nginx
```
### Podman
!!! warning "EXPERIMENTAL"
This feature might change without preserving backwards compatibility.
Scan your image in Podman (>=2.0) running locally. The remote Podman is not supported.
Before performing Trivy commands, you must enable the podman.sock systemd service on your machine.
For more details, see [here](https://github.com/containers/podman/blob/master/docs/tutorials/remote_client.md#enable-the-podman-service-on-the-server-machine).
```bash
$ systemctl --user enable --now podman.socket
```
Then, you can scan your image in Podman.
```bash
$ cat Dockerfile
FROM alpine:3.12
RUN apk add --no-cache bash
$ podman build -t test .
$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/test latest efc372d4e0de About a minute ago 7.94 MB
$ trivy image test
```
### Container Registry
Trivy supports registries that comply with the following specifications.
- [Docker Registry HTTP API V2](https://docs.docker.com/registry/spec/api/)
- [OCI Distribution Specification](https://github.com/opencontainers/distribution-spec)
You can configure credentials with `docker login`.
See [here](../advanced/private-registries/index.md) for the detail.
### Tar Files
Trivy supports image tar files generated by the following tools.
- [Docker Image Specification](https://github.com/moby/moby/tree/master/image/spec)
- [Moby Project](https://github.com/moby/moby/)
- [Buildah](https://github.com/containers/buildah)
- [Podman](https://github.com/containers/podman)
- [img](https://github.com/genuinetools/img)
- [Kaniko](https://github.com/GoogleContainerTools/kaniko)
```
$ docker pull ruby:3.1-alpine3.15
$ docker save ruby:3.1-alpine3.15 -o ruby-3.1.tar
$ trivy image --input ruby-3.1.tar
```
<details>
<summary>Result</summary>
```
2022-02-03T10:08:19.127Z INFO Detected OS: alpine
2022-02-03T10:08:19.127Z WARN This OS version is not on the EOL list: alpine 3.15
2022-02-03T10:08:19.127Z INFO Detecting Alpine vulnerabilities...
2022-02-03T10:08:19.127Z INFO Number of language-specific files: 2
2022-02-03T10:08:19.127Z INFO Detecting gemspec vulnerabilities...
2022-02-03T10:08:19.128Z INFO Detecting node-pkg vulnerabilities...
2022-02-03T10:08:19.128Z WARN This OS version is no longer supported by the distribution: alpine 3.15.0
2022-02-03T10:08:19.128Z WARN The vulnerability detection may be insufficient because security updates are not provided
ruby-3.1.tar (alpine 3.15.0)
============================
Total: 3 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 3, CRITICAL: 0)
+----------+------------------+----------+-------------------+---------------+---------------------------------------+
| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |
+----------+------------------+----------+-------------------+---------------+---------------------------------------+
| gmp | CVE-2021-43618 | HIGH | 6.2.1-r0 | 6.2.1-r1 | gmp: Integer overflow and resultant |
| | | | | | buffer overflow via crafted input |
| | | | | | -->avd.aquasec.com/nvd/cve-2021-43618 |
+----------+ + + + + +
| gmp-dev | | | | | |
| | | | | | |
| | | | | | |
+----------+ + + + + +
| libgmpxx | | | | | |
| | | | | | |
| | | | | | |
+----------+------------------+----------+-------------------+---------------+---------------------------------------+
Node.js (node-pkg)
==================
Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)
Ruby (gemspec)
==============
Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)
```
</details>
### OCI Layout
Trivy supports image directories compliant with [Open Container Image Layout Specification](https://github.com/opencontainers/image-spec/blob/master/spec.md).
Buildah:
```
$ buildah push docker.io/library/alpine:3.11 oci:/path/to/alpine
$ trivy image --input /path/to/alpine
```
Skopeo:
```
$ skopeo copy docker-daemon:alpine:3.11 oci:/path/to/alpine
$ trivy image --input /path/to/alpine
```
## SBOM generation
Trivy can generate SBOM for container images.
See [here](../sbom/index.md) for the detail.
## Compliance
!!! warning "EXPERIMENTAL"
This feature might change without preserving backwards compatibility.
This section describes container image specific compliance reports.
For an overview of Trivy's Compliance feature, including working with custom compliance, check out the [Compliance documentation](../compliance/compliance.md).
### Built in reports
The following reports are available out of the box:
| Compliance | Version | Name for command | More info |
|----------------------------------------|---------|------------------|---------------------------------------------------------------------------------------------|
| CIS Docker Community Edition Benchmark | 1.1.0 | `docker-cis` | [Link](https://www.aquasec.com/cloud-native-academy/docker-container/docker-cis-benchmark/) |
### Examples
Scan a container image configuration and generate a compliance summary report:
```
$ trivy image --compliance docker-cis [YOUR_IMAGE_NAME]
```
!!! note
The `Issues` column represent the total number of failed checks for this control.
## Options
### Scan Image on a specific Architecture and OS
By default, Trivy loads an image on a "linux/amd64" machine.
To customise this, pass a `--platform` argument in the format OS/Architecture for the image:
```
$ trivy image --platform=os/architecture [YOUR_IMAGE_NAME]
```
For example:
```
$ trivy image --platform=linux/arm alpine:3.16.1
```
<details>
<summary>Result</summary>
```
2022-10-25T21:00:50.972+0300 INFO Vulnerability scanning is enabled
2022-10-25T21:00:50.972+0300 INFO Secret scanning is enabled
2022-10-25T21:00:50.972+0300 INFO If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2022-10-25T21:00:50.972+0300 INFO Please see also https://aquasecurity.github.io/trivy/dev/docs/secret/scanning/#recommendation for faster secret detection
2022-10-25T21:00:56.190+0300 INFO Detected OS: alpine
2022-10-25T21:00:56.190+0300 INFO Detecting Alpine vulnerabilities...
2022-10-25T21:00:56.191+0300 INFO Number of language-specific files: 0
alpine:3.16.1 (alpine 3.16.1)
=============================
Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 1)
┌─────────┬────────────────┬──────────┬───────────────────┬───────────────┬─────────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Installed Version │ Fixed Version │ Title │
├─────────┼────────────────┼──────────┼───────────────────┼───────────────┼─────────────────────────────────────────────────────────────┤
│ zlib │ CVE-2022-37434 │ CRITICAL │ 1.2.12-r1 │ 1.2.12-r2 │ zlib: heap-based buffer over-read and overflow in inflate() │
│ │ │ │ │ │ in inflate.c via a... │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2022-37434 │
└─────────┴────────────────┴──────────┴───────────────────┴───────────────┴─────────────────────────────────────────────────────────────┘
```
</details>

View File

@@ -0,0 +1,93 @@
# Filesystem
Scan your local projects for
- Vulnerabilities
- Misconfigurations
- Secrets
- Licenses
By default, vulnerability and secret scanning are enabled, and you can configure that with `--scanners`.
```bash
$ trivy fs /path/to/project
```
It's also possible to scan a single file.
```
$ trivy fs ~/src/github.com/aquasecurity/trivy-ci-test/Pipfile.lock
```
## Scanners
### Vulnerabilities
It is enabled by default.
Trivy will look for vulnerabilities based on lock files such as Gemfile.lock and package-lock.json.
See [here](../vulnerability/scanning.md) for the detail.
```
$ trivy fs ~/src/github.com/aquasecurity/trivy-ci-test
```
<details>
<summary>Result</summary>
```
2020-06-01T17:06:58.652+0300 WARN OS is not detected and vulnerabilities in OS packages are not detected.
2020-06-01T17:06:58.652+0300 INFO Detecting pipenv vulnerabilities...
2020-06-01T17:06:58.691+0300 INFO Detecting cargo vulnerabilities...
Pipfile.lock
============
Total: 10 (UNKNOWN: 2, LOW: 0, MEDIUM: 6, HIGH: 2, CRITICAL: 0)
+---------------------+------------------+----------+-------------------+------------------------+------------------------------------+
| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |
+---------------------+------------------+----------+-------------------+------------------------+------------------------------------+
| django | CVE-2020-7471 | HIGH | 2.0.9 | 3.0.3, 2.2.10, 1.11.28 | django: potential |
| | | | | | SQL injection via |
| | | | | | StringAgg(delimiter) |
+ +------------------+----------+ +------------------------+------------------------------------+
| | CVE-2019-19844 | MEDIUM | | 3.0.1, 2.2.9, 1.11.27 | Django: crafted email address |
| | | | | | allows account takeover |
+ +------------------+ + +------------------------+------------------------------------+
| | CVE-2019-3498 | | | 2.1.5, 2.0.10, 1.11.18 | python-django: Content |
| | | | | | spoofing via URL path in |
| | | | | | default 404 page |
+ +------------------+ + +------------------------+------------------------------------+
| | CVE-2019-6975 | | | 2.1.6, 2.0.11, 1.11.19 | python-django: |
| | | | | | memory exhaustion in |
| | | | | | django.utils.numberformat.format() |
+---------------------+------------------+----------+-------------------+------------------------+------------------------------------+
...
```
</details>
### Misconfigurations
It is disabled by default and can be enabled with `--scanners config`.
See [here](../misconfiguration/scanning.md) for the detail.
```shell
$ trivy fs --scanners config /path/to/project
```
### Secrets
It is enabled by default.
See [here](../secret/scanning.md) for the detail.
```shell
$ trivy fs /path/to/project
```
### Licenses
It is disabled by default.
See [here](../licenses/scanning.md) for the detail.
```shell
$ trivy fs --scanners license /path/to/project
```
## SBOM generation
Trivy can generate SBOM for local projects.
See [here](../sbom/index.md) for the detail.

View File

@@ -1,6 +1,23 @@
# Git Repository
Scan your remote git repository
Scan your remote git repositories for
- Vulnerabilities
- Misconfigurations
- Secrets
- Licenses
By default, vulnerability and secret scanning are enabled, and you can configure that with `--scanners`.
```bash
$ trivy repo [YOUR_REPO_URL]
```
## Scanners
### Vulnerabilities
It is enabled by default.
Trivy will look for vulnerabilities based on lock files such as Gemfile.lock and package-lock.json.
See [here](../vulnerability/scanning.md) for the detail.
```
$ trivy repo https://github.com/knqyf263/trivy-ci-test
@@ -147,7 +164,36 @@ Total: 20 (UNKNOWN: 3, LOW: 0, MEDIUM: 7, HIGH: 5, CRITICAL: 5)
</details>
## Scanning a Branch
### Misconfigurations
It is disabled by default and can be enabled with `--scanners config`.
See [here](../misconfiguration/scanning.md) for the detail.
```shell
$ trivy repo --scanners config [YOUR_REPO_URL]
```
### Secrets
It is enabled by default.
See [here](../secret/scanning.md) for the detail.
```shell
$ trivy repo [YOUR_REPO_URL]
```
### Licenses
It is disabled by default.
See [here](../licenses/scanning.md) for the detail.
```shell
$ trivy repo --scanners license [YOUR_REPO_URL]
```
## SBOM generation
Trivy can generate SBOM for git repositories.
See [here](../sbom/index.md) for the detail.
## References
### Scanning a Branch
Pass a `--branch` argument with a valid branch name on the remote repository provided:
@@ -155,7 +201,7 @@ Pass a `--branch` argument with a valid branch name on the remote repository pro
$ trivy repo --branch <branch-name> <repo-name>
```
## Scanning upto a Commit
### Scanning upto a Commit
Pass a `--commit` argument with a valid commit hash on the remote repository provided:
@@ -163,7 +209,7 @@ Pass a `--commit` argument with a valid commit hash on the remote repository pro
$ trivy repo --commit <commit-hash> <repo-name>
```
## Scanning a Tag
### Scanning a Tag
Pass a `--tag` argument with a valid tag on the remote repository provided:
@@ -171,8 +217,7 @@ Pass a `--tag` argument with a valid tag on the remote repository provided:
$ trivy repo --tag <tag-name> <repo-name>
```
## Scanning Private Repositories
### Scanning Private Repositories
In order to scan private GitHub or GitLab repositories, the environment variable `GITHUB_TOKEN` or `GITLAB_TOKEN` must be set, respectively, with a valid token that has access to the private repository being scanned.
The `GITHUB_TOKEN` environment variable will take precedence over `GITLAB_TOKEN`, so if a private GitLab repository will be scanned, then `GITHUB_TOKEN` must be unset.
@@ -187,65 +232,3 @@ $ # or
$ export GITLAB_TOKEN="your_private_gitlab_token"
$ trivy repo <your private GitLab repo URL>
```
## Client/Server mode
You must launch Trivy server in advance.
```sh
$ trivy server
```
Then, Trivy works as a client if you specify the `--server` option.
```sh
$ trivy repo https://github.com/knqyf263/trivy-ci-test --server http://localhost:4954
```
<details>
<summary>Result</summary>
```
Cargo.lock (cargo)
==================
Total: 2 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 1)
┌───────────┬─────────────────────┬──────────┬───────────────────┬───────────────┬─────────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Installed Version │ Fixed Version │ Title │
├───────────┼─────────────────────┼──────────┼───────────────────┼───────────────┼─────────────────────────────────────────────────────────────┤
│ openssl │ CVE-2018-20997 │ CRITICAL │ 0.8.3 │ 0.10.9 │ Use after free in openssl │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2018-20997 │
│ ├─────────────────────┼──────────┤ ├───────────────┼─────────────────────────────────────────────────────────────┤
│ │ CVE-2016-10931 │ HIGH │ │ 0.9.0 │ Improper Certificate Validation in openssl │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2016-10931 │
└───────────┴─────────────────────┴──────────┴───────────────────┴───────────────┴─────────────────────────────────────────────────────────────┘
Pipfile.lock (pipenv)
=====================
Total: 5 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 3, CRITICAL: 2)
┌─────────────────────┬────────────────┬──────────┬───────────────────┬────────────────────────┬──────────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Installed Version │ Fixed Version │ Title │
├─────────────────────┼────────────────┼──────────┼───────────────────┼────────────────────────┼──────────────────────────────────────────────────────────────┤
│ py │ CVE-2020-29651 │ HIGH │ 1.8.0 │ 1.10.0 │ python-py: ReDoS in the py.path.svnwc component via │
│ │ │ │ │ │ mailicious input to blame functionality... │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2020-29651 │
│ ├────────────────┤ │ ├────────────────────────┼──────────────────────────────────────────────────────────────┤
│ │ CVE-2022-42969 │ │ │ │ The py library through 1.11.0 for Python allows remote │
│ │ │ │ │ │ attackers to co... │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2022-42969 │
├─────────────────────┼────────────────┤ ├───────────────────┼────────────────────────┼──────────────────────────────────────────────────────────────┤
│ pyjwt │ CVE-2022-29217 │ │ 1.7.1 │ 2.4.0 │ python-jwt: Key confusion through non-blocklisted public key │
│ │ │ │ │ │ formats │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2022-29217 │
├─────────────────────┼────────────────┼──────────┼───────────────────┼────────────────────────┼──────────────────────────────────────────────────────────────┤
│ pyyaml │ CVE-2019-20477 │ CRITICAL │ 5.1 │ 5.2b1 │ PyYAML: command execution through python/object/apply │
│ │ │ │ │ │ constructor in FullLoader │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2019-20477 │
│ ├────────────────┤ │ ├────────────────────────┼──────────────────────────────────────────────────────────────┤
│ │ CVE-2020-1747 │ │ │ 5.3.1 │ PyYAML: arbitrary command execution through │
│ │ │ │ │ │ python/object/new when FullLoader is used │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2020-1747 │
└─────────────────────┴────────────────┴──────────┴───────────────────┴────────────────────────┴──────────────────────────────────────────────────────────────┘
```
</details>

View File

@@ -3,13 +3,21 @@
!!! warning "EXPERIMENTAL"
This feature might change without preserving backwards compatibility.
The Trivy K8s CLI allows you to scan your Kubernetes cluster for Vulnerabilities, Secrets and Misconfigurations. You can either run the CLI locally or integrate it into your CI/CD pipeline. The difference to the Trivy CLI is that the Trivy K8s CLI allows you to scan running workloads directly within your cluster.
## CLI
The Trivy K8s CLI allows you to scan your Kubernetes cluster for
If you are looking for continuous cluster audit scanning, have a look at the [Trivy K8s operator.](../operator/index.md)
- Vulnerabilities
- Misconfigurations
- Secrets
You can either run the CLI locally or integrate it into your CI/CD pipeline.
The difference to the Trivy CLI is that the Trivy K8s CLI allows you to scan running workloads directly within your cluster.
If you are looking for continuous cluster audit scanning, have a look at the Trivy K8s operator below.
Trivy uses your local kubectl configuration to access the API server to list artifacts.
## CLI Commands
### Commands
Scan a full cluster and generate a simple summary report:
@@ -17,7 +25,7 @@ Scan a full cluster and generate a simple summary report:
$ trivy k8s --report=summary cluster
```
![k8s Summary Report](../../../imgs/trivy-k8s.png)
![k8s Summary Report](../../imgs/trivy-k8s.png)
The summary report is the default. To get all of the detail the output contains, use `--report all`.
@@ -27,12 +35,12 @@ Filter by severity:
$ trivy k8s --severity=CRITICAL --report=all cluster
```
Filter by security check (Vulnerabilities, Secrets or Misconfigurations):
Filter by scanners (Vulnerabilities, Secrets or Misconfigurations):
```
$ trivy k8s --security-checks=secret --report=summary cluster
$ trivy k8s --scanners=secret --report=summary cluster
# or
$ trivy k8s --security-checks=config --report=summary cluster
$ trivy k8s --scanners=config --report=summary cluster
```
Scan a specific namespace:
@@ -233,7 +241,7 @@ $ trivy k8s --format json -o results.json cluster
## Infra checks
### Infra checks
Trivy by default scans kubernetes infra components (apiserver, controller-manager, scheduler and etcd)
if they exist under the `kube-system` namespace. For example, if you run a full cluster scan, or scan all
@@ -263,17 +271,69 @@ Severities: C=CRITICAL H=HIGH M=MEDIUM L=LOW U=UNKNOWN
The infra checks are based on CIS Benchmarks recommendations for kubernetes.
If you want filter only for the infra checks, you can use the flag `--components` along with the `--security-checks=config`
If you want filter only for the infra checks, you can use the flag `--components` along with the `--scanners=config`
```
$ trivy k8s cluster --report summary --components=infra --security-checks=config # scan only infra
$ trivy k8s cluster --report summary --components=infra --scanners=config # scan only infra
```
Or, to filter for all other checks besides the infra checks, you can:
```
$ trivy k8s cluster --report summary --components=workload --security-checks=config # scan all components besides infra
$ trivy k8s cluster --report summary --components=workload --scanners=config # scan all components besides infra
```
### Compliance
This section describes Kubernetes specific compliance reports.
For an overview of Trivy's Compliance feature, including working with custom compliance, check out the [Compliance documentation](../compliance/compliance.md).
#### Built in reports
The following reports are available out of the box:
| Compliance | Name for command | More info |
|----------------------------------------------|----------------------|---------------------------------------------------------------------------------------------------------------------|
| NSA, CISA Kubernetes Hardening Guidance v1.2 | `k8s-nsa` | [Link](https://media.defense.gov/2022/Aug/29/2003066362/-1/-1/0/CTR_KUBERNETES_HARDENING_GUIDANCE_1.2_20220829.PDF) |
| CIS Benchmark for Kubernetes v1.23 | `k8s-cis` | [Link](https://www.cisecurity.org/benchmark/kubernetes) |
| Pod Security Standards, Baseline | `k8s-pss-baseline` | [Link](https://kubernetes.io/docs/concepts/security/pod-security-standards/#baseline) |
| Pod Security Standards, Restricted | `k8s-pss-restricted` | [Link](https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted) |
#### Examples
Scan a full cluster and generate a compliance summary report:
```
$ trivy k8s cluster --compliance=<compliance_id> --report summary
```
***Note*** : The `Issues` column represent the total number of failed checks for this control.
Get all of the detailed output for checks:
```
trivy k8s cluster --compliance=<compliance_id> --report all
```
Report result in JSON format:
```
trivy k8s cluster --compliance=<compliance_id> --report summary --format json
```
```
trivy k8s cluster --compliance=<compliance_id> --report all --format json
```
## Operator
Trivy has a native [Kubernetes Operator][operator] which continuously scans your Kubernetes cluster for security issues, and generates security reports as Kubernetes [Custom Resources][crd]. It does it by watching Kubernetes for state changes and automatically triggering scans in response to changes, for example initiating a vulnerability scan when a new Pod is created.
> Kubernetes-native security toolkit. ([Documentation][trivy-operator]).
<figure>
<figcaption>Workload reconcilers discover K8s controllers, manage scan jobs, and create VulnerabilityReport and ConfigAuditReport objects.</figcaption>
</figure>
[operator]: https://kubernetes.io/docs/concepts/extend-kubernetes/operator/
[crd]: https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/
[trivy-operator]: https://aquasecurity.github.io/trivy-operator/latest

View File

@@ -0,0 +1,15 @@
# Rootfs
Rootfs scanning is for special use cases such as
- Host machine
- [Root filesystem](../advanced/container/embed-in-dockerfile.md)
- [Unpacked filesystem](../advanced/container/unpacked-filesystem.md)
```bash
$ trivy rootfs /path/to/rootfs
```
!!! note
Rootfs scanning works differently from the Filesystem scanning.
You should use `trivy fs` to scan your local projects in CI/CD.
See [here](../vulnerability/detection/language.md) for the differences.

113
docs/docs/target/sbom.md Normal file
View File

@@ -0,0 +1,113 @@
# SBOM scanning
Trivy can take the following SBOM formats as an input and scan for vulnerabilities.
- CycloneDX
- SPDX
- SPDX JSON
- CycloneDX-type attestation
To scan SBOM, you can use the `sbom` subcommand and pass the path to the SBOM.
The input format is automatically detected.
```bash
$ trivy sbom /path/to/sbom_file
```
!!! note
Passing SBOMs generated by tool other than Trivy may result in inaccurate detection
because Trivy relies on custom properties in SBOM for accurate scanning.
## CycloneDX
Trivy supports CycloneDX as an input.
!!! note
CycloneDX XML is not supported at the moment.
```bash
$ trivy sbom /path/to/cyclonedx.json
```
!!! note
If you want to generate a CycloneDX report from a CycloneDX input, please be aware that the output stores references to your original CycloneDX report and contains only detected vulnerabilities, not components.
The report is called [BOV](https://cyclonedx.org/capabilities/sbom/).
## SPDX
Trivy supports the SPDX SBOM as an input.
The following SPDX formats are supported:
- Tag-value (`--format spdx`)
- JSON (`--format spdx-json`)
```bash
$ trivy image --format spdx-json --output spdx.json alpine:3.16.0
$ trivy sbom spdx.json
```
<details>
<summary>Result</summary>
```
2022-09-15T21:32:27.168+0300 INFO Vulnerability scanning is enabled
2022-09-15T21:32:27.169+0300 INFO Detected SBOM format: spdx-json
2022-09-15T21:32:27.210+0300 INFO Detected OS: alpine
2022-09-15T21:32:27.210+0300 INFO Detecting Alpine vulnerabilities...
2022-09-15T21:32:27.211+0300 INFO Number of language-specific files: 0
spdx.json (alpine 3.16.0)
=========================
Total: 5 (UNKNOWN: 0, LOW: 0, MEDIUM: 2, HIGH: 2, CRITICAL: 1)
┌──────────────┬────────────────┬──────────┬───────────────────┬───────────────┬────────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Installed Version │ Fixed Version │ Title │
├──────────────┼────────────────┼──────────┼───────────────────┼───────────────┼────────────────────────────────────────────────────────────┤
│ busybox │ CVE-2022-30065 │ HIGH │ 1.35.0-r13 │ 1.35.0-r15 │ busybox: A use-after-free in Busybox's awk applet leads to │
│ │ │ │ │ │ denial of service... │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2022-30065 │
├──────────────┼────────────────┼──────────┼───────────────────┼───────────────┼────────────────────────────────────────────────────────────┤
│ libcrypto1.1 │ CVE-2022-2097 │ MEDIUM │ 1.1.1o-r0 │ 1.1.1q-r0 │ openssl: AES OCB fails to encrypt some bytes │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2022-2097 │
├──────────────┤ │ │ │ │ │
│ libssl1.1 │ │ │ │ │ │
│ │ │ │ │ │ │
├──────────────┼────────────────┼──────────┼───────────────────┼───────────────┼────────────────────────────────────────────────────────────┤
│ ssl_client │ CVE-2022-30065 │ HIGH │ 1.35.0-r13 │ 1.35.0-r15 │ busybox: A use-after-free in Busybox's awk applet leads to │
│ │ │ │ │ │ denial of service... │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2022-30065 │
├──────────────┼────────────────┼──────────┼───────────────────┼───────────────┼────────────────────────────────────────────────────────────┤
│ zlib │ CVE-2022-37434 │ CRITICAL │ 1.2.12-r1 │ 1.2.12-r2 │ zlib: a heap-based buffer over-read or buffer overflow in │
│ │ │ │ │ │ inflate in inflate.c... │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2022-37434 │
└──────────────┴────────────────┴──────────┴───────────────────┴───────────────┴────────────────────────────────────────────────────────────┘
```
</details>
## SBOM attestation
You can also scan an SBOM attestation.
In the following example, [Cosign](https://github.com/sigstore/cosign) gets an attestation and Trivy scans it.
You must create CycloneDX-type attestation before trying the example.
To learn more about how to create an CycloneDX-Type attestation and attach it to an image, see the [SBOM attestation page](../attestation/sbom.md#sign-with-a-local-key-pair).
```bash
$ cosign verify-attestation --key /path/to/cosign.pub --type cyclonedx <IMAGE> > sbom.cdx.intoto.jsonl
$ trivy sbom ./sbom.cdx.intoto.jsonl
sbom.cdx.intoto.jsonl (alpine 3.7.3)
=========================
Total: 2 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 2)
┌────────────┬────────────────┬──────────┬───────────────────┬───────────────┬──────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Installed Version │ Fixed Version │ Title │
├────────────┼────────────────┼──────────┼───────────────────┼───────────────┼──────────────────────────────────────────────────────────┤
│ musl │ CVE-2019-14697 │ CRITICAL │ 1.1.18-r3 │ 1.1.18-r4 │ musl libc through 1.1.23 has an x87 floating-point stack │
│ │ │ │ │ │ adjustment im ...... │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2019-14697 │
├────────────┤ │ │ │ │ │
│ musl-utils │ │ │ │ │ │
│ │ │ │ │ │ │
│ │ │ │ │ │ │
└────────────┴────────────────┴──────────┴───────────────────┴───────────────┴──────────────────────────────────────────────────────────┘
```

View File

@@ -3,20 +3,21 @@
!!! warning "EXPERIMENTAL"
This feature might change without preserving backwards compatibility.
## Scanning
Trivy supports VM image scanning for vulnerabilities, secrets, etc.
To scan virtual machine (VM) images, you can use the `vm` subcommand.
## Targets
The following targets are currently supported:
- Local file
- [AWS EC2][aws]
To scan VM images, you can use the `vm` subcommand.
- AWS EC2
- Amazon Machine Image (AMI)
- Amazon Elastic Block Store (EBS) Snapshot
### Local file
Pass the path to your local VM image file.
```bash
$ trivy vm --security-checks vuln disk.vmdk
$ trivy vm --scanners vuln disk.vmdk
```
<details>
@@ -62,11 +63,126 @@ Total: 802 (UNKNOWN: 0, LOW: 17, MEDIUM: 554, HIGH: 221, CRITICAL: 10)
</details>
### AWS EC2
### Amazon Machine Image (AMI)
You can specify your AMI ID with the `ami:` prefix.
See [here][aws] for the detail.
```shell
$ trivy vm ami:${your_ami_id}
```
## Supported architectures
!!! note
AMIs in the marketplace are not supported because the EBS direct APIs don't support that.
See [the AWS documentation][ebsapi-elements] for the detail.
#### Example
```shell
$ trivy vm --scanners vuln ami:ami-0123456789abcdefg
```
If you want to scan a AMI of non-default setting region, you can set any region via `--aws-region` option.
```shell
$ trivy vm --aws-region ap-northeast-1 ami:ami-0123456789abcdefg
```
#### Required Actions
Some actions on EBS are also necessary since Trivy scans an EBS snapshot tied to the specified AMI under the hood.
- ec2:DescribeImages
- ebs:ListSnapshotBlocks
- ebs:GetSnapshotBlock
### Amazon Elastic Block Store (EBS) Snapshot
You can specify your EBS snapshot ID with the `ebs:` prefix.
```shell
$ trivy vm ebs:${your_ebs_snapshot_id}
```
!!! note
Public snapshots are not supported because the EBS direct APIs don't support that.
See [the AWS documentation][ebsapi-elements] for the detail.
#### Example
```shell
$ trivy vm --scanners vuln ebs:snap-0123456789abcdefg
```
If you want to scan an EBS Snapshot of non-default setting region, you can set any region via `--aws-region` option.
```shell
$ trivy vm --aws-region ap-northeast-1 ebs:ebs-0123456789abcdefg
```
The above command takes a while as it calls EBS API and fetches the EBS blocks.
If you want to scan the same snapshot several times, you can download the snapshot locally by using [coldsnap][coldsnap] maintained by AWS.
Then, Trivy can scan the local VM image file.
```shell
$ coldsnap download snap-0123456789abcdefg disk.img
$ trivy vm ./disk.img
```
#### Required Actions
- ebs:ListSnapshotBlocks
- ebs:GetSnapshotBlock
## Scanners
Trivy supports VM image scanning for
- Vulnerabilities
- Misconfigurations
- Secrets
- Licenses
### Vulnerabilities
It is enabled by default.
You can simply specify your VM image location.
It detects known vulnerabilities in your VM image.
See [here](../vulnerability/scanning.md) for the detail.
```
$ trivy vm [YOUR_VM_IMAGE]
```
### Misconfigurations
It is supported, but it is not useful in most cases.
As mentioned [here](../misconfiguration/scanning.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 config`.
```
$ trivy vm --scanners config [YOUR_VM_IMAGE]
```
### Secrets
It is enabled by default.
See [here](../secret/scanning.md) for the detail.
```shell
$ trivy vm [YOUR_VM_IMAGE]
```
!!! tip
The scanning could be faster if you enable only vulnerability scanning (`--scanners vuln`) because Trivy tries to download only necessary blocks for vulnerability detection.
### Licenses
It is disabled by default.
See [here](../licenses/scanning.md) for the detail.
```shell
$ trivy vm --scanners license [YOUR_VM_IMAGE]
```
## SBOM generation
Trivy can generate SBOM for VM images.
See [here](../sbom/index.md) for the detail.
## Supported Architectures
### Virtual machine images
@@ -117,5 +233,9 @@ Reference: [VMware Virtual Disk Format 1.1.pdf][vmdk]
| EXT2/3 | |
| ZFS | |
[aws]: ./aws.md
[vmdk]: https://www.vmware.com/app/vmdk/?src=vmdk
[aws]: ../vm/aws.md
[vmdk]: https://www.vmware.com/app/vmdk/?src=vmdk
[ebsapi-elements]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-accessing-snapshot.html#ebsapi-elements
[coldsnap]: https://github.com/awslabs/coldsnap

View File

@@ -1,83 +0,0 @@
# AWS EC2
Trivy can scan the following targets in AWS EC2.
- Amazon Machine Image (AMI)
- Elastic Block Store (EBS) Snapshot
## Amazon Machine Image (AMI)
You can specify your AMI ID with the `ami:` prefix.
```shell
$ trivy vm ami:${your_ami_id}
```
!!! note
AMIs in the marketplace are not supported because the EBS direct APIs don't support that.
See [the AWS documentation][ebsapi-elements] for the detail.
### Example
```shell
$ trivy vm --security-checks vuln ami:ami-0123456789abcdefg
```
!!! tip
The scanning could be faster if you enable only vulnerability scanning (`--security-checks vuln`) because Trivy tries to download only necessary blocks for vulnerability detection.
If you want to scan a AMI of non-default setting region, you can set any region via `--aws-region` option.
```shell
$ trivy vm --aws-region ap-northeast-1 ami:ami-0123456789abcdefg
```
### Required Actions
Some actions on EBS are also necessary since Trivy scans an EBS snapshot tied to the specified AMI under the hood.
- ec2:DescribeImages
- ebs:ListSnapshotBlocks
- ebs:GetSnapshotBlock
## Elastic Block Store (EBS) Snapshot
You can specify your EBS snapshot ID with the `ebs:` prefix.
```shell
$ trivy vm ebs:${your_ebs_snapshot_id}
```
!!! note
Public snapshots are not supported because the EBS direct APIs don't support that.
See [the AWS documentation][ebsapi-elements] for the detail.
### Example
```shell
$ trivy vm --security-checks vuln ebs:snap-0123456789abcdefg
```
!!! tip
The scanning could be faster if you enable only vulnerability scanning (`--security-checks vuln`) because Trivy tries to download only necessary blocks for vulnerability detection.
If you want to scan an EBS Snapshot of non-default setting region, you can set any region via `--aws-region` option.
```shell
$ trivy vm --aws-region ap-northeast-1 ebs:ebs-0123456789abcdefg
```
The above command takes a while as it calls EBS API and fetches the EBS blocks.
If you want to scan the same snapshot several times, you can download the snapshot locally by using [coldsnap][coldsnap] maintained by AWS.
Then, Trivy can scan the local VM image file.
```shell
$ coldsnap download snap-0123456789abcdefg disk.img
$ trivy vm ./disk.img
```
### Required Actions
- ebs:ListSnapshotBlocks
- ebs:GetSnapshotBlock
[ebsapi-elements]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-accessing-snapshot.html#ebsapi-elements
[coldsnap]: https://github.com/awslabs/coldsnap

View File

@@ -37,6 +37,7 @@
| Rust | [Open Source Vulnerabilities (crates.io)][rust-osv] | ✅ | - |
| .NET | [GitHub Advisory Database (NuGet)][dotnet-ghsa] | ✅ | - |
| C/C++ | [GitLab Advisories Community][gitlab] | ✅ | 1 month |
| Dart | [GitHub Advisory Database (Pub)][pub-ghsa] | ✅ | - |
| Elixir | [GitHub Advisory Database (Erlang)][erlang-ghsa] | ✅ | |
[^1]: Intentional delay between vulnerability disclosure and registration in the DB
@@ -79,6 +80,7 @@ The severity is from the selected data source. If the data source does not provi
[nodejs-ghsa]: https://github.com/advisories?query=ecosystem%3Anpm
[java-ghsa]: https://github.com/advisories?query=ecosystem%3Amaven
[dotnet-ghsa]: https://github.com/advisories?query=ecosystem%3Anuget
[pub-ghsa]: https://github.com/advisories?query=ecosystem%3Apub
[erlang-ghsa]: https://github.com/advisories?query=ecosystem%3Aerlang
[php]: https://github.com/FriendsOfPHP/security-advisories

View File

@@ -6,7 +6,7 @@
|----------|--------------------------------------------------------------------------------------------|:---------:|:----------:|:---------------:|:---------------:|------------------|:------------------------:|
| Ruby | Gemfile.lock | - | - | ✅ | ✅ | included | - |
| | gemspec | ✅ | ✅ | - | - | included | - |
| Python | Pipfile.lock | - | - | ✅ | ✅ | excluded | - |
| Python | Pipfile.lock | - | - | ✅ | ✅ | excluded | |
| | poetry.lock | - | - | ✅ | ✅ | excluded | - |
| | requirements.txt | - | - | ✅ | ✅ | included | - |
| | egg package[^1] | ✅ | ✅ | - | - | excluded | - |
@@ -28,6 +28,7 @@
| | Binaries built with [cargo-auditable](https://github.com/rust-secure-code/cargo-auditable) | ✅ | ✅ | - | - | excluded | - |
| C/C++ | conan.lock[^13] | - | - | ✅ | ✅ | excluded | - |
| Elixir | mix.lock[^13] | - | - | ✅ | ✅ | excluded | ✅ |
| Dart | pubspec.lock | ✅ | ✅ | - | - | included | - |
The path of these files does not matter.

View File

@@ -9,8 +9,8 @@ The unfixed/unfixable vulnerabilities mean that the patch has not yet been provi
| Red Hat Universal Base Image[^1] | 7, 8, 9 | Installed by yum/rpm | YES |
| Red Hat Enterprise Linux | 6, 7, 8 | Installed by yum/rpm | YES |
| CentOS | 6, 7, 8 | Installed by yum/rpm | YES |
| AlmaLinux | 8 | Installed by yum/rpm | NO |
| Rocky Linux | 8 | Installed by yum/rpm | NO |
| AlmaLinux | 8, 9 | Installed by yum/rpm | NO |
| Rocky Linux | 8, 9 | Installed by yum/rpm | NO |
| Oracle Linux | 5, 6, 7, 8 | Installed by yum/rpm | NO |
| CBL-Mariner | 1.0, 2.0 | Installed by yum/rpm | YES |
| Amazon Linux | 1, 2, 2022 | Installed by yum/rpm | NO |
@@ -21,5 +21,60 @@ The unfixed/unfixable vulnerabilities mean that the patch has not yet been provi
| Ubuntu | All versions supported by Canonical | Installed by apt/apt-get/dpkg | YES |
| Distroless[^2] | Any | Installed by apt/apt-get/dpkg | YES |
## Distributions
### CBL-Mariner
Trivy scans [CBL-Mariner][mariner].
#### Support
The following table provides an outline of the features Trivy offers.
| Version | Container image | Virtual machine | Distroless | Multi-arch | Unfixed support |
|---------|:---------------:|:---------------:|:----------:|:------------:|:---------------:|
| 1.0 | ✔ | ✔ | ✔ | amd64, arm64 | ✔ |
| 2.0 | ✔ | ✔ | ✔ | amd64, arm64 | ✔ |
### Examples
=== "image"
```
➜ trivy image mcr.microsoft.com/cbl-mariner/base/core:2.0
2022-07-27T14:48:20.355+0600 INFO Detected OS: cbl-mariner
2022-07-27T14:48:20.355+0600 INFO Detecting CBL-Mariner vulnerabilities...
2022-07-27T14:48:20.356+0600 INFO Number of language-specific files: 0
mcr.microsoft.com/cbl-mariner/base/core:2.0 (cbl-mariner 2.0.20220527)
Total: 33 (UNKNOWN: 0, LOW: 0, MEDIUM: 15, HIGH: 13, CRITICAL: 5)
```
=== "rootfs"
```
➜ docker run -it --rm --entrypoint bin/bash mcr.microsoft.com/cbl-mariner/base/core:2.0
root [ / ]# tdnf -y install ca-certificates
root [ / ]# # Install the latest Trivy
root [ / ]# trivy rootfs /
2022-07-27T09:30:06.815Z INFO Need to update DB
2022-07-27T09:30:06.815Z INFO DB Repository: ghcr.io/aquasecurity/trivy-db
2022-07-27T09:30:06.815Z INFO Downloading DB...
33.25 MiB / 33.25 MiB [------------------------------] 100.00% 4.20 MiB p/s 8.1s
2022-07-27T09:30:21.756Z INFO Vulnerability scanning is enabled
2022-07-27T09:30:21.756Z INFO Secret scanning is enabled
2022-07-27T09:30:21.756Z INFO If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2022-07-27T09:30:21.756Z INFO Please see also https://aquasecurity.github.io/trivy/v0.30.4/docs/secret/scanning/#recommendation for faster secret detection
2022-07-27T09:30:22.205Z INFO Detected OS: cbl-mariner
2022-07-27T09:30:22.205Z INFO Detecting CBL-Mariner vulnerabilities...
2022-07-27T09:30:22.205Z INFO Number of language-specific files: 0
40ba9a55397c (cbl-mariner 2.0.20220527)
=======================================
Total: 33 (UNKNOWN: 0, LOW: 0, MEDIUM: 15, HIGH: 13, CRITICAL: 5)
```
[^1]: https://developers.redhat.com/products/rhel/ubi
[^2]: https://github.com/GoogleContainerTools/distroless
### Data source
See [here][source].
[mariner]: https://github.com/microsoft/CBL-Mariner
[source]: data-source.md

View File

@@ -1,23 +0,0 @@
# Supported
## Container Runtime
- [Docker Engine](https://docs.docker.com/engine/)
- [Podman](../../advanced/container/podman.md)
- [containerd](../../advanced/container/containerd.md)
## Container Registry
- [Docker Registry HTTP API V2](https://docs.docker.com/registry/spec/api/)
- [OCI Distribution Specification](https://github.com/opencontainers/distribution-spec)
## Image Tar Formats
Trivy scans a tar image with the following format.
- [Docker Image Specification](https://github.com/moby/moby/tree/master/image/spec)
- [Moby Project](https://github.com/moby/moby/)
- [Buildah](https://github.com/containers/buildah)
- [Podman](https://github.com/containers/podman)
- [img](https://github.com/genuinetools/img)
- [Kaniko](https://github.com/GoogleContainerTools/kaniko)
## Image Layout
- [OCI Image Format Specification](https://github.com/opencontainers/image-spec)

View File

@@ -1,58 +0,0 @@
## CBL-Mariner
Trivy scans [CBL-Mariner][mariner].
### Support
The following table provides an outline of the features Trivy offers.
| Version | Container image | Virtual machine | Distroless | Multi-arch | Unfixed support |
|---------|:---------------:|:---------------:|:----------:|:------------:|:---------------:|
| 1.0 | ✔ | ✔ | ✔ | amd64, arm64 | ✔ |
| 2.0 | ✔ | ✔ | ✔ | amd64, arm64 | ✔ |
### Examples
=== "image"
```
➜ trivy image mcr.microsoft.com/cbl-mariner/base/core:2.0
2022-07-27T14:48:20.355+0600 INFO Detected OS: cbl-mariner
2022-07-27T14:48:20.355+0600 INFO Detecting CBL-Mariner vulnerabilities...
2022-07-27T14:48:20.356+0600 INFO Number of language-specific files: 0
mcr.microsoft.com/cbl-mariner/base/core:2.0 (cbl-mariner 2.0.20220527)
Total: 33 (UNKNOWN: 0, LOW: 0, MEDIUM: 15, HIGH: 13, CRITICAL: 5)
```
=== "fs"
```
➜ docker run -it --rm --entrypoint bin/bash mcr.microsoft.com/cbl-mariner/base/core:2.0
root [ / ]# tdnf -y install ca-certificates
...
root [ / ]# rpm -ivh https://github.com/aquasecurity/trivy/releases/download/v0.30.4/trivy_0.30.4_Linux-64bit.rpm
...
root [ / ]# trivy fs /
2022-07-27T09:30:06.815Z INFO Need to update DB
2022-07-27T09:30:06.815Z INFO DB Repository: ghcr.io/aquasecurity/trivy-db
2022-07-27T09:30:06.815Z INFO Downloading DB...
33.25 MiB / 33.25 MiB [------------------------------] 100.00% 4.20 MiB p/s 8.1s
2022-07-27T09:30:21.756Z INFO Vulnerability scanning is enabled
2022-07-27T09:30:21.756Z INFO Secret scanning is enabled
2022-07-27T09:30:21.756Z INFO If your scanning is slow, please try '--security-checks vuln' to disable secret scanning
2022-07-27T09:30:21.756Z INFO Please see also https://aquasecurity.github.io/trivy/v0.30.4/docs/secret/scanning/#recommendation for faster secret detection
2022-07-27T09:30:22.205Z INFO Detected OS: cbl-mariner
2022-07-27T09:30:22.205Z INFO Detecting CBL-Mariner vulnerabilities...
2022-07-27T09:30:22.205Z INFO Number of language-specific files: 0
40ba9a55397c (cbl-mariner 2.0.20220527)
Total: 33 (UNKNOWN: 0, LOW: 0, MEDIUM: 15, HIGH: 13, CRITICAL: 5)
```
### Data source
See [here][source].
[mariner]: https://github.com/microsoft/CBL-Mariner
[source]: detection/data-source.md

View File

@@ -43,3 +43,13 @@ $ trivy image --download-db-only
```
$ trivy image --db-repository registry.gitlab.com/gitlab-org/security-products/dependencies/trivy-db
```
## Java Vulnerability DB
The same options are also available for the Java index DB, which is used for scanning Java applications.
Skipping an update can be done by using the `--skip-java-db-update` option, while `--download-java-db-only` can be used to only download the Java index DB.
Downloading the Java index DB from an external OCI registry can be done by using the `--java-db-repository` option.
```
$ trivy image --java-db-repository registry.gitlab.com/gitlab-org/security-products/dependencies/trivy-java-db --download-java-db-only
```

View File

@@ -16,48 +16,6 @@ If your image contains lock files which are not maintained by you, you can skip
$ trivy image --skip-dirs /var/lib/gems/2.5.0/gems/fluent-plugin-detect-exceptions-0.0.13 --skip-dirs "/var/lib/gems/2.5.0/gems/http_parser.rb-0.6.0" quay.io/fluentd_elasticsearch/fluentd:v2.9.0
```
## Scan Image on a specific Architecture and OS
By default, Trivy loads an image on a "linux/amd64" machine.
To customise this, pass a `--platform` argument in the format OS/Architecture for the image:
```
$ trivy image --platform=os/architecture [YOUR_IMAGE_NAME]
```
For example:
```
$ trivy image --platform=linux/arm alpine:3.16.1
```
<details>
<summary>Result</summary>
```
2022-10-25T21:00:50.972+0300 INFO Vulnerability scanning is enabled
2022-10-25T21:00:50.972+0300 INFO Secret scanning is enabled
2022-10-25T21:00:50.972+0300 INFO If your scanning is slow, please try '--security-checks vuln' to disable secret scanning
2022-10-25T21:00:50.972+0300 INFO Please see also https://aquasecurity.github.io/trivy/dev/docs/secret/scanning/#recommendation for faster secret detection
2022-10-25T21:00:56.190+0300 INFO Detected OS: alpine
2022-10-25T21:00:56.190+0300 INFO Detecting Alpine vulnerabilities...
2022-10-25T21:00:56.191+0300 INFO Number of language-specific files: 0
alpine:3.16.1 (alpine 3.16.1)
=============================
Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 1)
┌─────────┬────────────────┬──────────┬───────────────────┬───────────────┬─────────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Installed Version │ Fixed Version │ Title │
├─────────┼────────────────┼──────────┼───────────────────┼───────────────┼─────────────────────────────────────────────────────────────┤
│ zlib │ CVE-2022-37434 │ CRITICAL │ 1.2.12-r1 │ 1.2.12-r2 │ zlib: heap-based buffer over-read and overflow in inflate() │
│ │ │ │ │ │ in inflate.c via a... │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2022-37434 │
└─────────┴────────────────┴──────────┴───────────────────┴───────────────┴─────────────────────────────────────────────────────────────┘
```
</details>
## File patterns
When a directory is given as an input, Trivy will recursively look for and test all files based on file patterns.
The default file patterns are [here](../../misconfiguration/custom/index.md).
@@ -110,6 +68,57 @@ $ trivy image --exit-code 0 --severity MEDIUM,HIGH ruby:2.4.0
$ trivy image --exit-code 1 --severity CRITICAL ruby:2.4.0
```
## Exit on EOL
Sometimes you may surprisingly get 0 vulnerabilities in an old image:
- Enabling `--ignore-unfixed` option while all packages have no fixed versions.
- Scanning a rather outdated OS (e.g. Ubuntu 10.04).
An OS at the end of service/life (EOL) usually gets into this situation, which is definitely full of vulnerabilities.
`--exit-on-eol` can fail scanning on EOL OS with a non-zero code.
This flag is available with the following targets.
- Container images (`trivy image`)
- Virtual machine images (`trivy vm`)
- SBOM (`trivy sbom`)
- Root filesystem (`trivy rootfs`)
```
$ trivy image --exit-on-eol 1 alpine:3.10
```
<details>
<summary>Result</summary>
```
2023-03-01T11:07:15.455+0200 INFO Vulnerability scanning is enabled
...
2023-03-01T11:07:17.938+0200 WARN This OS version is no longer supported by the distribution: alpine 3.10.9
2023-03-01T11:07:17.938+0200 WARN The vulnerability detection may be insufficient because security updates are not provided
alpine:3.10 (alpine 3.10.9)
===========================
Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 1)
┌───────────┬────────────────┬──────────┬───────────────────┬───────────────┬─────────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Installed Version │ Fixed Version │ Title │
├───────────┼────────────────┼──────────┼───────────────────┼───────────────┼─────────────────────────────────────────────────────────────┤
│ apk-tools │ CVE-2021-36159 │ CRITICAL │ 2.10.6-r0 │ 2.10.7-r0 │ libfetch before 2021-07-26, as used in apk-tools, xbps, and │
│ │ │ │ │ │ other products, mishandles... │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2021-36159 │
└───────────┴────────────────┴──────────┴───────────────────┴───────────────┴─────────────────────────────────────────────────────────────┘
2023-03-01T11:07:17.941+0200 ERROR Detected EOL OS: alpine 3.10.9
```
</details>
This option is useful for CI/CD.
The following example will fail when a critical vulnerability is found or the OS is EOSL:
```
$ trivy image --exit-code 1 --exit-on-eol 1 --severity CRITICAL alpine:3.16.3
```
## Reset
The `--reset` option removes all caches and database.
After this, it takes a long time as the vulnerability database needs to be rebuilt locally.

View File

@@ -19,10 +19,23 @@ This flag is only available with the `--format table` flag.
The following packages/languages are currently supported:
- OS packages (apk, dpkg and rpm)
- Node.js (package-lock.json and yarn.lock)
- Nuget lock files (packages.lock.json)
- Rust Binaries built with [cargo-auditable][cargo-auditable]
- OS packages
- apk
- dpkg
- rpm
- Node.js
- npm: package-lock.json
- yarn: yarn.lock
- .NET
- NuGet: packages.lock.json
- Python
- Poetry: poetry.lock
- Ruby
- Bundler: Gemfile.lock
- Rust
- Binaries built with [cargo-auditable][cargo-auditable]
- Go
- Modules: go.mod
This tree is the reverse of the npm list command.
However, if you want to resolve a vulnerability in a particular indirect dependency, the reversed tree is useful to know where that dependency comes from and identify which package you actually need to update.
@@ -47,8 +60,8 @@ Total: 2 (HIGH: 1, CRITICAL: 1)
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2020-28469 │
└──────────────────┴────────────────┴──────────┴───────────────────┴───────────────┴────────────────────────────────────────────────────────────┘
Dependency Origin Tree
======================
Dependency Origin Tree (Reversed)
=================================
package-lock.json
├── follow-redirects@1.14.6, (HIGH: 1, CRITICAL: 0)
│ └── axios@0.21.4

View File

@@ -4,10 +4,10 @@
Trivy supports two types of Go scanning, Go Modules and binaries built by Go.
The following table provides an outline of the features Trivy offers.
| Artifact | Offline[^1] | Dev dependencies |
|----------|:-----------:|:-----------------|
| Modules | ✓ | Include |
| Binaries | ✓ | Exclude |
| Artifact | Offline[^1] | Dev dependencies | License | Dependency graph |
|----------|:-----------:|:-----------------|:-------:|:----------------:|
| Modules | ✓ | Include | ✓[^2] | ✓[^2] |
| Binaries | ✓ | Exclude | - | - |
!!! note
Trivy scans only dependencies of the Go project.
@@ -17,10 +17,10 @@ The following table provides an outline of the features Trivy offers.
### Go Modules
Depending on Go versions, the required files are different.
| Version | Required files | Offline | License |
|---------|:--------------:|:-------:|:-------:|
| \>=1.17 | go.mod | ✓ | - |
| <1.17 | go.mod, go.sum | ✓ | - |
| Version | Required files | Offline |
|---------|:--------------:|:-------:|
| \>=1.17 | go.mod | ✓ |
| <1.17 | go.mod, go.sum | ✓ |
In Go 1.17+ projects, Trivy uses `go.mod` for direct/indirect dependencies.
On the other hand, it uses `go.mod` for direct dependencies and `go.sum` for indirect dependencies in Go 1.16 or less.
@@ -49,6 +49,10 @@ If you want to have better detection, please consider updating the Go version in
$ go mod tidy -go=1.18
```
To identify licenses and dependency relationships, you need to download modules to local cache beforehand,
such as `go mod download`, `go mod tidy`, etc.
Trivy traverses `$GOPATH/pkg/mod` and collect those extra information.
### Go binaries
Trivy scans binaries built by Go.
If there is a Go binary in your container image, Trivy automatically finds and scans it.
@@ -59,4 +63,5 @@ Also, you can scan your local binaries.
$ trivy fs ./your_binary
```
[^1]: It doesn't require the Internet access.
[^1]: It doesn't require the Internet access.
[^2]: Need to download modules to local cache beforehand

View File

@@ -0,0 +1,60 @@
# Java
Trivy supports three types of Java scanning: `JAR/WAR/PAR/EAR`, `pom.xml` and `*gradle.lockfile` files.
The following table provides an outline of the features Trivy offers.
| Artifact | Internet access | Dev dependencies |
|------------------|:---------------------:|:-----------------|
| JAR/WAR/PAR/EAR | Trivy Java DB | Include |
| pom.xml | Maven repository [^1] | Exclude |
| *gradle.lockfile | - | Exclude |
These may be enabled or disabled depending on the target.
See [here](../detection/language.md) for the detail.
## JAR/WAR/PAR/EAR
To find information about your JAR[^2] file, Trivy parses `pom.properties` and `MANIFEST.MF` files in your JAR[^2] file and takes required properties[^3].
If those files don't exist or don't contain enough information - Trivy will try to find this JAR[^2] file in [trivy-java-db](https://github.com/aquasecurity/trivy-java-db).
The Java DB will be automatically downloaded/updated when any JAR[^2] file is found.
It is stored in [the cache directory](../examples/cache.md#cache-directory).
!!! warning "EXPERIMENTAL"
Finding JARs in `trivy-java-db` is an experimental function.
Base JAR[^2] may contain inner JARs[^2] within itself.
To find information about these JARs[^2], the same logic is used as for the base JAR[^2].
## pom.xml
Trivy parses your `pom.xml` file and tries to find files with dependencies from these local locations.
- project directory[^4]
- relativePath field[^5]
- local repository directory[^6].
If your machine doesn't have the necessary files - Trivy tries to find the information about these dependencies in the [maven repository](https://repo.maven.apache.org/maven2/).
!!! Note
Trivy only takes information about packages. We don't take a list of vulnerabilities for packages from the `maven repository`.
Information about data sources for Java you can see [here](../detection/data-source.md).
You can disable connecting to the maven repository with the `--offline-scan` flag.
The `--offline-scan` flag does not affect the Trivy database.
The vulnerability database will be downloaded anyway.
!!! Warning
Trivy may skip some dependencies (that were not found on your local machine) when the `--offline-scan` flag is passed.
## Gradle.lock
`gradle.lock` files contain all necessary information about used dependencies.
Trivy simply parses the file, extract dependencies, and finds vulnerabilities for them.
It doesn't require the internet access.
[^1]: https://github.com/aquasecurity/trivy-java-db
[^1]: Uses maven repository to get information about dependencies. Internet access required.
[^2]: It means `*.jar`, `*.war`, `*.par` and `*.ear` file
[^3]: `ArtifactID`, `GroupID` and `Version`
[^4]: e.g. when parent pom.xml file has `../pom.xml` path
[^5]: When you use dependency path in `relativePath` field in pom.xml file
[^6]: `/Users/<username>/.m2/repository` (for Linux and Mac) and `C:/Users/<username>/.m2/repository` (for Windows) by default

View File

@@ -0,0 +1,55 @@
# Python
Trivy supports three types of Python package managers: `pip`, `Pipenv` and `Poetry`.
The following table provides an outline of the features Trivy offers.
| Package Manager | File | Transitive dependencies | Dev dependencies | Dependency graph | Position | License |
|-----------------|------------------|:-----------------------:|:----------------:|:----------------:|:--------:|:-------:|
| pip | requirements.txt | - | Include | - | - | - |
| Pipenv | Pipfile.lock | ✅ | Include | - | ✅ | - |
| Poetry | poetry.lock | ✅ | Exclude | ✅ | | - |
In addition, Trivy supports two formats of Python packages: `egg` and `wheel`.
| Packaging | License |
|-----------|:-------:|
| Egg | ✅ |
| Wheel | ✅ |
These may be enabled or disabled depending on the target.
See [here](../detection/language.md) for the detail.
## Package managers
Trivy parses your files generated by package managers in filesystem/repository scanning.
### pip
`requirements.txt` files contain only the direct dependencies and not contain the transitive dependencies.
Therefore, Trivy scans only for the direct dependencies with `requirements.txt`.
Also, `requirements.txt` files don't contain information about dependencies used for development.
Trivy could detect vulnerabilities on the development packages, which not affect your production environment.
License detection is not supported for `pip`.
### Pipenv
Trivy parses `Pipfile.lock`.
`Pipfile.lock` files don't contain information about dependencies used for development.
Trivy could detect vulnerabilities on the development packages, which not affect your production environment.
License detection is not supported for `Pipenv`.
### Poetry
Trivy uses `poetry.lock` to identify dependencies and find vulnerabilities.
To build the correct dependency graph, `pyproject.toml` also needs to be present next to `poetry.lock`.
License detection is not supported for `Poetry`.
## Packaging
Trivy parses the manifest files of installed packages in container image scanning and so on.
See [here](https://packaging.python.org/en/latest/discussions/wheel-vs-egg/) for the detail.
### Egg
Trivy looks for `*.egg-info`, `*.egg-info/PKG-INFO`, `*.egg` and `EGG-INFO/PKG-INFO` to identify Python packages.
### Wheel
Trivy looks for `.dist-info/META-DATA` to identify Python packages.

View File

@@ -0,0 +1,12 @@
# Vulnerability Scanning
This section describes the details of vulnerability scanning.
Trivy detects known vulnerabilities according to the versions of installed packages.
The following packages are supported.
- [OS packages](detection/os.md)
- [Language-specific packages](detection/language.md)
Trivy downloads [the vulnerabillity database](https://github.com/aquasecurity/trivy-db) every 6 hours.
The data source is listed [here](detection/data-source.md).

View File

@@ -1,103 +0,0 @@
# Filesystem
Scan a local project including language-specific files.
```bash
$ trivy fs /path/to/project
```
## Standalone mode
### Local Project
Trivy will look for vulnerabilities based on lock files such as Gemfile.lock and package-lock.json.
```
$ trivy fs ~/src/github.com/aquasecurity/trivy-ci-test
```
<details>
<summary>Result</summary>
```
2020-06-01T17:06:58.652+0300 WARN OS is not detected and vulnerabilities in OS packages are not detected.
2020-06-01T17:06:58.652+0300 INFO Detecting pipenv vulnerabilities...
2020-06-01T17:06:58.691+0300 INFO Detecting cargo vulnerabilities...
Pipfile.lock
============
Total: 10 (UNKNOWN: 2, LOW: 0, MEDIUM: 6, HIGH: 2, CRITICAL: 0)
+---------------------+------------------+----------+-------------------+------------------------+------------------------------------+
| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |
+---------------------+------------------+----------+-------------------+------------------------+------------------------------------+
| django | CVE-2020-7471 | HIGH | 2.0.9 | 3.0.3, 2.2.10, 1.11.28 | django: potential |
| | | | | | SQL injection via |
| | | | | | StringAgg(delimiter) |
+ +------------------+----------+ +------------------------+------------------------------------+
| | CVE-2019-19844 | MEDIUM | | 3.0.1, 2.2.9, 1.11.27 | Django: crafted email address |
| | | | | | allows account takeover |
+ +------------------+ + +------------------------+------------------------------------+
| | CVE-2019-3498 | | | 2.1.5, 2.0.10, 1.11.18 | python-django: Content |
| | | | | | spoofing via URL path in |
| | | | | | default 404 page |
+ +------------------+ + +------------------------+------------------------------------+
| | CVE-2019-6975 | | | 2.1.6, 2.0.11, 1.11.19 | python-django: |
| | | | | | memory exhaustion in |
| | | | | | django.utils.numberformat.format() |
+---------------------+------------------+----------+-------------------+------------------------+------------------------------------+
...
```
</details>
### Single file
It's also possible to scan a single file.
```
$ trivy fs ~/src/github.com/aquasecurity/trivy-ci-test/Pipfile.lock
```
## Client/Server mode
You must launch Trivy server in advance.
```sh
$ trivy server
```
Then, Trivy works as a client if you specify the `--server` option.
```sh
$ trivy fs --server http://localhost:4954 --severity CRITICAL ./integration/testdata/fixtures/fs/pom/
```
<details>
<summary>Result</summary>
```
pom.xml (pom)
=============
Total: 4 (CRITICAL: 4)
+---------------------------------------------+------------------+----------+-------------------+--------------------------------+---------------------------------------+
| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |
+---------------------------------------------+------------------+----------+-------------------+--------------------------------+---------------------------------------+
| com.fasterxml.jackson.core:jackson-databind | CVE-2017-17485 | CRITICAL | 2.9.1 | 2.8.11, 2.9.4 | jackson-databind: Unsafe |
| | | | | | deserialization due to |
| | | | | | incomplete black list (incomplete |
| | | | | | fix for CVE-2017-15095)... |
| | | | | | -->avd.aquasec.com/nvd/cve-2017-17485 |
+ +------------------+ + +--------------------------------+---------------------------------------+
| | CVE-2020-9546 | | | 2.7.9.7, 2.8.11.6, 2.9.10.4 | jackson-databind: Serialization |
| | | | | | gadgets in shaded-hikari-config |
| | | | | | -->avd.aquasec.com/nvd/cve-2020-9546 |
+ +------------------+ + + +---------------------------------------+
| | CVE-2020-9547 | | | | jackson-databind: Serialization |
| | | | | | gadgets in ibatis-sqlmap |
| | | | | | -->avd.aquasec.com/nvd/cve-2020-9547 |
+ +------------------+ + + +---------------------------------------+
| | CVE-2020-9548 | | | | jackson-databind: Serialization |
| | | | | | gadgets in anteros-core |
| | | | | | -->avd.aquasec.com/nvd/cve-2020-9548 |
+---------------------------------------------+------------------+----------+-------------------+--------------------------------+---------------------------------------+
```
</details>

View File

@@ -1,90 +0,0 @@
# Image
## Container Images
Simply specify an image name (and a tag).
```
$ trivy image [YOUR_IMAGE_NAME]
```
For example:
```
$ trivy image python:3.4-alpine
```
<details>
<summary>Result</summary>
```
2019-05-16T01:20:43.180+0900 INFO Updating vulnerability database...
2019-05-16T01:20:53.029+0900 INFO Detecting Alpine vulnerabilities...
python:3.4-alpine3.9 (alpine 3.9.2)
===================================
Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 1, HIGH: 0, CRITICAL: 0)
+---------+------------------+----------+-------------------+---------------+--------------------------------+
| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |
+---------+------------------+----------+-------------------+---------------+--------------------------------+
| openssl | CVE-2019-1543 | MEDIUM | 1.1.1a-r1 | 1.1.1b-r1 | openssl: ChaCha20-Poly1305 |
| | | | | | with long nonces |
+---------+------------------+----------+-------------------+---------------+--------------------------------+
```
</details>
## Tar Files
```
$ docker pull ruby:3.1-alpine3.15
$ docker save ruby:3.1-alpine3.15 -o ruby-3.1.tar
$ trivy image --input ruby-3.1.tar
```
<details>
<summary>Result</summary>
```
2022-02-03T10:08:19.127Z INFO Detected OS: alpine
2022-02-03T10:08:19.127Z WARN This OS version is not on the EOL list: alpine 3.15
2022-02-03T10:08:19.127Z INFO Detecting Alpine vulnerabilities...
2022-02-03T10:08:19.127Z INFO Number of language-specific files: 2
2022-02-03T10:08:19.127Z INFO Detecting gemspec vulnerabilities...
2022-02-03T10:08:19.128Z INFO Detecting node-pkg vulnerabilities...
2022-02-03T10:08:19.128Z WARN This OS version is no longer supported by the distribution: alpine 3.15.0
2022-02-03T10:08:19.128Z WARN The vulnerability detection may be insufficient because security updates are not provided
ruby-3.1.tar (alpine 3.15.0)
============================
Total: 3 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 3, CRITICAL: 0)
+----------+------------------+----------+-------------------+---------------+---------------------------------------+
| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |
+----------+------------------+----------+-------------------+---------------+---------------------------------------+
| gmp | CVE-2021-43618 | HIGH | 6.2.1-r0 | 6.2.1-r1 | gmp: Integer overflow and resultant |
| | | | | | buffer overflow via crafted input |
| | | | | | -->avd.aquasec.com/nvd/cve-2021-43618 |
+----------+ + + + + +
| gmp-dev | | | | | |
| | | | | | |
| | | | | | |
+----------+ + + + + +
| libgmpxx | | | | | |
| | | | | | |
| | | | | | |
+----------+------------------+----------+-------------------+---------------+---------------------------------------+
Node.js (node-pkg)
==================
Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)
Ruby (gemspec)
==============
Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)
```
</details>

View File

@@ -1,9 +0,0 @@
# Vulnerability Scanning
Trivy scans [Container Images][image], [Rootfs][rootfs], [Filesystem][fs], [Virtual Machine Image][vm] and [Git Repositories][repo] to detect vulnerabilities.
[image]: image.md
[rootfs]: rootfs.md
[fs]: filesystem.md
[repo]: git-repository.md
[vm]: ../../vm/index.md

View File

@@ -1,103 +0,0 @@
# Rootfs
Scan a root filesystem (such as a host machine, a virtual machine image, or an unpacked container image filesystem).
```bash
$ trivy rootfs /path/to/rootfs
```
## Standalone mode
### From Inside Containers
Scan your container from inside the container.
```bash
$ docker run --rm -it alpine:3.11
/ # curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
/ # trivy rootfs /
```
<details>
<summary>Result</summary>
```
2021-03-08T05:22:26.378Z INFO Need to update DB
2021-03-08T05:22:26.380Z INFO Downloading DB...
20.37 MiB / 20.37 MiB [-------------------------------------------------------------------------------------------------------------------------------------] 100.00% 8.24 MiB p/s 2s
2021-03-08T05:22:30.134Z INFO Detecting Alpine vulnerabilities...
2021-03-08T05:22:30.138Z INFO Trivy skips scanning programming language libraries because no supported file was detected
313430f09696 (alpine 3.11.7)
============================
Total: 6 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 6, CRITICAL: 0)
+--------------+------------------+----------+-------------------+---------------+---------------------------------------+
| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |
+--------------+------------------+----------+-------------------+---------------+---------------------------------------+
| libcrypto1.1 | CVE-2021-23839 | HIGH | 1.1.1i-r0 | 1.1.1j-r0 | openssl: incorrect SSLv2 |
| | | | | | rollback protection |
| | | | | | -->avd.aquasec.com/nvd/cve-2021-23839 |
+ +------------------+ + + +---------------------------------------+
| | CVE-2021-23840 | | | | openssl: integer |
| | | | | | overflow in CipherUpdate |
| | | | | | -->avd.aquasec.com/nvd/cve-2021-23840 |
+ +------------------+ + + +---------------------------------------+
| | CVE-2021-23841 | | | | openssl: NULL pointer dereference |
| | | | | | in X509_issuer_and_serial_hash() |
| | | | | | -->avd.aquasec.com/nvd/cve-2021-23841 |
+--------------+------------------+ + + +---------------------------------------+
| libssl1.1 | CVE-2021-23839 | | | | openssl: incorrect SSLv2 |
| | | | | | rollback protection |
| | | | | | -->avd.aquasec.com/nvd/cve-2021-23839 |
+ +------------------+ + + +---------------------------------------+
| | CVE-2021-23840 | | | | openssl: integer |
| | | | | | overflow in CipherUpdate |
| | | | | | -->avd.aquasec.com/nvd/cve-2021-23840 |
+ +------------------+ + + +---------------------------------------+
| | CVE-2021-23841 | | | | openssl: NULL pointer dereference |
| | | | | | in X509_issuer_and_serial_hash() |
| | | | | | -->avd.aquasec.com/nvd/cve-2021-23841 |
+--------------+------------------+----------+-------------------+---------------+---------------------------------------+
```
</details>
## Client/Server mode
You must launch Trivy server in advance.
```sh
$ trivy server
```
Then, Trivy works as a client if you specify the `--server` option.
```sh
$ trivy rootfs --server http://localhost:4954 --severity CRITICAL /tmp/rootfs
```
<details>
<summary>Result</summary>
```
/tmp/rootfs (alpine 3.10.2)
Total: 1 (CRITICAL: 1)
┌───────────┬────────────────┬──────────┬───────────────────┬───────────────┬─────────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Installed Version │ Fixed Version │ Title │
├───────────┼────────────────┼──────────┼───────────────────┼───────────────┼─────────────────────────────────────────────────────────────┤
│ apk-tools │ CVE-2021-36159 │ CRITICAL │ 2.10.4-r2 │ 2.10.7-r0 │ libfetch before 2021-07-26, as used in apk-tools, xbps, and │
│ │ │ │ │ │ other products, mishandles... │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2021-36159 │
└───────────┴────────────────┴──────────┴───────────────────┴───────────────┴─────────────────────────────────────────────────────────────┘
```
</details>
## Other Examples
- [Embed in Dockerfile][embedding]
- [Unpacked container image filesystem][unpacked]
[embedding]: ../../advanced/container/embed-in-dockerfile.md
[unpacked]: ../../advanced/container/unpacked-filesystem.md

View File

@@ -1,9 +1,9 @@
# Ecosystem
Trivy is already integrated into many popular tools and applications, so that you can easily add security to your workflow.
Trivy is integrated into many popular tools and applications, so that you can easily add security to your workflow.
In this section you will find an aggregation of the different integrations. Integrations are listed as either "official" or "community". Official integrations are developed by the core Trivy team and supported by it. Community integrations are integrations developed by the community, and collected here for your convenience. For support or questions about community integrations, please contact the original developers.
👈 Choose a category from the side menu to browse integrations.
👈 Please use the side-navigation on the left in order to browse the different topics.
## Add missing integration

View File

@@ -0,0 +1,6 @@
# Security Management
## SonarQube (Community)
A Trivy plugin that converts JSON report to SonarQube [generic issues format](https://docs.sonarqube.org/9.6/analyzing-source-code/importing-external-issues/generic-issue-import-format/).
👉 Get it at: <https://github.com/umax/trivy-plugin-sonarqube>

View File

@@ -1,6 +1,10 @@
# CLI Installation
# Installing Trivy
## RHEL/CentOS
In this section you will find an aggregation of the different ways to install Trivy. installations are listed as either "official" or "community". Official integrations are developed by the core Trivy team and supported by it. Community integrations are integrations developed by the community, and collected here for your convenience. For support or questions about community integrations, please contact the original developers.
## Install using Package Manager
### RHEL/CentOS (Official)
=== "Repository"
Add repository setting to `/etc/yum.repos.d`.
@@ -24,7 +28,7 @@
rpm -ivh https://github.com/aquasecurity/trivy/releases/download/{{ git.tag }}/trivy_{{ git.tag[1:] }}_Linux-64bit.rpm
```
## Debian/Ubuntu
### Debian/Ubuntu (Official)
=== "Repository"
Add repository setting to `/etc/apt/sources.list.d`.
@@ -44,43 +48,47 @@
sudo dpkg -i trivy_{{ git.tag[1:] }}_Linux-64bit.deb
```
## Arch Linux
### Homebrew (Official)
Package trivy can be installed from the Arch Community Package Manager.
```bash
pacman -S trivy
```
## Homebrew
You can use homebrew on macOS and Linux.
Homebrew for MacOS and Linux.
```bash
brew install trivy
```
## MacPorts
### Arch Linux (Community)
You can also install `trivy` via [MacPorts](https://www.macports.org) on macOS:
Arch Community Package Manager.
```bash
pacman -S trivy
```
References:
- <https://archlinux.org/packages/community/x86_64/trivy/>
- <https://github.com/archlinux/svntogit-community/blob/packages/trivy/trunk/PKGBUILD>
### MacPorts (Community)
[MacPorts](https://www.macports.org) for MacOS.
```bash
sudo port install trivy
```
More info [here](https://ports.macports.org/port/trivy/).
References:
- <https://ports.macports.org/port/trivy/details/>
## Nix/NixOS
### Nix/NixOS (Community)
Direct issues installing `trivy` via `nix` through the channels mentioned [here](https://nixos.wiki/wiki/Support)
Nix package manager for Linux and MacOS.
You can use `nix` on Linux or macOS and on other platforms unofficially.
=== "Command line"
`nix-env --install -A nixpkgs.trivy`
Or through your configuration as usual
NixOS:
=== "Configuration"
```nix
# your other config ...
@@ -90,7 +98,7 @@ NixOS:
];
```
home-manager:
=== "Home Manager"
```nix
# your other config ...
@@ -100,165 +108,51 @@ home-manager:
];
```
## Install Script
References:
- <https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/admin/trivy/default.nix>
This script downloads Trivy binary based on your OS and architecture.
## Install from GitHub Release (Official)
### Download Binary
1. Download the file for your operating system/architecture from [GitHub Release assets](https://github.com/aquasecurity/trivy/releases/tag/{{ git.tag }}) (`curl -LO https://url.to/trivy.tar.gz`).
2. Unpack the downloaded archive (`tar -xzf ./trivy.tar.gz`).
3. Put the binary somewhere in your `$PATH` (e.g `mv ./trivy /usr/local/bin/`).
4. Make sure the binary has execution bit turned on (`chmod +x ./trivy`).
### Install Script
The process above can be automated by the following script:
```bash
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin {{ git.tag }}
```
## Binary
Download the archive file for your operating system/architecture from [here](https://github.com/aquasecurity/trivy/releases/tag/{{ git.tag }}).
Unpack the archive, and put the binary somewhere in your `$PATH` (on UNIX-y systems, /usr/local/bin or the like).
Make sure it has execution bits turned on.
## From source
### Install from source
```bash
mkdir -p $GOPATH/src/github.com/aquasecurity
cd $GOPATH/src/github.com/aquasecurity
git clone --depth 1 --branch {{ git.tag }} https://github.com/aquasecurity/trivy
cd trivy/cmd/trivy/
export GO111MODULE=on
cd trivy
go install
```
## Docker
## Use container image
### Docker Hub
Replace [YOUR_CACHE_DIR] with the cache directory on your machine.
```bash
docker pull aquasec/trivy:{{ git.tag[1:] }}
```
1. Pull Trivy image (`docker pull aquasec/trivy:{{ git.tag[1:] }}`)
2. It is advisable to mount a consistent [cache dir](https://aquasecurity.github.io/trivy/{{ git.tag }}/docs/vulnerability/examples/cache/) on the host into the Trivy container.
3. For scanning container images with Trivy, mount `docker.sock` from the host into the Trivy container.
Example:
=== "Linux"
``` bash
docker run --rm -v [YOUR_CACHE_DIR]:/root/.cache/ aquasec/trivy:{{ git.tag[1:] }} image [YOUR_IMAGE_NAME]
```
=== "macOS"
``` bash
docker run --rm -v $HOME/Library/Caches:/root/.cache/ aquasec/trivy:{{ git.tag[1:] }} image [YOUR_IMAGE_NAME]
```
If you would like to scan the image on your host machine, you need to mount `docker.sock`.
```bash
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
-v $HOME/Library/Caches:/root/.cache/ aquasec/trivy:{{ git.tag[1:] }} image python:3.4-alpine
``` bash
docker run -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/Library/Caches:/root/.cache/ aquasec/trivy:{{ git.tag[1:] }} image python:3.4-alpine
```
Please re-pull latest `aquasec/trivy` if an error occurred.
<details>
<summary>Result</summary>
```bash
2019-05-16T01:20:43.180+0900 INFO Updating vulnerability database...
2019-05-16T01:20:53.029+0900 INFO Detecting Alpine vulnerabilities...
python:3.4-alpine3.9 (alpine 3.9.2)
===================================
Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 1, HIGH: 0, CRITICAL: 0)
+---------+------------------+----------+-------------------+---------------+--------------------------------+
| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |
+---------+------------------+----------+-------------------+---------------+--------------------------------+
| openssl | CVE-2019-1543 | MEDIUM | 1.1.1a-r1 | 1.1.1b-r1 | openssl: ChaCha20-Poly1305 |
| | | | | | with long nonces |
+---------+------------------+----------+-------------------+---------------+--------------------------------+
```
</details>
### GitHub Container Registry
The same image is hosted on [GitHub Container Registry][registry] as well.
```bash
docker pull ghcr.io/aquasecurity/trivy:{{ git.tag[1:] }}
```
### Amazon ECR Public
The same image is hosted on [Amazon ECR Public][ecr] as well.
```bash
docker pull public.ecr.aws/aquasecurity/trivy:{{ git.tag[1:] }}
```
### AWS private registry permissions
You may need to grant permissions to allow trivy to pull images from private registry (AWS ECR).
It depends on how you want to provide AWS Role to trivy.
- [IAM Role Service account](https://github.com/aws/amazon-eks-pod-identity-webhook)
- [Kube2iam](https://github.com/jtblin/kube2iam) or [Kiam](https://github.com/uswitch/kiam)
#### IAM Role Service account
Add the AWS role in trivy's service account annotations:
```yaml
trivy:
serviceAccount:
annotations: {}
# eks.amazonaws.com/role-arn: arn:aws:iam::ACCOUNT_ID:role/IAM_ROLE_NAME
```
#### Kube2iam or Kiam
Add the AWS role to pod's annotations:
```yaml
podAnnotations: {}
## kube2iam/kiam annotation
# iam.amazonaws.com/role: arn:aws:iam::ACCOUNT_ID:role/IAM_ROLE_NAME
```
> **Tip**: List all releases using `helm list`.
Registry | Repository | Link | Supportability
Docker Hub | `docker.io/aquasec/trivy` | https://hub.docker.com/r/aquasec/trivy | Official
GitHub Container Registry (GHCR) | `ghcr.io/aquasecurity/trivy` | https://github.com/orgs/aquasecurity/packages/container/package/trivy | Official
AWS Elastic Container Registry (ECR) | `public.ecr.aws/aquasecurity/trivy` | https://gallery.ecr.aws/aquasecurity/trivy | Official
## Other Tools to use and deploy Trivy
For additional tools and ways to install and use Trivy in different environments such as in Docker Desktop and Kubernetes clusters, see the links in the [Ecosystem section](../ecosystem/index.md).
[ecr]: https://gallery.ecr.aws/aquasecurity/trivy
[registry]: https://github.com/orgs/aquasecurity/packages/container/package/trivy
[helm]: https://github.com/aquasecurity/trivy/tree/{{ git.tag }}/helm/trivy
[slack]: https://slack.aquasec.com
[operator-docs]: https://aquasecurity.github.io/trivy-operator/latest/
[vuln]: ./docs/vulnerability/scanning/index.md
[misconf]: ./docs/misconfiguration/scanning.md
[kubernetesoperator]: ./docs/kubernetes/operator/index.md
[container]: ./docs/vulnerability/scanning/image.md
[rootfs]: ./docs/vulnerability/scanning/rootfs.md
[filesystem]: ./docs/vulnerability/scanning/filesystem.md
[repo]: ./docs/vulnerability/scanning/git-repository.md
[kubernetes]: ./docs/kubernetes/cli/scanning.md
[standalone]: ./docs/references/modes/standalone.md
[client-server]: ./docs/references/modes/client-server.md
[integrations]: ./tutorials/integrations/index.md
[os]: ./docs/vulnerability/detection/os.md
[lang]: ./docs/vulnerability/detection/language.md
[builtin]: ./docs/misconfiguration/policy/builtin.md
[quickstart]: ./getting-started/quickstart.md
[podman]: ./docs/advanced/container/podman.md
[sbom]: ./docs/sbom/index.md
[oci]: https://github.com/opencontainers/image-spec
[license]: https://github.com/aquasecurity/trivy/blob/main/LICENSE
For additional tools and ways to install and use Trivy in different environments such as in IDE, Kubernetes or CI/CD, see [Ecosystem section](../ecosystem/index.md).

View File

@@ -10,9 +10,9 @@ hide:
- You are currently in the [Getting Started] section where you can find general information and help with first steps.
- In the [Tutorials] section you can find step-by-step guides that help you accomplish specific tasks.
- In the [CLI] section you will find the complete reference documentation for all of the different features and settings that Trivy has to offer.
- In the [Ecosystem] section you will find how Trivy works together with other tools and applications that you might already use.
- In the [Contributing] section you will find instructions about developing Trivy, and contribution guidelines.
- In the [Docs] section you can find the complete reference documentation for all of the different features and settings that Trivy has to offer.
- In the [Ecosystem] section you can find how Trivy works together with other tools and applications that you might already use.
- In the [Contributing] section you can find technical developer documentation and contribution guidelines.
# About Trivy
@@ -35,30 +35,30 @@ Scanners (what Trivy can find there):
- Sensitive information and secrets
- Software licenses
To learn more, go to the [Trivy homepage][homepage] for feature highlights, or to the [Documentation site][Docs] for detailed information.
## Quick Start
### Get Trivy
Trivy is available in most common distribution methods. The full list of installation options is available in the [Installation] page, here are a few popular options:
Trivy is available in most common distribution channels. The complete list of installation options is available in the [Installation] page. Here are a few popular examples:
- `apt-get install trivy`
- `yum install trivy`
- `brew install aquasecurity/trivy/trivy`
- `brew install trivy`
- `docker run aquasec/trivy`
- Download binary from <https://github.com/aquasecurity/trivy/releases/latest/>
- See [Installation] for more
Trivy is integrated with many popular platforms and applications. The full list of integrations is available in the [Ecosystem] page. Here are a few popular options:
Trivy is integrated with many popular platforms and applications. The complete list of integrations is available in the [Ecosystem] page. Here are a few popular options examples:
- [GitHub Actions](https://github.com/aquasecurity/trivy-action)
- [CircleCI](https://circleci.com/developer/orbs/orb/fifteen5/trivy-orb)
- [Kubernetes operator](https://github.com/aquasecurity/trivy-operator)
- [VS Code plugin](https://github.com/aquasecurity/trivy-vscode-extension)
- See [Ecosystem] for more
### General usage
```bash
trivy <target> [--security-checks <scanner1,scanner2>] <subject>
trivy <target> [--scanners <scanner1,scanner2>] <subject>
```
Examples:
@@ -80,7 +80,7 @@ trivy image python:3.4-alpine
</details>
```bash
trivy fs --security-checks vuln,secret,config myproject/
trivy fs --scanners vuln,secret,config myproject/
```
<details>
@@ -109,36 +109,6 @@ trivy k8s --report summary cluster
</details>
## Highlights
- Comprehensive vulnerability detection
- OS packages (Alpine Linux, Red Hat Universal Base Image, Red Hat Enterprise Linux, CentOS, AlmaLinux, Rocky Linux, CBL-Mariner, Oracle Linux, Debian, Ubuntu, Amazon Linux, openSUSE Leap, SUSE Enterprise Linux, Photon OS and Distroless)
- **Language-specific packages** (Bundler, Composer, Pipenv, Poetry, npm, yarn, Cargo, NuGet, Maven, and Go)
- High accuracy, especially [Alpine Linux][alpine] and RHEL/CentOS
- Supply chain security (SBOM support)
- Support CycloneDX
- Support SPDX
- Generating and Scanning SBOM
- Leveraging in-toto attestations
- Integrated with [Sigstore]
- Misconfiguration detection (IaC scanning)
- Wide variety of security checks are provided **out of the box**
- Kubernetes, Docker, Terraform, and more
- User-defined policies using [OPA Rego][rego]
- Secret detection
- A wide variety of built-in rules are provided **out of the box**
- User-defined patterns
- Efficient scanning of container images
- Simple
- Available in apt, yum, brew, dockerhub
- **No pre-requisites** such as a database, system libraries, or eny environmental requirements. The binary runs anywhere.
- The first scan will finish within 10 seconds (depending on your network). Consequent scans will finish instantaneously.
- Fits your workflow
- **Great for CI** such as GitHub Actions, Jenkins, GitLab CI, etc.
- Available as extension for IDEs such as vscode, jetbrains, vim
- Available as extension for Docker Desktop, Rancher Desktop
- See [Ecosystem] section in the documentation.
## FAQ
### How to pronounce the name "Trivy"?
@@ -159,6 +129,8 @@ Contact us about any matter by opening a GitHub Discussion [here][discussions]
[oss]: https://www.aquasec.com/products/open-source-projects/
[discussions]: https://github.com/aquasecurity/trivy/discussions
[homepage]: https://trivy.dev
[Tutorials]: ./tutorials/overview
[CLI]: ./docs
[Docs]: ./docs
[Getting Started]: ./
[Contributing]: ./community/contribute/issue

View File

@@ -150,7 +150,7 @@ trivy:
# Image report
- ./trivy image --exit-code 0 --format template --template "@contrib/gitlab-codequality.tpl" -o gl-codeclimate-image.json $IMAGE
# Filesystem report
- ./trivy filesystem --security-checks config,vuln --exit-code 0 --format template --template "@contrib/gitlab-codequality.tpl" -o gl-codeclimate-fs.json .
- ./trivy filesystem --scanners config,vuln --exit-code 0 --format template --template "@contrib/gitlab-codequality.tpl" -o gl-codeclimate-fs.json .
# Combine report
- apk update && apk add jq
- jq -s 'add' gl-codeclimate-image.json gl-codeclimate-fs.json > gl-codeclimate.json

View File

@@ -68,7 +68,7 @@ This has several benefits:
- The CRDs can be both machine and human-readable depending on which applications consume the CRDs. This allows for more versatile applications of the Trivy operator.
There are several ways that you can install the Trivy Operator in your cluster. In this guide, were going to use the Helm installation based on the [following documentation.](../../docs/kubernetes/operator/index.md)
There are several ways that you can install the Trivy Operator in your cluster. In this guide, were going to use the Helm installation based on the [following documentation.](../../docs/target/kubernetes.md#trivy-operator)
Make sure that you have the [Helm CLI installed.](https://helm.sh/docs/intro/install/)
Next, run the following commands.

View File

@@ -106,9 +106,15 @@ spec:
sourceRef:
kind: HelmRepository
name: trivy-operator
namespace: flux-system
version: 0.0.5
namespace: flux-system
version: 0.10.1
interval: 60m
values:
trivy:
ignoreUnfixed: true
install:
crds: CreateReplace
createNamespace: true
```
You can then apply the file to your Kubernetes cluster:

View File

@@ -1,27 +1,18 @@
# Tutorials
Tutorials are a great way to learn about use cases and integrations. We highly encourage community members to share their Trivy use cases with us in the documentation.
In this section you can find step-by-step guides that help you accomplish specific tasks.
There are two ways to contributor to the tutorials section
👈 Please use the side-navigation on the left in order to browse the different topics.
1. If you are creating any external content on Trivy, we would love to have it as part of our list of [external community resources][community-resources]
2. If you are creating an end-to-end tutorial on a specific Trivy use-case, we would love to feature it in our tutorial section. Read below how you can contribute tutorials to the docs.
## Adding tutorials
## Process for adding new tutorials
You are welcome to create tutorials and showcase them here. Tutorials can be either included in here as full articles, or included as external links under [external community resources][community-resources].
Before sending PR, please first create an issue (of kind "Documentation") and describe the suggestion, if it's external link or article, and what category it's under.
Requirements
- The tutorial has to provide an end-to-end set of instructions
- Ideally, tutorials should focus on a specific use case
- If the tutorial is featuring other tools, those should be open source, too
- Make sure to describe the expected outcome after each instruction
Guidelines:
**Tip:** Make sure that your tutorial is concise about a specific use case or integration.
How to add a tutorial
1. Simply create a new `.md` file in the tutorials folder of the docs
2. Add your content
3. Create a new index in the mkdocs.yaml file which is in the [root directory](https://github.com/aquasecurity/trivy) of the repository
4. Create a PR
- Focus on a specific use case. Start by clearly describing the use case and when/who it is relevant for.
- Provide an end-to-end set of instructions. Make sure anyone can easily follow.
- Describe the expected outcome after each step. Include examples as much as possible.
[community-resources]: additional-resources/community.md

View File

@@ -0,0 +1,66 @@
# Enable shell completion
Below is example steps to enable shell completion feature for `trivy` cli:
### 1. Know your current shell
```bash
$ echo $SHELL
/bin/zsh # For this example it is zsh, but will be vary depend on your $SHELL, maybe /bin/bash or /bin/fish
```
### 2. Run `completion` command to get sub-commands
``` bash
$ trivy completion zsh -h
Generate the autocompletion script for the zsh shell.
If shell completion is not already enabled in your environment you will need
to enable it. You can execute the following once:
echo "autoload -U compinit; compinit" >> ~/.zshrc
To load completions in your current shell session:
source <(trivy completion zsh); compdef _trivy trivy
To load completions for every new session, execute once:
#### Linux:
trivy completion zsh > "${fpath[1]}/_trivy"
#### macOS:
trivy completion zsh > $(brew --prefix)/share/zsh/site-functions/_trivy
You will need to start a new shell for this setup to take effect.
```
### 3. Run the sub-commands following the instruction
```bash
echo "autoload -U compinit; compinit" >> ~/.zshrc
source <(trivy completion zsh); compdef _trivy trivy
trivy completion zsh > "${fpath[1]}/_trivy"
```
### 4. Start a new shell and you can see the shell completion
```bash
$ trivy [tab]
aws -- scan aws account
completion -- Generate the autocompletion script for the specified shell
config -- Scan config files for misconfigurations
filesystem -- Scan local filesystem
help -- Help about any command
image -- Scan a container image
kubernetes -- scan kubernetes cluster
module -- Manage modules
plugin -- Manage plugins
repository -- Scan a remote repository
rootfs -- Scan rootfs
sbom -- Scan SBOM for vulnerabilities
server -- Server mode
version -- Print the version
```

View File

@@ -18,7 +18,7 @@ trivy image --ignore-unfixed --format json --output scan.json anaisurlichs/cns-w
```
* --ignore-unfixed: Ensures that only the vulnerabilities are displayed that have a already a fix available
* --output scan.json: The scan output is scaved to a scan.json file instead of being displayed in the terminal.
* --output scan.json: The scan output is saved to a scan.json file instead of being displayed in the terminal.
Note: Replace the container image with the container image that you would like to scan.

View File

@@ -14,7 +14,7 @@ scan:
- /usr/lib
- /usr/include
security-checks:
scanners:
- vuln
- secret
vulnerability:

244
go.mod
View File

@@ -8,8 +8,8 @@ require (
github.com/NYTimes/gziphandler v1.1.1
github.com/alicebob/miniredis/v2 v2.23.0
github.com/aquasecurity/bolt-fixtures v0.0.0-20200903104109-d34e7f983986
github.com/aquasecurity/defsec v0.82.7-0.20221229120130-2bc18528da1c
github.com/aquasecurity/go-dep-parser v0.0.0-20230105081339-fe9e63bf16bf
github.com/aquasecurity/defsec v0.84.0
github.com/aquasecurity/go-dep-parser v0.0.0-20230228091112-63a15cdc6bc3
github.com/aquasecurity/go-gem-version v0.0.0-20201115065557-8eed6fe000ce
github.com/aquasecurity/go-npm-version v0.0.0-20201110091526-0b796d180798
github.com/aquasecurity/go-pep440-version v0.0.0-20210121094942-22b2f8951d46
@@ -17,23 +17,24 @@ require (
github.com/aquasecurity/loading v0.0.5
github.com/aquasecurity/memoryfs v1.4.4
github.com/aquasecurity/table v1.8.0
github.com/aquasecurity/testdocker v0.0.0-20210911155206-e1e85f5a1516
github.com/aquasecurity/testdocker v0.0.0-20230111101738-e741bda259da
github.com/aquasecurity/tml v0.6.1
github.com/aquasecurity/trivy-db v0.0.0-20221227141502-af78ecb7db4c
github.com/aquasecurity/trivy-kubernetes v0.3.1-0.20221021174315-8d74450b4506
github.com/aws/aws-sdk-go v1.44.171
github.com/aws/aws-sdk-go-v2 v1.17.1
github.com/aws/aws-sdk-go-v2/config v1.18.3
github.com/aws/aws-sdk-go-v2/service/ec2 v1.63.1
github.com/aws/aws-sdk-go-v2/service/sts v1.17.5
github.com/aquasecurity/trivy-db v0.0.0-20230116084806-4bcdf1c414d0
github.com/aquasecurity/trivy-java-db v0.0.0-20230209231723-7cddb1406728
github.com/aquasecurity/trivy-kubernetes v0.3.1-0.20230223104408-c772810be7c3
github.com/aws/aws-sdk-go v1.44.210
github.com/aws/aws-sdk-go-v2 v1.17.5
github.com/aws/aws-sdk-go-v2/config v1.18.15
github.com/aws/aws-sdk-go-v2/service/ec2 v1.86.1
github.com/aws/aws-sdk-go-v2/service/sts v1.18.5
github.com/caarlos0/env/v6 v6.10.1
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/cheggaaa/pb/v3 v3.1.0
github.com/containerd/containerd v1.6.14
github.com/docker/docker v20.10.20+incompatible
github.com/containerd/containerd v1.6.18
github.com/docker/docker v23.0.0-rc.1+incompatible
github.com/docker/go-connections v0.4.0
github.com/fatih/color v1.13.0
github.com/go-openapi/runtime v0.24.2
github.com/go-openapi/runtime v0.25.0
github.com/go-openapi/strfmt v0.21.3
github.com/go-redis/redis/v8 v8.11.5
github.com/golang-jwt/jwt v3.2.2+incompatible
@@ -42,11 +43,11 @@ require (
github.com/google/licenseclassifier/v2 v2.0.0
github.com/google/uuid v1.3.0
github.com/google/wire v0.5.0
github.com/hashicorp/go-getter v1.6.2
github.com/hashicorp/go-getter v1.7.0
github.com/hashicorp/golang-lru/v2 v2.0.1
github.com/in-toto/in-toto-golang v0.5.0
github.com/knqyf263/go-apk-version v0.0.0-20200609155635-041fdbb8563f
github.com/knqyf263/go-deb-version v0.0.0-20190517075300-09fca494f03d
github.com/knqyf263/go-deb-version v0.0.0-20230223133812-3ed183d23422
github.com/knqyf263/go-rpm-version v0.0.0-20220614171824-631e686d1075
github.com/kylelemons/godebug v1.1.0
github.com/mailru/easyjson v0.7.7
@@ -59,17 +60,17 @@ require (
github.com/mitchellh/hashstructure/v2 v2.0.2
github.com/open-policy-agent/opa v0.44.1-0.20220927105354-00e835a7cc15
github.com/owenrumney/go-sarif/v2 v2.1.2
github.com/package-url/packageurl-go v0.1.1-0.20220203205134-d70459300c8a
github.com/samber/lo v1.36.0
github.com/package-url/packageurl-go v0.1.1-0.20220428063043-89078438f170
github.com/samber/lo v1.37.0
github.com/secure-systems-lab/go-securesystemslib v0.4.0
github.com/sigstore/rekor v1.0.1
github.com/sosedoff/gitkit v0.3.0
github.com/spf13/cobra v1.6.0
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.14.0
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.1
github.com/testcontainers/testcontainers-go v0.15.0
github.com/tetratelabs/wazero v1.0.0-pre.7
github.com/testcontainers/testcontainers-go v0.17.0
github.com/tetratelabs/wazero v1.0.0-pre.9
github.com/twitchtv/twirp v8.1.2+incompatible
github.com/xlab/treeprint v1.1.0
go.etcd.io/bbolt v1.3.6
@@ -78,15 +79,25 @@ require (
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2
google.golang.org/protobuf v1.28.1
gopkg.in/yaml.v3 v3.0.1
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
k8s.io/utils v0.0.0-20230115233650-391b47cb4029
modernc.org/sqlite v1.20.3
)
require (
cloud.google.com/go v0.104.0 // indirect
cloud.google.com/go/compute v1.12.1 // indirect
cloud.google.com/go/compute/metadata v0.2.1 // indirect
cloud.google.com/go/iam v0.5.0 // indirect
cloud.google.com/go/storage v1.23.0 // indirect
github.com/cloudflare/circl v1.1.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/pjbgf/sha1cd v0.2.3 // indirect
github.com/skeema/knownhosts v1.1.0 // indirect
go.opentelemetry.io/otel v1.11.1 // indirect
go.opentelemetry.io/otel/trace v1.11.1 // indirect
)
require (
cloud.google.com/go v0.105.0 // indirect
cloud.google.com/go/compute v1.14.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v0.8.0 // indirect
cloud.google.com/go/storage v1.27.0 // indirect
github.com/Azure/azure-sdk-for-go v67.1.0+incompatible
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
@@ -107,7 +118,7 @@ require (
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/Microsoft/hcsshim v0.9.6 // indirect
github.com/OneOfOne/xxhash v1.2.8 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4 // indirect
github.com/VividCortex/ewma v1.1.1 // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
@@ -118,23 +129,23 @@ require (
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.8 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.3 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.19 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.25 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.19 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.26 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.15 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.23 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.29 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.23 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.30 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.14 // indirect
github.com/aws/aws-sdk-go-v2/service/accessanalyzer v1.16.0 // indirect
github.com/aws/aws-sdk-go-v2/service/apigateway v1.15.20 // indirect
github.com/aws/aws-sdk-go-v2/service/apigateway v1.15.24 // indirect
github.com/aws/aws-sdk-go-v2/service/apigatewayv2 v1.12.18 // indirect
github.com/aws/aws-sdk-go-v2/service/athena v1.18.10 // indirect
github.com/aws/aws-sdk-go-v2/service/cloudfront v1.20.5 // indirect
github.com/aws/aws-sdk-go-v2/service/cloudtrail v1.18.2 // indirect
github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.21.6 // indirect
github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.21.10 // indirect
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.15.20 // indirect
github.com/aws/aws-sdk-go-v2/service/codebuild v1.19.17 // indirect
github.com/aws/aws-sdk-go-v2/service/docdb v1.19.11 // indirect
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.17.1 // indirect
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.17.6 // indirect
github.com/aws/aws-sdk-go-v2/service/ebs v1.15.19 // indirect
github.com/aws/aws-sdk-go-v2/service/ecr v1.17.18 // indirect
github.com/aws/aws-sdk-go-v2/service/ecs v1.18.26 // indirect
@@ -145,12 +156,12 @@ require (
github.com/aws/aws-sdk-go-v2/service/elasticsearchservice v1.16.10 // indirect
github.com/aws/aws-sdk-go-v2/service/emr v1.20.11 // indirect
github.com/aws/aws-sdk-go-v2/service/iam v1.18.23 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.9 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.10 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.18 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.17 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.19 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.19 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.23 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.17 // indirect
github.com/aws/aws-sdk-go-v2/service/kafka v1.17.19 // indirect
github.com/aws/aws-sdk-go-v2/service/kafka v1.19.4 // indirect
github.com/aws/aws-sdk-go-v2/service/kinesis v1.15.19 // indirect
github.com/aws/aws-sdk-go-v2/service/kms v1.18.15 // indirect
github.com/aws/aws-sdk-go-v2/service/lambda v1.24.6 // indirect
@@ -162,21 +173,21 @@ require (
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.16.2 // indirect
github.com/aws/aws-sdk-go-v2/service/sns v1.18.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sqs v1.19.10 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.11.25 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.8 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.12.4 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.4 // indirect
github.com/aws/aws-sdk-go-v2/service/workspaces v1.23.0 // indirect
github.com/aws/smithy-go v1.13.4 // indirect
github.com/aws/smithy-go v1.13.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bmatcuk/doublestar v1.3.4 // indirect
github.com/briandowns/spinner v1.12.0 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/containerd/cgroups v1.0.4 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/containerd/fifo v1.0.0 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.12.1 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.13.0 // indirect
github.com/containerd/ttrpc v1.1.1-0.20220420014843-944ef4a40df3 // indirect
github.com/containerd/typeurl v1.0.2 // indirect
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
@@ -184,22 +195,23 @@ require (
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/dlclark/regexp2 v1.4.0 // indirect
github.com/docker/cli v20.10.20+incompatible // indirect
github.com/docker/cli v23.0.0-rc.1+incompatible // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.3.1 // indirect
github.com/go-git/go-git/v5 v5.4.2
github.com/go-git/go-billy/v5 v5.4.0 // indirect
github.com/go-git/go-git/v5 v5.5.2
github.com/go-gorp/gorp/v3 v3.0.2 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
@@ -215,23 +227,21 @@ require (
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
github.com/googleapis/gax-go/v2 v2.6.0 // indirect
github.com/googleapis/go-type-adapters v1.0.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.1 // indirect
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gosuri/uitable v0.0.4 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
@@ -246,37 +256,39 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/knqyf263/go-rpmdb v0.0.0-20221030142135-919c8a52f04f
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.15.12 // indirect
github.com/knqyf263/go-rpmdb v0.0.0-20230201142403-697bc51b3948
github.com/knqyf263/nested v0.0.1
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/liamg/iamgo v0.0.9 // indirect
github.com/liamg/jfather v0.0.7 // indirect
github.com/liamg/memoryfs v1.4.3 // indirect
github.com/lib/pq v1.10.6 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/microsoft/go-rustaudit v0.0.0-20220808201409-204dfee52032 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/buildkit v0.10.6
github.com/moby/buildkit v0.11.0
github.com/moby/locker v1.0.1 // indirect
github.com/moby/patternmatcher v0.5.0 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/sys/mount v0.3.3 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/signal v0.7.0 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
@@ -288,38 +300,37 @@ require (
github.com/opencontainers/image-spec v1.1.0-rc2
github.com/opencontainers/runc v1.1.3 // indirect
github.com/opencontainers/runtime-spec v1.0.3-0.20220311020903-6969a0a09ab1 // indirect
github.com/opencontainers/selinux v1.10.1 // indirect
github.com/opencontainers/selinux v1.10.2 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/owenrumney/squealer v1.0.1-0.20220510063705-c0be93f0edea // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/owenrumney/squealer v1.1.1 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.13.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230126093431-47fa9a501578 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rubenv/sql-migrate v1.1.2 // indirect
github.com/russross/blackfriday v1.6.0 // indirect
github.com/rubenv/sql-migrate v1.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/saracen/walker v0.0.0-20191201085201-324a081bae7e
github.com/sergi/go-diff v1.1.0 // indirect
github.com/shibumi/go-pathspec v1.3.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spdx/tools-golang v0.3.0
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spdx/tools-golang v0.3.1-0.20230104082527-d6f58551be3f
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/tchap/go-patricia/v2 v2.3.1 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/vbatts/tar-split v0.11.2 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
@@ -327,26 +338,25 @@ require (
github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 // indirect
github.com/zclconf/go-cty v1.10.0 // indirect
github.com/zclconf/go-cty-yaml v1.0.2 // indirect
go.etcd.io/etcd/api/v3 v3.5.5 // indirect
go.mongodb.org/mongo-driver v1.10.0 // indirect
go.opencensus.io v0.23.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.3.0
golang.org/x/mod v0.6.0
golang.org/x/net v0.2.0 // indirect
golang.org/x/crypto v0.5.0
golang.org/x/mod v0.8.0
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.1.0 // indirect
golang.org/x/sync v0.1.0
golang.org/x/sys v0.3.0 // indirect
golang.org/x/term v0.3.0
golang.org/x/text v0.5.0
golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0
golang.org/x/text v0.7.0
golang.org/x/time v0.1.0 // indirect
golang.org/x/tools v0.2.0 // indirect
google.golang.org/api v0.102.0 // indirect
google.golang.org/api v0.107.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e // indirect
google.golang.org/grpc v1.50.1 // indirect
google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef // indirect
google.golang.org/grpc v1.52.0 // indirect
gopkg.in/cheggaaa/pb.v1 v1.0.28 // indirect
gopkg.in/go-playground/validator.v9 v9.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
@@ -354,28 +364,27 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gotest.tools v2.2.0+incompatible
helm.sh/helm/v3 v3.10.1 // indirect
k8s.io/api v0.25.3 // indirect
k8s.io/apiextensions-apiserver v0.25.2 // indirect
k8s.io/apimachinery v0.25.3 // indirect
k8s.io/apiserver v0.25.2 // indirect
k8s.io/cli-runtime v0.25.3 // indirect
k8s.io/client-go v0.25.3 // indirect
k8s.io/component-base v0.25.3 // indirect
k8s.io/klog/v2 v2.70.1 // indirect
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
k8s.io/kubectl v0.25.3 // indirect
lukechampine.com/uint128 v1.1.1 // indirect
modernc.org/cc/v3 v3.36.0 // indirect
modernc.org/ccgo/v3 v3.16.6 // indirect
modernc.org/libc v1.16.7 // indirect
modernc.org/mathutil v1.4.1 // indirect
modernc.org/memory v1.1.1 // indirect
modernc.org/opt v0.1.1 // indirect
modernc.org/sqlite v1.17.3 // indirect
modernc.org/strutil v1.1.1 // indirect
modernc.org/token v1.0.0 // indirect
oras.land/oras-go v1.2.0 // indirect
helm.sh/helm/v3 v3.11.1 // indirect
k8s.io/api v0.26.1 // indirect
k8s.io/apiextensions-apiserver v0.26.0 // indirect
k8s.io/apimachinery v0.26.1 // indirect
k8s.io/apiserver v0.26.0 // indirect
k8s.io/cli-runtime v0.26.1 // indirect
k8s.io/client-go v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/klog/v2 v2.90.0 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/kubectl v0.26.1 // indirect
lukechampine.com/uint128 v1.2.0 // indirect
modernc.org/cc/v3 v3.40.0 // indirect
modernc.org/ccgo/v3 v3.16.13 // indirect
modernc.org/libc v1.22.2 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.5.0 // indirect
modernc.org/opt v0.1.3 // indirect
modernc.org/strutil v1.1.3 // indirect
modernc.org/token v1.0.1 // indirect
oras.land/oras-go v1.2.2 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/kustomize/api v0.12.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect
@@ -383,9 +392,10 @@ require (
sigs.k8s.io/yaml v1.3.0 // indirect
)
// See https://github.com/moby/moby/issues/42939#issuecomment-1114255529
replace github.com/docker/docker => github.com/docker/docker v20.10.3-0.20220224222438-c78f6963a1c0+incompatible
// v1.2.0 is taken from github.com/open-policy-agent/opa v0.42.0
// v1.2.0 incompatible with github.com/docker/docker v20.10.3-0.20220224222438-c78f6963a1c0+incompatible
// v1.2.0 incompatible with github.com/docker/docker v23.0.0-rc.1+incompatible
replace oras.land/oras-go => oras.land/oras-go v1.1.1
// v0.3.1-0.20230104082527-d6f58551be3f is taken from github.com/moby/buildkit v0.11.0
// spdx logic write on v0.3.0 and incompatible with v0.3.1-0.20230104082527-d6f58551be3f
replace github.com/spdx/tools-golang => github.com/spdx/tools-golang v0.3.0

681
go.sum

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
apiVersion: v2
name: trivy
version: 0.4.17
appVersion: 0.30.4
version: 0.7.0
appVersion: 0.37.2
description: Trivy helm chart
keywords:
- scanner

View File

@@ -68,7 +68,7 @@ The following table lists the configurable parameters of the Trivy chart and the
| `trivy.registryPassword` | The password used to log in at dockerhub. More info: https://aquasecurity.github.io/trivy/dev/advanced/private-registries/docker-hub/ | |
| `trivy.registryCredentialsExistingSecret` | Name of Secret containing dockerhub credentials. Alternative to the 2 parameters above, has precedence if set. | |
| `trivy.serviceAccount.annotations` | Additional annotations to add to the Kubernetes service account resource | |
| `trivy.skipUpdate` | The flag to enable or disable Trivy DB downloads from GitHub | `false` |
| `trivy.skipDBUpdate` | The flag to enable or disable Trivy DB downloads from GitHub | `false` |
| `trivy.dbRepository` | OCI repository to retrieve the trivy vulnerability database from | `ghcr.io/aquasecurity/trivy-db` |
| `trivy.cache.redis.enabled` | Enable Redis as caching backend | `false` |
| `trivy.cache.redis.url` | Specify redis connection url, e.g. redis://redis.redis.svc:6379 | `` |

View File

@@ -12,7 +12,7 @@ data:
TRIVY_CACHE_TTL: {{ .Values.trivy.cache.redis.ttl | quote }}
{{- end }}
TRIVY_DEBUG: {{ .Values.trivy.debugMode | quote }}
TRIVY_SKIP_UPDATE: {{ .Values.trivy.skipUpdate | quote }}
TRIVY_SKIP_DB_UPDATE: {{ .Values.trivy.skipDBUpdate | quote }}
TRIVY_DB_REPOSITORY: {{ .Values.trivy.dbRepository | quote }}
{{- if .Values.httpProxy }}
HTTP_PROXY: {{ .Values.httpProxy | quote }}

View File

@@ -93,12 +93,12 @@ trivy:
# NOTE: When this is set the previous parameters are ignored.
#
# registryCredentialsExistingSecret: name-of-existing-secret
# skipUpdate the flag to enable or disable Trivy DB downloads from GitHub
# skipDBUpdate the flag to enable or disable Trivy DB downloads from GitHub
#
# You might want to enable this flag in test or CI/CD environments to avoid GitHub rate limiting issues.
# If the flag is enabled you have to manually download the `trivy.db` file and mount it in the
# `/home/scanner/.cache/trivy/db/trivy.db` path (see `cacheDir`).
skipUpdate: false
skipDBUpdate: false
# OCI repository to retrieve the trivy vulnerability database from
dbRepository: ghcr.io/aquasecurity/trivy-db
# Trivy supports filesystem and redis as caching backend

View File

@@ -11,11 +11,13 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/aquasecurity/trivy/pkg/types"
)
func TestFilesystem(t *testing.T) {
type args struct {
securityChecks string
scanner types.Scanner
severity []string
ignoreIDs []string
policyPaths []string
@@ -28,6 +30,8 @@ func TestFilesystem(t *testing.T) {
helmValuesFile []string
skipFiles []string
skipDirs []string
command string
format string
}
tests := []struct {
name string
@@ -37,201 +41,228 @@ func TestFilesystem(t *testing.T) {
{
name: "gomod",
args: args{
securityChecks: "vuln",
input: "testdata/fixtures/fs/gomod",
scanner: types.VulnerabilityScanner,
input: "testdata/fixtures/fs/gomod",
},
golden: "testdata/gomod.json.golden",
},
{
name: "gomod with skip files",
args: args{
securityChecks: "vuln",
input: "testdata/fixtures/fs/gomod",
skipFiles: []string{"testdata/fixtures/fs/gomod/submod2/go.mod"},
scanner: types.VulnerabilityScanner,
input: "testdata/fixtures/fs/gomod",
skipFiles: []string{"testdata/fixtures/fs/gomod/submod2/go.mod"},
},
golden: "testdata/gomod-skip.json.golden",
},
{
name: "gomod with skip dirs",
args: args{
securityChecks: "vuln",
input: "testdata/fixtures/fs/gomod",
skipDirs: []string{"testdata/fixtures/fs/gomod/submod2"},
scanner: types.VulnerabilityScanner,
input: "testdata/fixtures/fs/gomod",
skipDirs: []string{"testdata/fixtures/fs/gomod/submod2"},
},
golden: "testdata/gomod-skip.json.golden",
},
{
name: "nodejs",
args: args{
securityChecks: "vuln",
input: "testdata/fixtures/fs/nodejs",
listAllPkgs: true,
scanner: types.VulnerabilityScanner,
input: "testdata/fixtures/fs/nodejs",
listAllPkgs: true,
},
golden: "testdata/nodejs.json.golden",
},
{
name: "yarn",
args: args{
securityChecks: "vuln",
input: "testdata/fixtures/fs/yarn",
listAllPkgs: true,
scanner: types.VulnerabilityScanner,
input: "testdata/fixtures/fs/yarn",
listAllPkgs: true,
},
golden: "testdata/yarn.json.golden",
},
{
name: "pnpm",
args: args{
securityChecks: "vuln",
input: "testdata/fixtures/fs/pnpm",
scanner: types.VulnerabilityScanner,
input: "testdata/fixtures/fs/pnpm",
},
golden: "testdata/pnpm.json.golden",
},
{
name: "pip",
args: args{
securityChecks: "vuln",
listAllPkgs: true,
input: "testdata/fixtures/fs/pip",
scanner: types.VulnerabilityScanner,
listAllPkgs: true,
input: "testdata/fixtures/fs/pip",
},
golden: "testdata/pip.json.golden",
},
{
name: "pipenv",
args: args{
scanner: types.VulnerabilityScanner,
listAllPkgs: true,
input: "testdata/fixtures/fs/pipenv",
},
golden: "testdata/pipenv.json.golden",
},
{
name: "poetry",
args: args{
scanner: types.VulnerabilityScanner,
listAllPkgs: true,
input: "testdata/fixtures/fs/poetry",
},
golden: "testdata/poetry.json.golden",
},
{
name: "pom",
args: args{
securityChecks: "vuln",
input: "testdata/fixtures/fs/pom",
scanner: types.VulnerabilityScanner,
input: "testdata/fixtures/fs/pom",
},
golden: "testdata/pom.json.golden",
},
{
name: "gradle",
args: args{
securityChecks: "vuln",
input: "testdata/fixtures/fs/gradle",
scanner: types.VulnerabilityScanner,
input: "testdata/fixtures/fs/gradle",
},
golden: "testdata/gradle.json.golden",
},
{
name: "conan",
args: args{
securityChecks: "vuln",
listAllPkgs: true,
input: "testdata/fixtures/fs/conan",
scanner: types.VulnerabilityScanner,
listAllPkgs: true,
input: "testdata/fixtures/fs/conan",
},
golden: "testdata/conan.json.golden",
},
{
name: "nuget",
args: args{
securityChecks: "vuln",
listAllPkgs: true,
input: "testdata/fixtures/fs/nuget",
scanner: types.VulnerabilityScanner,
listAllPkgs: true,
input: "testdata/fixtures/fs/nuget",
},
golden: "testdata/nuget.json.golden",
},
{
name: "dotnet",
args: args{
securityChecks: "vuln",
listAllPkgs: true,
input: "testdata/fixtures/fs/dotnet",
scanner: types.VulnerabilityScanner,
listAllPkgs: true,
input: "testdata/fixtures/fs/dotnet",
},
golden: "testdata/dotnet.json.golden",
},
{
name: "cocoapods",
args: args{
securityChecks: "vuln",
listAllPkgs: true,
input: "testdata/fixtures/fs/cocoapods",
scanner: types.VulnerabilityScanner,
listAllPkgs: true,
input: "testdata/fixtures/fs/cocoapods",
},
golden: "testdata/cocoapods.json.golden",
},
{
name: "pubspec.lock",
args: args{
scanner: types.VulnerabilityScanner,
listAllPkgs: true,
input: "testdata/fixtures/fs/pubspec",
},
golden: "testdata/pubspec.lock.json.golden",
},
{
name: "mix.lock",
args: args{
securityChecks: "vuln",
listAllPkgs: true,
input: "testdata/fixtures/fs/mixlock",
scanner: types.VulnerabilityScanner,
listAllPkgs: true,
input: "testdata/fixtures/fs/mixlock",
},
golden: "testdata/mix.lock.json.golden",
},
{
name: "dockerfile",
args: args{
securityChecks: "config",
input: "testdata/fixtures/fs/dockerfile",
namespaces: []string{"testing"},
scanner: types.MisconfigScanner,
input: "testdata/fixtures/fs/dockerfile",
namespaces: []string{"testing"},
},
golden: "testdata/dockerfile.json.golden",
},
{
name: "dockerfile with custom file pattern",
args: args{
securityChecks: "config",
input: "testdata/fixtures/fs/dockerfile_file_pattern",
namespaces: []string{"testing"},
filePatterns: []string{"dockerfile:Customfile"},
scanner: types.MisconfigScanner,
input: "testdata/fixtures/fs/dockerfile_file_pattern",
namespaces: []string{"testing"},
filePatterns: []string{"dockerfile:Customfile"},
},
golden: "testdata/dockerfile_file_pattern.json.golden",
},
{
name: "dockerfile with rule exception",
args: args{
securityChecks: "config",
policyPaths: []string{"testdata/fixtures/fs/rule-exception/policy"},
input: "testdata/fixtures/fs/rule-exception",
scanner: types.MisconfigScanner,
policyPaths: []string{"testdata/fixtures/fs/rule-exception/policy"},
input: "testdata/fixtures/fs/rule-exception",
},
golden: "testdata/dockerfile-rule-exception.json.golden",
},
{
name: "dockerfile with namespace exception",
args: args{
securityChecks: "config",
policyPaths: []string{"testdata/fixtures/fs/namespace-exception/policy"},
input: "testdata/fixtures/fs/namespace-exception",
scanner: types.MisconfigScanner,
policyPaths: []string{"testdata/fixtures/fs/namespace-exception/policy"},
input: "testdata/fixtures/fs/namespace-exception",
},
golden: "testdata/dockerfile-namespace-exception.json.golden",
},
{
name: "dockerfile with custom policies",
args: args{
securityChecks: "config",
policyPaths: []string{"testdata/fixtures/fs/custom-policy/policy"},
namespaces: []string{"user"},
input: "testdata/fixtures/fs/custom-policy",
scanner: types.MisconfigScanner,
policyPaths: []string{"testdata/fixtures/fs/custom-policy/policy"},
namespaces: []string{"user"},
input: "testdata/fixtures/fs/custom-policy",
},
golden: "testdata/dockerfile-custom-policies.json.golden",
},
{
name: "tarball helm chart scanning with builtin policies",
args: args{
securityChecks: "config",
input: "testdata/fixtures/fs/helm",
scanner: types.MisconfigScanner,
input: "testdata/fixtures/fs/helm",
},
golden: "testdata/helm.json.golden",
},
{
name: "helm chart directory scanning with builtin policies",
args: args{
securityChecks: "config",
input: "testdata/fixtures/fs/helm_testchart",
scanner: types.MisconfigScanner,
input: "testdata/fixtures/fs/helm_testchart",
},
golden: "testdata/helm_testchart.json.golden",
},
{
name: "helm chart directory scanning with value overrides using set",
args: args{
securityChecks: "config",
input: "testdata/fixtures/fs/helm_testchart",
helmSet: []string{"securityContext.runAsUser=0"},
scanner: types.MisconfigScanner,
input: "testdata/fixtures/fs/helm_testchart",
helmSet: []string{"securityContext.runAsUser=0"},
},
golden: "testdata/helm_testchart.overridden.json.golden",
},
{
name: "helm chart directory scanning with value overrides using value file",
args: args{
securityChecks: "config",
scanner: types.MisconfigScanner,
input: "testdata/fixtures/fs/helm_testchart",
helmValuesFile: []string{"testdata/fixtures/fs/helm_values/values.yaml"},
},
@@ -240,20 +271,38 @@ func TestFilesystem(t *testing.T) {
{
name: "helm chart directory scanning with builtin policies and non string Chart name",
args: args{
securityChecks: "config",
input: "testdata/fixtures/fs/helm_badname",
scanner: types.MisconfigScanner,
input: "testdata/fixtures/fs/helm_badname",
},
golden: "testdata/helm_badname.json.golden",
},
{
name: "secrets",
args: args{
securityChecks: "vuln,secret",
input: "testdata/fixtures/fs/secrets",
secretConfig: "testdata/fixtures/fs/secrets/trivy-secret.yaml",
scanner: "vuln,secret",
input: "testdata/fixtures/fs/secrets",
secretConfig: "testdata/fixtures/fs/secrets/trivy-secret.yaml",
},
golden: "testdata/secrets.json.golden",
},
{
name: "conda generating CycloneDX SBOM",
args: args{
command: "rootfs",
format: "cyclonedx",
input: "testdata/fixtures/fs/conda",
},
golden: "testdata/conda-cyclonedx.json.golden",
},
{
name: "conda generating SPDX SBOM",
args: args{
command: "rootfs",
format: "spdx-json",
input: "testdata/fixtures/fs/conda",
},
golden: "testdata/conda-spdx.json.golden",
},
}
// Set up testing DB
@@ -264,9 +313,31 @@ func TestFilesystem(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
command := "fs"
if tt.args.command != "" {
command = tt.args.command
}
format := "json"
if tt.args.format != "" {
format = tt.args.format
}
osArgs := []string{
"-q", "--cache-dir", cacheDir, "fs", "--skip-db-update", "--skip-policy-update",
"--format", "json", "--offline-scan", "--security-checks", tt.args.securityChecks,
"-q",
"--cache-dir",
cacheDir,
command,
"--skip-db-update",
"--skip-policy-update",
"--format",
format,
"--offline-scan",
}
if tt.args.scanner != "" {
osArgs = append(osArgs, "--scanners", string(tt.args.scanner))
}
if len(tt.args.policyPaths) != 0 {
@@ -344,7 +415,16 @@ func TestFilesystem(t *testing.T) {
require.NoError(t, err)
// Compare want and got
compareReports(t, tt.golden, outputFile)
switch format {
case "cyclonedx":
compareCycloneDX(t, tt.golden, outputFile)
case "spdx-json":
compareSpdxJson(t, tt.golden, outputFile)
case "json":
compareReports(t, tt.golden, outputFile)
default:
require.Fail(t, "invalid format", "format: %s", format)
}
})
}
}

View File

@@ -14,6 +14,9 @@ import (
"testing"
"time"
cdx "github.com/CycloneDX/cyclonedx-go"
"github.com/spdx/tools-golang/jsonloader"
"github.com/spdx/tools-golang/spdx"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -22,6 +25,8 @@ import (
"github.com/aquasecurity/trivy/pkg/commands"
"github.com/aquasecurity/trivy/pkg/dbtest"
"github.com/aquasecurity/trivy/pkg/types"
_ "modernc.org/sqlite"
)
var update = flag.Bool("update", false, "update golden files")
@@ -55,6 +60,7 @@ func initDB(t *testing.T) string {
})
require.NoError(t, err)
dbtest.InitJavaDB(t, cacheDir)
return cacheDir
}
@@ -121,6 +127,63 @@ func readReport(t *testing.T, filePath string) types.Report {
return report
}
func readCycloneDX(t *testing.T, filePath string) *cdx.BOM {
f, err := os.Open(filePath)
require.NoError(t, err)
defer f.Close()
bom := cdx.NewBOM()
decoder := cdx.NewBOMDecoder(f, cdx.BOMFileFormatJSON)
err = decoder.Decode(bom)
require.NoError(t, err)
// We don't compare values which change each time an SBOM is generated
bom.Metadata.Timestamp = ""
bom.Metadata.Component.BOMRef = ""
bom.SerialNumber = ""
if bom.Components != nil {
sort.Slice(*bom.Components, func(i, j int) bool {
return (*bom.Components)[i].Name < (*bom.Components)[j].Name
})
for i := range *bom.Components {
(*bom.Components)[i].BOMRef = ""
sort.Slice(*(*bom.Components)[i].Properties, func(ii, jj int) bool {
return (*(*bom.Components)[i].Properties)[ii].Name < (*(*bom.Components)[i].Properties)[jj].Name
})
}
}
if bom.Dependencies != nil {
for j := range *bom.Dependencies {
(*bom.Dependencies)[j].Ref = ""
(*bom.Dependencies)[j].Dependencies = nil
}
}
return bom
}
func readSpdxJson(t *testing.T, filePath string) *spdx.Document2_2 {
f, err := os.Open(filePath)
require.NoError(t, err)
defer f.Close()
bom, err := jsonloader.Load2_2(f)
require.NoError(t, err)
sort.Slice(bom.Relationships, func(i, j int) bool {
if bom.Relationships[i].RefA.ElementRefID != bom.Relationships[j].RefA.ElementRefID {
return bom.Relationships[i].RefA.ElementRefID < bom.Relationships[j].RefA.ElementRefID
}
return bom.Relationships[i].RefB.ElementRefID < bom.Relationships[j].RefB.ElementRefID
})
// We don't compare values which change each time an SBOM is generated
bom.CreationInfo.Created = ""
bom.CreationInfo.DocumentNamespace = ""
return bom
}
func execute(osArgs []string) error {
// Setup CLI App
app := commands.NewApp("dev")
@@ -136,3 +199,15 @@ func compareReports(t *testing.T, wantFile, gotFile string) {
got := readReport(t, gotFile)
assert.Equal(t, want, got)
}
func compareCycloneDX(t *testing.T, wantFile, gotFile string) {
want := readCycloneDX(t, wantFile)
got := readCycloneDX(t, gotFile)
assert.Equal(t, want, got)
}
func compareSpdxJson(t *testing.T, wantFile, gotFile string) {
want := readSpdxJson(t, wantFile)
got := readSpdxJson(t, gotFile)
assert.Equal(t, want, got)
}

View File

@@ -1,17 +1,14 @@
//go:build module_integration
package integration
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/aquasecurity/trivy/pkg/module"
"github.com/aquasecurity/trivy/pkg/utils"
"github.com/aquasecurity/trivy/pkg/fanal/analyzer"
"github.com/aquasecurity/trivy/pkg/scanner/post"
)
func TestModule(t *testing.T) {
@@ -35,21 +32,23 @@ func TestModule(t *testing.T) {
// Set up testing DB
cacheDir := initDB(t)
// Set up module dir
moduleDir := filepath.Join(cacheDir, module.RelativeDir)
err := os.MkdirAll(moduleDir, 0700)
require.NoError(t, err)
// Set up Spring4Shell module
t.Setenv("XDG_DATA_HOME", cacheDir)
_, err = utils.CopyFile(filepath.Join("../", "examples", "module", "spring4shell", "spring4shell.wasm"),
filepath.Join(moduleDir, "spring4shell.wasm"))
require.NoError(t, err)
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
osArgs := []string{"--cache-dir", cacheDir, "image", "--ignore-unfixed", "--format", "json",
"--skip-update", "--offline-scan", "--input", tt.input}
osArgs := []string{
"--cache-dir",
cacheDir,
"image",
"--ignore-unfixed",
"--format",
"json",
"--skip-db-update",
"--offline-scan",
"--quiet",
"--module-dir",
filepath.Join("../", "examples", "module", "spring4shell"),
"--input",
tt.input,
}
// Set up the output file
outputFile := filepath.Join(t.TempDir(), "output.json")
@@ -57,11 +56,18 @@ func TestModule(t *testing.T) {
outputFile = tt.golden
}
osArgs = append(osArgs, []string{"--output", outputFile}...)
osArgs = append(osArgs, []string{
"--output",
outputFile,
}...)
// Run Trivy
err = execute(osArgs)
assert.NoError(t, err)
err := execute(osArgs)
require.NoError(t, err)
defer func() {
analyzer.DeregisterAnalyzer("spring4shell")
post.DeregisterPostScanner("spring4shell")
}()
// Compare want and got
compareReports(t, tt.golden, outputFile)

View File

@@ -3,11 +3,9 @@
package integration
import (
"os"
"path/filepath"
"testing"
cdx "github.com/CycloneDX/cyclonedx-go"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -128,9 +126,7 @@ func TestSBOM(t *testing.T) {
// Compare want and got
switch tt.args.format {
case "cyclonedx":
want := decodeCycloneDX(t, tt.golden)
got := decodeCycloneDX(t, outputFile)
assert.Equal(t, want, got)
compareCycloneDX(t, tt.golden, outputFile)
case "json":
compareSBOMReports(t, tt.golden, outputFile, tt.override)
default:
@@ -165,18 +161,3 @@ func compareSBOMReports(t *testing.T, wantFile, gotFile string, overrideWant typ
got := readReport(t, gotFile)
assert.Equal(t, want, got)
}
func decodeCycloneDX(t *testing.T, filePath string) *cdx.BOM {
f, err := os.Open(filePath)
require.NoError(t, err)
defer f.Close()
bom := cdx.NewBOM()
decoder := cdx.NewBOMDecoder(f, cdx.BOMFileFormatJSON)
err = decoder.Decode(bom)
require.NoError(t, err)
bom.Metadata.Timestamp = ""
return bom
}

View File

@@ -0,0 +1,83 @@
{
"bomFormat": "CycloneDX",
"specVersion": "1.4",
"serialNumber": "urn:uuid:4dd4cf4a-d4de-4ea0-b75f-ad617f31b5a9",
"version": 1,
"metadata": {
"timestamp": "2023-01-08T23:57:37+00:00",
"tools": [
{
"vendor": "aquasecurity",
"name": "trivy",
"version": "dev"
}
],
"component": {
"bom-ref": "582a7c6f-b30e-4b65-a911-f3f5034aa003",
"type": "application",
"name": "testdata/fixtures/fs/conda",
"properties": [
{
"name": "aquasecurity:trivy:SchemaVersion",
"value": "2"
}
]
}
},
"components": [
{
"bom-ref": "pkg:conda/openssl@1.1.1q?file_path=miniconda3%2Fenvs%2Ftestenv%2Fconda-meta%2Fopenssl-1.1.1q-h7f8727e_0.json",
"type": "library",
"name": "openssl",
"version": "1.1.1q",
"licenses": [
{
"expression": "OpenSSL"
}
],
"purl": "pkg:conda/openssl@1.1.1q",
"properties": [
{
"name": "aquasecurity:trivy:PkgType",
"value": "conda-pkg"
},
{
"name": "aquasecurity:trivy:FilePath",
"value": "miniconda3/envs/testenv/conda-meta/openssl-1.1.1q-h7f8727e_0.json"
}
]
},
{
"bom-ref": "pkg:conda/pip@22.2.2?file_path=miniconda3%2Fenvs%2Ftestenv%2Fconda-meta%2Fpip-22.2.2-py38h06a4308_0.json",
"type": "library",
"name": "pip",
"version": "22.2.2",
"licenses": [
{
"expression": "MIT"
}
],
"purl": "pkg:conda/pip@22.2.2",
"properties": [
{
"name": "aquasecurity:trivy:PkgType",
"value": "conda-pkg"
},
{
"name": "aquasecurity:trivy:FilePath",
"value": "miniconda3/envs/testenv/conda-meta/pip-22.2.2-py38h06a4308_0.json"
}
]
}
],
"dependencies": [
{
"ref": "582a7c6f-b30e-4b65-a911-f3f5034aa003",
"dependsOn": [
"pkg:conda/openssl@1.1.1q?file_path=miniconda3%2Fenvs%2Ftestenv%2Fconda-meta%2Fopenssl-1.1.1q-h7f8727e_0.json",
"pkg:conda/pip@22.2.2?file_path=miniconda3%2Fenvs%2Ftestenv%2Fconda-meta%2Fpip-22.2.2-py38h06a4308_0.json"
]
}
],
"vulnerabilities": []
}

View File

@@ -0,0 +1,101 @@
{
"SPDXID": "SPDXRef-DOCUMENT",
"creationInfo": {
"created": "2023-01-08T23:58:16.700785648Z",
"creators": [
"Tool: trivy",
"Organization: aquasecurity"
]
},
"dataLicense": "CC0-1.0",
"documentDescribes": [
"SPDXRef-Filesystem-6e0ac6a0fab50ab4"
],
"documentNamespace": "http://aquasecurity.github.io/trivy/filesystem/testdata/fixtures/fs/conda-3be0d21e-5711-451e-8b1b-2ac8775a3abb",
"files": [
{
"SPDXID": "SPDXRef-File-600e5e0110a84891",
"fileName": "miniconda3/envs/testenv/conda-meta/openssl-1.1.1q-h7f8727e_0.json"
},
{
"SPDXID": "SPDXRef-File-7eb62e2a3edddc0a",
"fileName": "miniconda3/envs/testenv/conda-meta/pip-22.2.2-py38h06a4308_0.json"
}
],
"name": "testdata/fixtures/fs/conda",
"packages": [
{
"SPDXID": "SPDXRef-Application-ee5ef1aa4ac89125",
"filesAnalyzed": false,
"name": "conda-pkg",
"sourceInfo": "Conda"
},
{
"SPDXID": "SPDXRef-Filesystem-6e0ac6a0fab50ab4",
"attributionTexts": [
"SchemaVersion: 2"
],
"filesAnalyzed": false,
"name": "testdata/fixtures/fs/conda"
},
{
"SPDXID": "SPDXRef-Package-2984084f02572600",
"externalRefs": [
{
"referenceCategory": "PACKAGE-MANAGER",
"referenceLocator": "pkg:conda/openssl@1.1.1q",
"referenceType": "purl"
}
],
"filesAnalyzed": false,
"hasFiles": [
"SPDXRef-File-600e5e0110a84891"
],
"licenseConcluded": "OpenSSL",
"licenseDeclared": "OpenSSL",
"name": "openssl",
"versionInfo": "1.1.1q"
},
{
"SPDXID": "SPDXRef-Package-ac33eb699b3aa81d",
"externalRefs": [
{
"referenceCategory": "PACKAGE-MANAGER",
"referenceLocator": "pkg:conda/pip@22.2.2",
"referenceType": "purl"
}
],
"filesAnalyzed": false,
"hasFiles": [
"SPDXRef-File-7eb62e2a3edddc0a"
],
"licenseConcluded": "MIT",
"licenseDeclared": "MIT",
"name": "pip",
"versionInfo": "22.2.2"
}
],
"relationships": [
{
"relatedSpdxElement": "SPDXRef-Filesystem-6e0ac6a0fab50ab4",
"relationshipType": "DESCRIBES",
"spdxElementId": "SPDXRef-DOCUMENT"
},
{
"relatedSpdxElement": "SPDXRef-Application-ee5ef1aa4ac89125",
"relationshipType": "CONTAINS",
"spdxElementId": "SPDXRef-Filesystem-6e0ac6a0fab50ab4"
},
{
"relatedSpdxElement": "SPDXRef-Package-2984084f02572600",
"relationshipType": "CONTAINS",
"spdxElementId": "SPDXRef-Application-ee5ef1aa4ac89125"
},
{
"relatedSpdxElement": "SPDXRef-Package-ac33eb699b3aa81d",
"relationshipType": "CONTAINS",
"spdxElementId": "SPDXRef-Application-ee5ef1aa4ac89125"
}
],
"spdxVersion": "SPDX-2.2"
}

View File

@@ -20,7 +20,7 @@
"Class": "config",
"Type": "dockerfile",
"MisconfSummary": {
"Successes": 22,
"Successes": 24,
"Failures": 2,
"Exceptions": 0
},

Some files were not shown because too many files have changed in this diff Show More