mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-06 12:51:17 -08:00
Compare commits
289 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3caf0658c | ||
|
|
01dbb42ae9 | ||
|
|
f186d22bf2 | ||
|
|
093c0ae020 | ||
|
|
6bfda76022 | ||
|
|
53850c8b20 | ||
|
|
221196202c | ||
|
|
a614b693d7 | ||
|
|
c24dfbab68 | ||
|
|
728e77a726 | ||
|
|
83fc6e7ec2 | ||
|
|
c2b9132a7e | ||
|
|
aa0c413814 | ||
|
|
1c49ae957e | ||
|
|
29615be85e | ||
|
|
2f05418e60 | ||
|
|
5b0bc5823e | ||
|
|
f92ea09685 | ||
|
|
aa59489fa8 | ||
|
|
fb3c756033 | ||
|
|
c4741b021e | ||
|
|
dca50294e8 | ||
|
|
62de6f3feb | ||
|
|
b1e159b7fb | ||
|
|
ea3a124fc7 | ||
|
|
a447f6ba94 | ||
|
|
e66dbb9357 | ||
|
|
0e3560abe5 | ||
|
|
56dbe1f676 | ||
|
|
5ccfd17fd8 | ||
|
|
03fc5347b5 | ||
|
|
349caf96bc | ||
|
|
21114c98be | ||
|
|
3a4e845e4b | ||
|
|
ebb123f37f | ||
|
|
9c3e895fcb | ||
|
|
20781e5bc3 | ||
|
|
e86bacbd6d | ||
|
|
e3738333b4 | ||
|
|
ac7452009b | ||
|
|
49678aed2a | ||
|
|
c3e734f659 | ||
|
|
db5c523144 | ||
|
|
df422c8bf5 | ||
|
|
bac4689697 | ||
|
|
9297885c75 | ||
|
|
28194e5815 | ||
|
|
693d8c5293 | ||
|
|
48a718394d | ||
|
|
48bdc6e734 | ||
|
|
1e0864842e | ||
|
|
9515695d45 | ||
|
|
2bc54ad275 | ||
|
|
b526e73d88 | ||
|
|
bbaf5952bc | ||
|
|
65b8a40d0d | ||
|
|
ff32deb7bf | ||
|
|
e7f14f729d | ||
|
|
eca51500c3 | ||
|
|
39a746c778 | ||
|
|
d6dc56732b | ||
|
|
a944f0e4c5 | ||
|
|
903bd69abd | ||
|
|
afb4f9dc47 | ||
|
|
c96f2a5b3d | ||
|
|
4d4ea1d51c | ||
|
|
696f2ae0ec | ||
|
|
9d26ae88d6 | ||
|
|
88702cfd59 | ||
|
|
1ad47c24ef | ||
|
|
fecafb1fc5 | ||
|
|
7c22ee3df5 | ||
|
|
3d388d8552 | ||
|
|
fa3cf993ea | ||
|
|
26faf8f3f0 | ||
|
|
150a77313e | ||
|
|
787b466e06 | ||
|
|
5caf4377f3 | ||
|
|
a126e1075a | ||
|
|
6a72dd47ae | ||
|
|
357c358fb1 | ||
|
|
04a6073eac | ||
|
|
fe5d40e8ab | ||
|
|
4eae37c52b | ||
|
|
b7a0a131a0 | ||
|
|
3eecfc6b6e | ||
|
|
39ebed45f8 | ||
|
|
67c6b1d473 | ||
|
|
a2c522ddb2 | ||
|
|
16e9fc054f | ||
|
|
38e2fbf7f9 | ||
|
|
2482aa74f8 | ||
|
|
290462be6f | ||
|
|
8016b821a2 | ||
|
|
7a25dadb44 | ||
|
|
9c794c0ffc | ||
|
|
14c1024b47 | ||
|
|
998f750432 | ||
|
|
770b14113c | ||
|
|
3ccb1a0f10 | ||
|
|
58cfd1b074 | ||
|
|
715963d754 | ||
|
|
37da98df45 | ||
|
|
cdee7030ac | ||
|
|
6a2225b425 | ||
|
|
a2a02de7c5 | ||
|
|
e739ab8506 | ||
|
|
c6d5d856ce | ||
|
|
194a814688 | ||
|
|
03830c50c9 | ||
|
|
8e814fa23d | ||
|
|
2dc76ba782 | ||
|
|
c17176ba97 | ||
|
|
bce70af369 | ||
|
|
4369a19af7 | ||
|
|
5566548b78 | ||
|
|
a8af76a471 | ||
|
|
c8ed432f28 | ||
|
|
551a46efcc | ||
|
|
261649b115 | ||
|
|
acfddd4570 | ||
|
|
419e3d2023 | ||
|
|
f0961d54f6 | ||
|
|
a5d485cf8a | ||
|
|
29b8faf5fa | ||
|
|
e3bef02018 | ||
|
|
916f6c66f8 | ||
|
|
8e6cd0e917 | ||
|
|
060d0bb641 | ||
|
|
2d090ef2df | ||
|
|
6343e4fc71 | ||
|
|
a018ee1f9b | ||
|
|
5da053f302 | ||
|
|
3d66cb8d88 | ||
|
|
9aca98cca8 | ||
|
|
7811ad0d24 | ||
|
|
fae710db8f | ||
|
|
d2d4022ef3 | ||
|
|
164b025413 | ||
|
|
5dd9bd4701 | ||
|
|
7c2017fa7a | ||
|
|
63c9469bdd | ||
|
|
aa822c260f | ||
|
|
30cc88fa87 | ||
|
|
e32215c99d | ||
|
|
d4da83c633 | ||
|
|
0d7d97d131 | ||
|
|
9873cf3b9c | ||
|
|
95c8fd912e | ||
|
|
12ec0dfe9e | ||
|
|
9b7d7132b7 | ||
|
|
13e72eca58 | ||
|
|
a9861994e5 | ||
|
|
46d5abad42 | ||
|
|
34ab09d559 | ||
|
|
1ba5b59527 | ||
|
|
4fab0f8b99 | ||
|
|
d7709816c3 | ||
|
|
4337068208 | ||
|
|
d82d6cb731 | ||
|
|
cfddfb33c1 | ||
|
|
dfcb0f90db | ||
|
|
183eaafb4e | ||
|
|
94d6e8ced6 | ||
|
|
336c47ecc3 | ||
|
|
06b44738e7 | ||
|
|
a51ceddada | ||
|
|
53517d622b | ||
|
|
ad544e97cc | ||
|
|
089368d968 | ||
|
|
116356500e | ||
|
|
637da2b178 | ||
|
|
13190e92d9 | ||
|
|
6bca7c3c79 | ||
|
|
8e4279b863 | ||
|
|
e98c873ed0 | ||
|
|
b1c2eab5aa | ||
|
|
1c49a16c65 | ||
|
|
8dd0fcd61b | ||
|
|
74e4c6e012 | ||
|
|
245c120532 | ||
|
|
86714bf6bf | ||
|
|
a75839212c | ||
|
|
4d00d8b52a | ||
|
|
3ad2b3e255 | ||
|
|
8baccd7909 | ||
|
|
e75a90f2e5 | ||
|
|
6625bd32e0 | ||
|
|
826fe60732 | ||
|
|
f23ed77598 | ||
|
|
df024e88dd | ||
|
|
29dee32814 | ||
|
|
1a67472d2b | ||
|
|
09e37b7c67 | ||
|
|
87a9aa60d1 | ||
|
|
712dcd3007 | ||
|
|
625f22b819 | ||
|
|
6a2f6fde4f | ||
|
|
5f69937cc6 | ||
|
|
258d153461 | ||
|
|
ade033a837 | ||
|
|
f85c9fac6f | ||
|
|
9d7f5c948e | ||
|
|
f148eb10f2 | ||
|
|
97f95c4ddf | ||
|
|
abd62ae74e | ||
|
|
7c409fd270 | ||
|
|
1b68327b65 | ||
|
|
a2482c14e1 | ||
|
|
e866bd5b5d | ||
|
|
1870f28461 | ||
|
|
6c81e5505e | ||
|
|
8ec3938e01 | ||
|
|
f6c5d58001 | ||
|
|
c4022d61b3 | ||
|
|
317792433e | ||
|
|
dd9620ef38 | ||
|
|
eb3ceb323d | ||
|
|
ab74caa87f | ||
|
|
71da44f7e1 | ||
|
|
102b6df738 | ||
|
|
aa19aaf4e4 | ||
|
|
8fcef352b3 | ||
|
|
fb8c516ded | ||
|
|
96bd7ac594 | ||
|
|
12c5bf0805 | ||
|
|
d6c40ce058 | ||
|
|
9d2057a7c2 | ||
|
|
2a9d9bd214 | ||
|
|
617c3e31bd | ||
|
|
56cedc0d67 | ||
|
|
d7d7265eb0 | ||
|
|
6639911662 | ||
|
|
337cb75353 | ||
|
|
9361cdb7e2 | ||
|
|
ee01e6e2f4 | ||
|
|
3d2f583ecd | ||
|
|
c4b5ab7881 | ||
|
|
355c1b583b | ||
|
|
7244ece536 | ||
|
|
5cd0566843 | ||
|
|
ebb74a5de0 | ||
|
|
24a8d6aaa8 | ||
|
|
9d0d7ad886 | ||
|
|
e8230e19d7 | ||
|
|
04535b554a | ||
|
|
939e34e37c | ||
|
|
7cb6c02a4e | ||
|
|
c1d26ec334 | ||
|
|
4f70468bdd | ||
|
|
1dfece89d0 | ||
|
|
e1ea02c7b8 | ||
|
|
64926d8423 | ||
|
|
eb54bb5da5 | ||
|
|
dc76c6e4f4 | ||
|
|
1b7e47424b | ||
|
|
876ab84b36 | ||
|
|
eef7c4fb40 | ||
|
|
069aae59ec | ||
|
|
4a9ac6d199 | ||
|
|
9c5e5a04ee | ||
|
|
388f47669d | ||
|
|
cd3e4bcac2 | ||
|
|
ce81c05851 | ||
|
|
cf0f0d00c2 | ||
|
|
8a3a113eea | ||
|
|
19495ba7c2 | ||
|
|
e787e1af01 | ||
|
|
327cf88397 | ||
|
|
82214736a9 | ||
|
|
7694df11fb | ||
|
|
74dc5b6804 | ||
|
|
32a02a95dd | ||
|
|
fb79ea7c95 | ||
|
|
c6844a73f1 | ||
|
|
a813506f41 | ||
|
|
14adbb4464 | ||
|
|
efe0e0f8f3 | ||
|
|
73dde32632 | ||
|
|
aadbad1d78 | ||
|
|
14a0981efa | ||
|
|
3ac63887dc | ||
|
|
3c1601b6cb | ||
|
|
c107e1af29 | ||
|
|
b26f217172 | ||
|
|
7bd3b630bb | ||
|
|
535b5a96d9 | ||
|
|
428420ee84 | ||
|
|
7fec991c58 |
19
.github/CODEOWNERS
vendored
19
.github/CODEOWNERS
vendored
@@ -1,15 +1,22 @@
|
||||
# Global
|
||||
* @knqyf263
|
||||
|
||||
# SBOM/Vulnerability scanning
|
||||
pkg/dependency/ @knqyf263 @DmitriyLewen
|
||||
pkg/fanal/ @knqyf263 @DmitriyLewen
|
||||
pkg/sbom/ @knqyf263 @DmitriyLewen
|
||||
pkg/scanner/ @knqyf263 @DmitriyLewen
|
||||
|
||||
# Misconfiguration scanning
|
||||
docs/docs/scanner/misconfiguration @knqyf263 @simar7
|
||||
docs/docs/target/aws.md @knqyf263 @simar7
|
||||
pkg/fanal/analyzer/config @knqyf263 @simar7
|
||||
pkg/cloud @knqyf263 @simar7
|
||||
docs/docs/scanner/misconfiguration/ @simar7 @nikpivkin
|
||||
docs/docs/target/aws.md @simar7 @nikpivkin
|
||||
pkg/fanal/analyzer/config/ @simar7 @nikpivkin
|
||||
pkg/cloud/ @simar7 @nikpivkin
|
||||
pkg/iac/ @simar7 @nikpivkin
|
||||
|
||||
# Helm chart
|
||||
helm/trivy/ @chen-keinan
|
||||
|
||||
# Kubernetes scanning
|
||||
pkg/k8s/ @josedonizetti @chen-keinan @knqyf263
|
||||
docs/docs/kubernetes/ @josedonizetti @chen-keinan @knqyf263
|
||||
pkg/k8s/ @chen-keinan
|
||||
docs/docs/target/kubernetes.md @chen-keinan
|
||||
|
||||
24
.github/dependabot.yml
vendored
24
.github/dependabot.yml
vendored
@@ -4,12 +4,34 @@ updates:
|
||||
directory: /
|
||||
schedule:
|
||||
interval: monthly
|
||||
groups:
|
||||
github-actions:
|
||||
patterns:
|
||||
- "*"
|
||||
- package-ecosystem: docker
|
||||
directory: /
|
||||
schedule:
|
||||
interval: monthly
|
||||
groups:
|
||||
docker:
|
||||
patterns:
|
||||
- "*"
|
||||
- package-ecosystem: gomod
|
||||
open-pull-requests-limit: 10
|
||||
directory: /
|
||||
schedule:
|
||||
interval: monthly
|
||||
interval: weekly
|
||||
groups:
|
||||
aws:
|
||||
patterns:
|
||||
- "github.com/aws/*"
|
||||
docker:
|
||||
patterns:
|
||||
- "github.com/docker/*"
|
||||
- "github.com/moby/*"
|
||||
testcontainers:
|
||||
patterns:
|
||||
- "github.com/testcontainers/*"
|
||||
common:
|
||||
patterns:
|
||||
- "*"
|
||||
10
.github/workflows/auto-update-labels.yaml
vendored
10
.github/workflows/auto-update-labels.yaml
vendored
@@ -5,22 +5,24 @@ on:
|
||||
- 'misc/triage/labels.yaml'
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
GO_VERSION: '1.22'
|
||||
jobs:
|
||||
deploy:
|
||||
name: Auto-update labels
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout main
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.6
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
# cf. https://github.com/aquasecurity/trivy/pull/6711
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Install aqua tools
|
||||
uses: aquaproj/aqua-installer@v2.2.0
|
||||
uses: aquaproj/aqua-installer@v3.0.1
|
||||
with:
|
||||
aqua_version: v1.25.0
|
||||
|
||||
|
||||
2
.github/workflows/canary.yaml
vendored
2
.github/workflows/canary.yaml
vendored
@@ -25,7 +25,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Restore Trivy binaries from cache
|
||||
uses: actions/cache@v4.0.0
|
||||
uses: actions/cache@v4.0.2
|
||||
with:
|
||||
path: dist/
|
||||
key: ${{ runner.os }}-bins-${{github.workflow}}-${{github.sha}}
|
||||
|
||||
2
.github/workflows/mkdocs-dev.yaml
vendored
2
.github/workflows/mkdocs-dev.yaml
vendored
@@ -12,7 +12,7 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout main
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: true
|
||||
|
||||
2
.github/workflows/mkdocs-latest.yaml
vendored
2
.github/workflows/mkdocs-latest.yaml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout main
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: true
|
||||
|
||||
8
.github/workflows/publish-chart.yaml
vendored
8
.github/workflows/publish-chart.yaml
vendored
@@ -22,11 +22,11 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install Helm
|
||||
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78
|
||||
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814
|
||||
with:
|
||||
version: v3.5.0
|
||||
- name: Set up python
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
id: lint
|
||||
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992
|
||||
- name: Setup Kubernetes cluster (KIND)
|
||||
uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140
|
||||
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde
|
||||
with:
|
||||
version: ${{ env.KIND_VERSION }}
|
||||
image: ${{ env.KIND_IMAGE }}
|
||||
@@ -55,7 +55,7 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install chart-releaser
|
||||
|
||||
82
.github/workflows/release-please.yaml
vendored
Normal file
82
.github/workflows/release-please.yaml
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
name: Release Please
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 'release/v*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
description: 'Release version without the "v" prefix (e.g., 0.51.0)'
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
release-please:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ !startsWith(github.event.head_commit.message, 'release:') && !github.event.inputs.version }}
|
||||
steps:
|
||||
- name: Release Please
|
||||
id: release
|
||||
uses: googleapis/release-please-action@v4
|
||||
with:
|
||||
token: ${{ secrets.ORG_REPO_TOKEN }}
|
||||
target-branch: ${{ github.ref_name }}
|
||||
|
||||
manual-release-please:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event.inputs.version }}
|
||||
steps:
|
||||
- name: Install Release Please CLI
|
||||
run: npm install release-please -g
|
||||
|
||||
- name: Release Please
|
||||
run: |
|
||||
release-please release-pr --repo-url=${{ github.server_url }}/${{ github.repository }} \
|
||||
--token=${{ secrets.ORG_REPO_TOKEN }} \
|
||||
--release-as=${{ github.event.inputs.version }} \
|
||||
--target-branch=${{ github.ref_name }}
|
||||
|
||||
release-tag:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ startsWith(github.event.head_commit.message, 'release:') }}
|
||||
steps:
|
||||
# Since skip-github-release is specified, the outputs of googleapis/release-please-action cannot be used.
|
||||
# Therefore, we need to parse the version ourselves.
|
||||
- name: Extract version and PR number from commit message
|
||||
id: extract_info
|
||||
shell: bash
|
||||
run: |
|
||||
echo "version=$( echo "${{ github.event.head_commit.message }}" | sed 's/^release: v\([0-9]\+\.[0-9]\+\.[0-9]\+\).*$/\1/' )" >> $GITHUB_OUTPUT
|
||||
echo "pr_number=$( echo "${{ github.event.head_commit.message }}" | sed 's/.*(\#\([0-9]\+\)).*$/\1/' )" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Tag release
|
||||
if: ${{ steps.extract_info.outputs.version }}
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.ORG_REPO_TOKEN }}
|
||||
script: |
|
||||
await github.rest.git.createRef({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
ref: `refs/tags/v${{ steps.extract_info.outputs.version }}`,
|
||||
sha: context.sha
|
||||
});
|
||||
|
||||
# Since skip-github-release is specified, googleapis/release-please-action doesn't delete the label from PR.
|
||||
# This label prevents the subsequent PRs from being created. Therefore, we need to delete it ourselves.
|
||||
# cf. https://github.com/googleapis/release-please?tab=readme-ov-file#release-please-bot-does-not-create-a-release-pr-why
|
||||
- name: Remove the label from PR
|
||||
if: ${{ steps.extract_info.outputs.pr_number }}
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.ORG_REPO_TOKEN }}
|
||||
script: |
|
||||
const prNumber = parseInt('${{ steps.extract_info.outputs.pr_number }}', 10);
|
||||
github.rest.issues.removeLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: prNumber,
|
||||
name: 'autorelease: pending'
|
||||
});
|
||||
6
.github/workflows/release.yaml
vendored
6
.github/workflows/release.yaml
vendored
@@ -19,12 +19,12 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Restore Trivy binaries from cache
|
||||
uses: actions/cache@v4.0.0
|
||||
uses: actions/cache@v4.0.2
|
||||
with:
|
||||
path: dist/
|
||||
key: ${{ runner.os }}-bins-${{github.workflow}}-${{github.sha}}
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
sudo apt-get -y install rpm reprepro createrepo-c distro-info
|
||||
|
||||
- name: Checkout trivy-repo
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.6
|
||||
with:
|
||||
repository: ${{ github.repository_owner }}/trivy-repo
|
||||
path: trivy-repo
|
||||
|
||||
16
.github/workflows/reusable-release.yaml
vendored
16
.github/workflows/reusable-release.yaml
vendored
@@ -14,6 +14,7 @@ on:
|
||||
|
||||
env:
|
||||
GH_USER: "aqua-bot"
|
||||
GO_VERSION: '1.22'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
@@ -36,7 +37,7 @@ jobs:
|
||||
remove-haskell: 'true'
|
||||
|
||||
- name: Cosign install
|
||||
uses: sigstore/cosign-installer@e1523de7571e31dbe865fd2e80c5c7c23ae71eb4
|
||||
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
@@ -69,14 +70,15 @@ jobs:
|
||||
password: ${{ secrets.ECR_SECRET_ACCESS_KEY }}
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache: false # Disable cache to avoid free space issues during `Post Setup Go` step.
|
||||
|
||||
- name: Generate SBOM
|
||||
uses: CycloneDX/gh-gomod-generate-sbom@v2
|
||||
@@ -90,6 +92,11 @@ jobs:
|
||||
run: |
|
||||
echo "$GPG_KEY" > gpg.key
|
||||
|
||||
# Create tmp dir for GoReleaser
|
||||
- name: "create tmp dir"
|
||||
run: |
|
||||
mkdir tmp
|
||||
|
||||
- name: GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v5
|
||||
with:
|
||||
@@ -99,6 +106,7 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.ORG_REPO_TOKEN }}
|
||||
NFPM_DEFAULT_RPM_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
|
||||
GPG_FILE: "gpg.key"
|
||||
TMPDIR: "tmp"
|
||||
|
||||
- name: "remove gpg key"
|
||||
run: |
|
||||
@@ -121,7 +129,7 @@ jobs:
|
||||
public.ecr.aws/aquasecurity/trivy:canary
|
||||
|
||||
- name: Cache Trivy binaries
|
||||
uses: actions/cache@v4.0.0
|
||||
uses: actions/cache@v4.0.2
|
||||
with:
|
||||
path: dist/
|
||||
# use 'github.sha' to create a unique cache folder for each run.
|
||||
|
||||
8
.github/workflows/roadmap.yaml
vendored
8
.github/workflows/roadmap.yaml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# 'kind/feature' AND 'priority/backlog' labels -> 'Backlog' column
|
||||
- uses: actions/add-to-project@v0.4.1 # add new issue to project
|
||||
- uses: actions/add-to-project@v1.0.1 # add new issue to project
|
||||
with:
|
||||
project-url: https://github.com/orgs/aquasecurity/projects/25
|
||||
github-token: ${{ secrets.ORG_PROJECT_TOKEN }}
|
||||
@@ -28,7 +28,7 @@ jobs:
|
||||
field-values: Backlog
|
||||
|
||||
# 'kind/feature' AND 'priority/important-longterm' labels -> 'Important (long-term)' column
|
||||
- uses: actions/add-to-project@v0.4.1 # add new issue to project
|
||||
- uses: actions/add-to-project@v1.0.1 # add new issue to project
|
||||
with:
|
||||
project-url: https://github.com/orgs/aquasecurity/projects/25
|
||||
github-token: ${{ secrets.ORG_PROJECT_TOKEN }}
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
field-values: Important (long-term)
|
||||
|
||||
# 'kind/feature' AND 'priority/important-soon' labels -> 'Important (soon)' column
|
||||
- uses: actions/add-to-project@v0.4.1 # add new issue to project
|
||||
- uses: actions/add-to-project@v1.0.1 # add new issue to project
|
||||
with:
|
||||
project-url: https://github.com/orgs/aquasecurity/projects/25
|
||||
github-token: ${{ secrets.ORG_PROJECT_TOKEN }}
|
||||
@@ -62,7 +62,7 @@ jobs:
|
||||
field-values: Important (soon)
|
||||
|
||||
# 'kind/feature' AND 'priority/critical-urgent' labels -> 'Urgent' column
|
||||
- uses: actions/add-to-project@v0.4.1 # add new issue to project
|
||||
- uses: actions/add-to-project@v1.0.1 # add new issue to project
|
||||
with:
|
||||
project-url: https://github.com/orgs/aquasecurity/projects/25
|
||||
github-token: ${{ secrets.ORG_PROJECT_TOKEN }}
|
||||
|
||||
4
.github/workflows/scan.yaml
vendored
4
.github/workflows/scan.yaml
vendored
@@ -10,10 +10,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.6
|
||||
|
||||
- name: Run Trivy vulnerability scanner and create GitHub issues
|
||||
uses: knqyf263/trivy-issue-action@v0.0.5
|
||||
uses: knqyf263/trivy-issue-action@v0.0.6
|
||||
with:
|
||||
assignee: knqyf263
|
||||
severity: CRITICAL
|
||||
|
||||
5
.github/workflows/semantic-pr.yaml
vendored
5
.github/workflows/semantic-pr.yaml
vendored
@@ -28,6 +28,7 @@ jobs:
|
||||
ci
|
||||
chore
|
||||
revert
|
||||
release
|
||||
BREAKING
|
||||
|
||||
scopes: |
|
||||
@@ -44,6 +45,7 @@ jobs:
|
||||
k8s
|
||||
aws
|
||||
vm
|
||||
plugin
|
||||
|
||||
alpine
|
||||
wolfi
|
||||
@@ -75,6 +77,8 @@ jobs:
|
||||
dart
|
||||
swift
|
||||
bitnami
|
||||
conda
|
||||
julia
|
||||
|
||||
os
|
||||
lang
|
||||
@@ -100,4 +104,5 @@ jobs:
|
||||
helm
|
||||
report
|
||||
db
|
||||
parser
|
||||
deps
|
||||
|
||||
2
.github/workflows/test-docs.yaml
vendored
2
.github/workflows/test-docs.yaml
vendored
@@ -10,7 +10,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: true
|
||||
|
||||
54
.github/workflows/test.yaml
vendored
54
.github/workflows/test.yaml
vendored
@@ -7,6 +7,8 @@ on:
|
||||
- 'mkdocs.yml'
|
||||
- 'LICENSE'
|
||||
merge_group:
|
||||
env:
|
||||
GO_VERSION: '1.22'
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
@@ -15,13 +17,22 @@ jobs:
|
||||
matrix:
|
||||
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- name: Maximize build space
|
||||
uses: easimon/maximize-build-space@v10
|
||||
with:
|
||||
root-reserve-mb: 32768 # The golangci-lint uses a lot of space.
|
||||
remove-android: "true"
|
||||
remove-docker-images: "true"
|
||||
remove-dotnet: "true"
|
||||
remove-haskell: "true"
|
||||
if: matrix.operating-system == 'ubuntu-latest'
|
||||
|
||||
- uses: actions/checkout@v4.1.6
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
- name: go mod tidy
|
||||
run: |
|
||||
go mod tidy
|
||||
@@ -33,11 +44,10 @@ jobs:
|
||||
|
||||
- name: Lint
|
||||
id: lint
|
||||
uses: golangci/golangci-lint-action@v3.7.0
|
||||
uses: golangci/golangci-lint-action@v6.0.1
|
||||
with:
|
||||
version: v1.54
|
||||
args: --deadline=30m --out-format=line-number
|
||||
skip-cache: true # https://github.com/golangci/golangci-lint-action/issues/244#issuecomment-1052197778
|
||||
version: v1.58
|
||||
args: --verbose --out-format=line-number
|
||||
if: matrix.operating-system == 'ubuntu-latest'
|
||||
|
||||
- name: Check if linter failed
|
||||
@@ -47,7 +57,7 @@ jobs:
|
||||
if: ${{ failure() && steps.lint.conclusion == 'failure' }}
|
||||
|
||||
- name: Install tools
|
||||
uses: aquaproj/aqua-installer@v2.2.0
|
||||
uses: aquaproj/aqua-installer@v3.0.1
|
||||
with:
|
||||
aqua_version: v1.25.0
|
||||
aqua_opts: ""
|
||||
@@ -69,15 +79,15 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.6
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Install tools
|
||||
uses: aquaproj/aqua-installer@v2.2.0
|
||||
uses: aquaproj/aqua-installer@v3.0.1
|
||||
with:
|
||||
aqua_version: v1.25.0
|
||||
|
||||
@@ -98,15 +108,15 @@ jobs:
|
||||
remove-haskell: "true"
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.6
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Install tools
|
||||
uses: aquaproj/aqua-installer@v2.2.0
|
||||
uses: aquaproj/aqua-installer@v3.0.1
|
||||
with:
|
||||
aqua_version: v1.25.0
|
||||
|
||||
@@ -118,15 +128,15 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.6
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Install tools
|
||||
uses: aquaproj/aqua-installer@v2.2.0
|
||||
uses: aquaproj/aqua-installer@v3.0.1
|
||||
with:
|
||||
aqua_version: v1.25.0
|
||||
|
||||
@@ -149,14 +159,14 @@ jobs:
|
||||
remove-haskell: 'true'
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.6
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
- name: Install tools
|
||||
uses: aquaproj/aqua-installer@v2.2.0
|
||||
uses: aquaproj/aqua-installer@v3.0.1
|
||||
with:
|
||||
aqua_version: v1.25.0
|
||||
- name: Run vm integration tests
|
||||
@@ -183,12 +193,12 @@ jobs:
|
||||
if: matrix.operating-system == 'ubuntu-latest'
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.6
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Determine GoReleaser ID
|
||||
id: goreleaser_id
|
||||
|
||||
155
.golangci.yaml
155
.golangci.yaml
@@ -1,30 +1,9 @@
|
||||
linters-settings:
|
||||
dupl:
|
||||
threshold: 100
|
||||
errcheck:
|
||||
check-type-assertions: true
|
||||
check-blank: true
|
||||
govet:
|
||||
check-shadowing: false
|
||||
gofmt:
|
||||
simplify: false
|
||||
revive:
|
||||
ignore-generated-header: true
|
||||
gocyclo:
|
||||
min-complexity: 20
|
||||
dupl:
|
||||
threshold: 100
|
||||
goconst:
|
||||
min-len: 3
|
||||
min-occurrences: 3
|
||||
misspell:
|
||||
locale: US
|
||||
ignore-words:
|
||||
- licence
|
||||
gosec:
|
||||
excludes:
|
||||
- G101
|
||||
- G114
|
||||
- G204
|
||||
- G402
|
||||
gci:
|
||||
sections:
|
||||
- standard
|
||||
@@ -32,17 +11,9 @@ linters-settings:
|
||||
- prefix(github.com/aquasecurity/)
|
||||
- blank
|
||||
- dot
|
||||
gomodguard:
|
||||
blocked:
|
||||
modules:
|
||||
- github.com/hashicorp/go-version:
|
||||
recommendations:
|
||||
- github.com/aquasecurity/go-version
|
||||
reason: "`aquasecurity/go-version` is designed for our use-cases"
|
||||
- github.com/Masterminds/semver:
|
||||
recommendations:
|
||||
- github.com/aquasecurity/go-version
|
||||
reason: "`aquasecurity/go-version` is designed for our use-cases"
|
||||
goconst:
|
||||
min-len: 3
|
||||
min-occurrences: 3
|
||||
gocritic:
|
||||
disabled-checks:
|
||||
- appendAssign
|
||||
@@ -65,53 +36,99 @@ linters-settings:
|
||||
ruleguard:
|
||||
failOn: all
|
||||
rules: '${configDir}/misc/lint/rules.go'
|
||||
gocyclo:
|
||||
min-complexity: 20
|
||||
gofmt:
|
||||
simplify: false
|
||||
rewrite-rules:
|
||||
- pattern: 'interface{}'
|
||||
replacement: 'any'
|
||||
gomodguard:
|
||||
blocked:
|
||||
modules:
|
||||
- github.com/hashicorp/go-version:
|
||||
recommendations:
|
||||
- github.com/aquasecurity/go-version
|
||||
reason: "`aquasecurity/go-version` is designed for our use-cases"
|
||||
- github.com/Masterminds/semver:
|
||||
recommendations:
|
||||
- github.com/aquasecurity/go-version
|
||||
reason: "`aquasecurity/go-version` is designed for our use-cases"
|
||||
gosec:
|
||||
excludes:
|
||||
- G101
|
||||
- G114
|
||||
- G204
|
||||
- G304
|
||||
- G402
|
||||
govet:
|
||||
check-shadowing: false
|
||||
misspell:
|
||||
locale: US
|
||||
ignore-words:
|
||||
- behaviour
|
||||
- licence
|
||||
- optimise
|
||||
- simmilar
|
||||
revive:
|
||||
ignore-generated-header: true
|
||||
testifylint:
|
||||
enable-all: true
|
||||
disable:
|
||||
- float-compare
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- unused
|
||||
- ineffassign
|
||||
- typecheck
|
||||
- govet
|
||||
- revive
|
||||
- gosec
|
||||
- unconvert
|
||||
- goconst
|
||||
- gocyclo
|
||||
- gofmt
|
||||
- misspell
|
||||
- bodyclose
|
||||
- gci
|
||||
- gomodguard
|
||||
- tenv
|
||||
- goconst
|
||||
- gocritic
|
||||
- gocyclo
|
||||
- gofmt
|
||||
- gomodguard
|
||||
- gosec
|
||||
- govet
|
||||
- ineffassign
|
||||
- misspell
|
||||
- revive
|
||||
- tenv
|
||||
- testifylint
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unused
|
||||
|
||||
run:
|
||||
go: '1.21'
|
||||
skip-files:
|
||||
- ".*_mock.go$"
|
||||
- ".*_test.go$"
|
||||
- "integration/*"
|
||||
- "examples/*"
|
||||
go: '1.22'
|
||||
timeout: 30m
|
||||
|
||||
issues:
|
||||
exclude-files:
|
||||
- "mock_*.go$"
|
||||
- "examples/*"
|
||||
exclude-dirs:
|
||||
- "pkg/iac/scanners/terraform/parser/funcs" # copies of Terraform functions
|
||||
exclude-rules:
|
||||
- linters:
|
||||
- path: ".*_test.go$"
|
||||
linters:
|
||||
- goconst
|
||||
- gosec
|
||||
text: "G304: Potential file inclusion"
|
||||
- linters:
|
||||
- gosec
|
||||
text: "Deferring unsafe method"
|
||||
- linters:
|
||||
- errcheck
|
||||
text: "Close` is not checked"
|
||||
- linters:
|
||||
- errcheck
|
||||
text: "os.*` is not checked"
|
||||
- linters:
|
||||
- golint
|
||||
text: "a blank import should be only in a main or test package"
|
||||
exclude:
|
||||
- "should have a package comment, unless it's in another file for this package"
|
||||
- unused
|
||||
- path: ".*_test.go$"
|
||||
linters:
|
||||
- govet
|
||||
text: "copylocks:"
|
||||
- path: ".*_test.go$"
|
||||
linters:
|
||||
- gocritic
|
||||
text: "commentFormatting:"
|
||||
- path: ".*_test.go$"
|
||||
linters:
|
||||
- gocritic
|
||||
text: "exitAfterDefer:"
|
||||
- path: ".*_test.go$"
|
||||
linters:
|
||||
- gocritic
|
||||
text: "importShadow:"
|
||||
exclude-use-default: false
|
||||
max-same-issues: 0
|
||||
|
||||
1
.release-please-manifest.json
Normal file
1
.release-please-manifest.json
Normal file
@@ -0,0 +1 @@
|
||||
{".":"0.52.1"}
|
||||
60
CHANGELOG.md
Normal file
60
CHANGELOG.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# Changelog
|
||||
|
||||
## [0.52.1](https://github.com/aquasecurity/trivy/compare/v0.52.0...v0.52.1) (2024-06-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **nodejs:** fix infinite loop when package link from `package-lock.json` file is broken [backport: release/v0.52] ([#6888](https://github.com/aquasecurity/trivy/issues/6888)) ([01dbb42](https://github.com/aquasecurity/trivy/commit/01dbb42ae9ecff21d1c71f095a27f47a6ac9adaa))
|
||||
* **nodejs:** fix infinity loops for `pnpm` with cyclic imports ([#6857](https://github.com/aquasecurity/trivy/issues/6857)) ([a614b69](https://github.com/aquasecurity/trivy/commit/a614b693d7b948df7d4ed3516e79573cb8424406))
|
||||
* **python:** compare pkg names from `poetry.lock` and `pyproject.toml` in lowercase [backport: release/v0.52] ([#6878](https://github.com/aquasecurity/trivy/issues/6878)) ([093c0ae](https://github.com/aquasecurity/trivy/commit/093c0ae020548bf6f3d1896d4d55210eb42c7b0e))
|
||||
* **sbom:** don't overwrite `srcEpoch` when decoding SBOM files [backport: release/v0.52] ([#6881](https://github.com/aquasecurity/trivy/issues/6881)) ([f186d22](https://github.com/aquasecurity/trivy/commit/f186d22bf275e872bd664f07131604f6a0216f20))
|
||||
|
||||
## [0.52.0](https://github.com/aquasecurity/trivy/compare/v0.51.1...v0.52.0) (2024-06-03)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Add Julia language analyzer support ([#5635](https://github.com/aquasecurity/trivy/issues/5635)) ([fecafb1](https://github.com/aquasecurity/trivy/commit/fecafb1fc5bb129c7485342a0775f0dd8bedd28e))
|
||||
* add support for plugin index ([#6674](https://github.com/aquasecurity/trivy/issues/6674)) ([26faf8f](https://github.com/aquasecurity/trivy/commit/26faf8f3f04b1c5f9f81c03ffc6b2008732207e2))
|
||||
* **misconf:** Add support for deprecating a check ([#6664](https://github.com/aquasecurity/trivy/issues/6664)) ([88702cf](https://github.com/aquasecurity/trivy/commit/88702cfd5918b093defc5b5580f7cbf16f5f2417))
|
||||
* **misconf:** add Terraform 'removed' block to schema ([#6640](https://github.com/aquasecurity/trivy/issues/6640)) ([b7a0a13](https://github.com/aquasecurity/trivy/commit/b7a0a131a03ed49c08d3b0d481bc9284934fd6e1))
|
||||
* **misconf:** register builtin Rego funcs from trivy-checks ([#6616](https://github.com/aquasecurity/trivy/issues/6616)) ([7c22ee3](https://github.com/aquasecurity/trivy/commit/7c22ee3df5ee51beb90e44428a99541b3d19ab98))
|
||||
* **misconf:** resolve tf module from OpenTofu compatible registry ([#6743](https://github.com/aquasecurity/trivy/issues/6743)) ([ac74520](https://github.com/aquasecurity/trivy/commit/ac7452009bf7ca0fa8ee1de8807c792eabad405a))
|
||||
* **misconf:** support for VPC resources for inbound/outbound rules ([#6779](https://github.com/aquasecurity/trivy/issues/6779)) ([349caf9](https://github.com/aquasecurity/trivy/commit/349caf96bc3dd81551d488044f1adfdb947f39fb))
|
||||
* **misconf:** support symlinks inside of Helm archives ([#6621](https://github.com/aquasecurity/trivy/issues/6621)) ([4eae37c](https://github.com/aquasecurity/trivy/commit/4eae37c52b035b3576361c12f70d3d9517d0a73c))
|
||||
* **nodejs:** add v9 pnpm lock file support ([#6617](https://github.com/aquasecurity/trivy/issues/6617)) ([1e08648](https://github.com/aquasecurity/trivy/commit/1e0864842e32a709941d4b4e8f521602bcee684d))
|
||||
* **plugin:** specify plugin version ([#6683](https://github.com/aquasecurity/trivy/issues/6683)) ([d6dc567](https://github.com/aquasecurity/trivy/commit/d6dc56732babbc9d7f788c280a768d8648aa093d))
|
||||
* **python:** add license support for `requirement.txt` files ([#6782](https://github.com/aquasecurity/trivy/issues/6782)) ([29615be](https://github.com/aquasecurity/trivy/commit/29615be85e8bfeaf5a0cd51829b1898c55fa4274))
|
||||
* **python:** add line number support for `requirement.txt` files ([#6729](https://github.com/aquasecurity/trivy/issues/6729)) ([2bc54ad](https://github.com/aquasecurity/trivy/commit/2bc54ad2752aba5de4380cb92c13b09c0abefd73))
|
||||
* **report:** Include licenses and secrets filtered by rego to ModifiedFindings ([#6483](https://github.com/aquasecurity/trivy/issues/6483)) ([fa3cf99](https://github.com/aquasecurity/trivy/commit/fa3cf993eace4be793f85907b42365269c597b91))
|
||||
* **vex:** improve relationship support in CSAF VEX ([#6735](https://github.com/aquasecurity/trivy/issues/6735)) ([a447f6b](https://github.com/aquasecurity/trivy/commit/a447f6ba94b6f8b14177dc5e4369a788e2020d90))
|
||||
* **vex:** support non-root components for products in OpenVEX ([#6728](https://github.com/aquasecurity/trivy/issues/6728)) ([9515695](https://github.com/aquasecurity/trivy/commit/9515695d45e9b5c20890e27e21e3ab45bfd4ce5f))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* clean up golangci lint configuration ([#6797](https://github.com/aquasecurity/trivy/issues/6797)) ([62de6f3](https://github.com/aquasecurity/trivy/commit/62de6f3feba6e4c56ad3922441d5b0f150c3d6b7))
|
||||
* **cli:** always output fatal errors to stderr ([#6827](https://github.com/aquasecurity/trivy/issues/6827)) ([c2b9132](https://github.com/aquasecurity/trivy/commit/c2b9132a7e933a68df4cc0eb86aab23719ded1b5))
|
||||
* close APKINDEX archive file ([#6672](https://github.com/aquasecurity/trivy/issues/6672)) ([5caf437](https://github.com/aquasecurity/trivy/commit/5caf4377f3a7fcb1f6e1a84c67136ae62d100be3))
|
||||
* close settings.xml ([#6768](https://github.com/aquasecurity/trivy/issues/6768)) ([9c3e895](https://github.com/aquasecurity/trivy/commit/9c3e895fcb0852c00ac03ed21338768f76b5273b))
|
||||
* close testfile ([#6830](https://github.com/aquasecurity/trivy/issues/6830)) ([aa0c413](https://github.com/aquasecurity/trivy/commit/aa0c413814e8915b38d2285c6a8ba5bc3f0705b4))
|
||||
* **conda:** add support `pip` deps for `environment.yml` files ([#6675](https://github.com/aquasecurity/trivy/issues/6675)) ([150a773](https://github.com/aquasecurity/trivy/commit/150a77313e980cd63797a89a03afcbc97b285f38))
|
||||
* **go:** add only non-empty root modules for `gobinaries` ([#6710](https://github.com/aquasecurity/trivy/issues/6710)) ([c96f2a5](https://github.com/aquasecurity/trivy/commit/c96f2a5b3de820da37e14594dd537c3b0949ae9c))
|
||||
* **go:** include only `.version`|`.ver` (no prefixes) ldflags for `gobinaries` ([#6705](https://github.com/aquasecurity/trivy/issues/6705)) ([afb4f9d](https://github.com/aquasecurity/trivy/commit/afb4f9dc4730671ba004e1734fa66422c4c86dad))
|
||||
* Golang version parsing from binaries w/GOEXPERIMENT ([#6696](https://github.com/aquasecurity/trivy/issues/6696)) ([696f2ae](https://github.com/aquasecurity/trivy/commit/696f2ae0ecdd4f90303f41249924a09ace70dd78))
|
||||
* include packages unless it is not needed ([#6765](https://github.com/aquasecurity/trivy/issues/6765)) ([56dbe1f](https://github.com/aquasecurity/trivy/commit/56dbe1f6768fe67fbc1153b74fde0f83eaa1b281))
|
||||
* **misconf:** don't shift ignore rule related to code ([#6708](https://github.com/aquasecurity/trivy/issues/6708)) ([39a746c](https://github.com/aquasecurity/trivy/commit/39a746c77837f873e87b81be40676818030f44c5))
|
||||
* **misconf:** skip Rego errors with a nil location ([#6638](https://github.com/aquasecurity/trivy/issues/6638)) ([a2c522d](https://github.com/aquasecurity/trivy/commit/a2c522ddb229f049999c4ce74ef75a0e0f9fdc62))
|
||||
* **misconf:** skip Rego errors with a nil location ([#6666](https://github.com/aquasecurity/trivy/issues/6666)) ([a126e10](https://github.com/aquasecurity/trivy/commit/a126e1075a44ef0e40c0dc1e214d1c5955f80242))
|
||||
* node-collector high and critical cves ([#6707](https://github.com/aquasecurity/trivy/issues/6707)) ([ff32deb](https://github.com/aquasecurity/trivy/commit/ff32deb7bf9163c06963f557228260b3b8c161ed))
|
||||
* **plugin:** initialize logger ([#6836](https://github.com/aquasecurity/trivy/issues/6836)) ([728e77a](https://github.com/aquasecurity/trivy/commit/728e77a7261dc3fcda1e61e79be066c789bbba0c))
|
||||
* **python:** add package name and version validation for `requirements.txt` files. ([#6804](https://github.com/aquasecurity/trivy/issues/6804)) ([ea3a124](https://github.com/aquasecurity/trivy/commit/ea3a124fc7162c30c7f1a59bdb28db0b3c8bb86d))
|
||||
* **report:** hide empty tables if all vulns has been filtered ([#6352](https://github.com/aquasecurity/trivy/issues/6352)) ([3d388d8](https://github.com/aquasecurity/trivy/commit/3d388d8552ef42d4d54176309a38c1879008527b))
|
||||
* **sbom:** fix panic for `convert` mode when scanning json file derived from sbom file ([#6808](https://github.com/aquasecurity/trivy/issues/6808)) ([f92ea09](https://github.com/aquasecurity/trivy/commit/f92ea096856c7c262b05bd4d31c62689ebafac82))
|
||||
* use of specified context to obtain cluster name ([#6645](https://github.com/aquasecurity/trivy/issues/6645)) ([39ebed4](https://github.com/aquasecurity/trivy/commit/39ebed45f8c218509d264bd3f3ca548fc33d2b3a))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **misconf:** parse rego input once ([#6615](https://github.com/aquasecurity/trivy/issues/6615)) ([67c6b1d](https://github.com/aquasecurity/trivy/commit/67c6b1d473999003d682bdb42657bbf3a4a69a9c))
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM alpine:3.19.1
|
||||
FROM alpine:3.20.0
|
||||
RUN apk --no-cache add ca-certificates git
|
||||
COPY trivy /usr/local/bin/trivy
|
||||
COPY contrib/*.tpl contrib/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM alpine:3.19.1
|
||||
FROM alpine:3.20.0
|
||||
RUN apk --no-cache add ca-certificates git
|
||||
|
||||
# binaries were created with GoReleaser
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM --platform=linux/amd64 golang:1.21
|
||||
FROM --platform=linux/amd64 golang:1.22
|
||||
|
||||
# Set environment variable for protoc
|
||||
ENV PROTOC_ZIP=protoc-3.19.4-linux-x86_64.zip
|
||||
@@ -14,7 +14,7 @@ RUN curl --retry 5 -OL https://github.com/protocolbuffers/protobuf/releases/down
|
||||
|
||||
# Install Go tools
|
||||
RUN go install github.com/twitchtv/twirp/protoc-gen-twirp@v8.1.0
|
||||
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1
|
||||
RUN go install github.com/magefile/mage@v1.14.0
|
||||
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.0
|
||||
RUN go install github.com/magefile/mage@v1.15.0
|
||||
|
||||
ENV TRIVY_PROTOC_CONTAINER=true
|
||||
|
||||
@@ -5,6 +5,6 @@ registries:
|
||||
- type: standard
|
||||
ref: v3.157.0 # renovate: depName=aquaproj/aqua-registry
|
||||
packages:
|
||||
- name: tinygo-org/tinygo@v0.29.0
|
||||
- name: tinygo-org/tinygo@v0.31.1
|
||||
- name: WebAssembly/binaryen@version_112
|
||||
- name: magefile/mage@v1.14.0
|
||||
|
||||
@@ -5,14 +5,14 @@ UBUNTU_RELEASES=$(sort -u <(ubuntu-distro-info --supported-esm) <(ubuntu-distro-
|
||||
|
||||
cd trivy-repo/deb
|
||||
|
||||
for release in ${DEBIAN_RELEASES[@]} ${UBUNTU_RELEASES[@]}; do
|
||||
for release in generic ${DEBIAN_RELEASES[@]} ${UBUNTU_RELEASES[@]}; do
|
||||
echo "Removing deb package of $release"
|
||||
reprepro -A i386 remove $release trivy
|
||||
reprepro -A amd64 remove $release trivy
|
||||
reprepro -A arm64 remove $release trivy
|
||||
done
|
||||
|
||||
for release in ${DEBIAN_RELEASES[@]} ${UBUNTU_RELEASES[@]}; do
|
||||
for release in generic ${DEBIAN_RELEASES[@]} ${UBUNTU_RELEASES[@]}; do
|
||||
echo "Adding deb package to $release"
|
||||
reprepro includedeb $release ../../dist/*Linux-32bit.deb
|
||||
reprepro includedeb $release ../../dist/*Linux-64bit.deb
|
||||
|
||||
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
@@ -9,23 +10,26 @@ import (
|
||||
"github.com/aquasecurity/trivy/pkg/commands"
|
||||
"github.com/aquasecurity/trivy/pkg/log"
|
||||
"github.com/aquasecurity/trivy/pkg/plugin"
|
||||
"github.com/aquasecurity/trivy/pkg/types"
|
||||
|
||||
_ "modernc.org/sqlite" // sqlite driver for RPM DB and Java DB
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := run(); err != nil {
|
||||
log.Fatal(err)
|
||||
var exitError *types.ExitError
|
||||
if errors.As(err, &exitError) {
|
||||
os.Exit(exitError.Code)
|
||||
}
|
||||
log.Fatal("Fatal error", log.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
func run() error {
|
||||
// Trivy behaves as the specified plugin.
|
||||
if runAsPlugin := os.Getenv("TRIVY_RUN_AS_PLUGIN"); runAsPlugin != "" {
|
||||
if !plugin.IsPredefined(runAsPlugin) {
|
||||
return xerrors.Errorf("unknown plugin: %s", runAsPlugin)
|
||||
}
|
||||
if err := plugin.RunWithURL(context.Background(), runAsPlugin, plugin.RunOptions{Args: os.Args[1:]}); err != nil {
|
||||
log.InitLogger(false, false)
|
||||
if err := plugin.Run(context.Background(), runAsPlugin, plugin.Options{Args: os.Args[1:]}); err != nil {
|
||||
return xerrors.Errorf("plugin error: %w", err)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -56,3 +56,21 @@ ignore {
|
||||
# https://cwe.mitre.org/data/definitions/352.html
|
||||
input.CweIDs[_] == "CWE-352"
|
||||
}
|
||||
|
||||
# Ignore a license
|
||||
ignore {
|
||||
input.PkgName == "alpine-baselayout"
|
||||
input.Name == "GPL-2.0"
|
||||
}
|
||||
|
||||
# Ignore loose file license
|
||||
ignore {
|
||||
input.Name == "AGPL-3.0"
|
||||
input.FilePath == "/usr/share/grafana/LICENSE"
|
||||
}
|
||||
|
||||
# Ignore secret
|
||||
ignore {
|
||||
input.RuleID == "aws-access-key-id"
|
||||
input.Match == "AWS_ACCESS_KEY_ID=\"********************\""
|
||||
}
|
||||
|
||||
@@ -73,8 +73,11 @@
|
||||
{{- /* TODO: Type not extractable - https://github.com/aquasecurity/trivy-db/pull/24 */}}
|
||||
"type": "cve",
|
||||
"name": "{{ .VulnerabilityID }}",
|
||||
"value": "{{ .VulnerabilityID }}",
|
||||
"value": "{{ .VulnerabilityID }}"
|
||||
{{- /* cf. https://gitlab.com/gitlab-org/security-products/security-report-schemas/-/blob/e3d280d7f0862ca66a1555ea8b24016a004bb914/dist/container-scanning-report-format.json#L157-179 */}}
|
||||
{{- if .PrimaryURL | regexMatch "^(https?|ftp)://.+" -}},
|
||||
"url": "{{ .PrimaryURL }}"
|
||||
{{- end }}
|
||||
}
|
||||
],
|
||||
"links": [
|
||||
@@ -85,9 +88,13 @@
|
||||
{{- else -}}
|
||||
,
|
||||
{{- end -}}
|
||||
{{- if . | regexMatch "^(https?|ftp)://.+" -}}
|
||||
{
|
||||
"url": "{{ regexFind "[^ ]+" . }}"
|
||||
"url": "{{ . }}"
|
||||
}
|
||||
{{- else -}}
|
||||
{{- $l_first = true }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
]
|
||||
}
|
||||
|
||||
130
docs/community/contribute/checks/overview.md
Normal file
130
docs/community/contribute/checks/overview.md
Normal file
@@ -0,0 +1,130 @@
|
||||
# Contribute Rego Checks
|
||||
|
||||
The following guide provides an overview of contributing checks to the default checks in Trivy.
|
||||
|
||||
All of the checks in Trivy can be found in the [trivy-checks](https://github.com/aquasecurity/trivy-checks/tree/main) repository on GitHub. Before you begin writing a check, ensure:
|
||||
|
||||
1. The check does not already exist as part of the default checks in the [trivy-checks](https://github.com/aquasecurity/trivy-checks/tree/main) repository.
|
||||
2. The pull requests in the [trivy-checks](https://github.com/aquasecurity/trivy-checks/pulls) repository to see whether someone else is already contributing the check that you wanted to add.
|
||||
3. The [issues in Trivy](https://github.com/aquasecurity/trivy/issues) to see whether any specific checks are missing in Trivy that you can contribute.
|
||||
|
||||
If anything is unclear, please [start a discussion](https://github.com/aquasecurity/trivy/discussions/new) and we will do our best to help.
|
||||
|
||||
## Check structure
|
||||
|
||||
Checks are written in Rego and follow a particular structure in Trivy. Below is an example check for AWS:
|
||||
|
||||
```rego
|
||||
# METADATA
|
||||
# title: "RDS IAM Database Authentication Disabled"
|
||||
# description: "Ensure IAM Database Authentication is enabled for RDS database instances to manage database access"
|
||||
# scope: package
|
||||
# schemas:
|
||||
# - input: schema["aws"]
|
||||
# related_resources:
|
||||
# - https://docs.aws.amazon.com/neptune/latest/userguide/iam-auth.html
|
||||
# custom:
|
||||
# id: AVD-AWS-0176
|
||||
# avd_id: AVD-AWS-0176
|
||||
# provider: aws
|
||||
# service: rds
|
||||
# severity: MEDIUM
|
||||
# short_code: enable-iam-auth
|
||||
# recommended_action: "Modify the PostgreSQL and MySQL type RDS instances to enable IAM database authentication."
|
||||
# input:
|
||||
# selector:
|
||||
# - type: cloud
|
||||
# subtypes:
|
||||
# - service: rds
|
||||
# provider: aws
|
||||
|
||||
package builtin.aws.rds.aws0176
|
||||
|
||||
deny[res] {
|
||||
instance := input.aws.rds.instances[_]
|
||||
instance.engine.value == ["postgres", "mysql"][_]
|
||||
not instance.iamauthenabled.value
|
||||
res := result.new("Instance does not have IAM Authentication enabled", instance.iamauthenabled)
|
||||
}
|
||||
```
|
||||
|
||||
## Verify the provider and service exists
|
||||
|
||||
Every check for a cloud service references a cloud provider. The list of providers are found in the [Trivy](https://github.com/aquasecurity/trivy/tree/main/pkg/iac/providers) repository.
|
||||
|
||||
Before writing a new check for a cloud provider, you need to verify if the cloud provider or resource type that your check targets is supported by Trivy. If it's not, you'll need to add support for it. Additionally, if the provider that you want to target exists, you need to check whether the service your policy will target is supported. As a reference you can take a look at the AWS provider [here](https://github.com/aquasecurity/trivy/blob/main/pkg/iac/providers/aws/aws.go).
|
||||
|
||||
???+ note
|
||||
New Kubernetes and Dockerfile checks do not require any additional provider definitions. You can find an example of a Dockerfile check [here](https://github.com/aquasecurity/trivy-checks/blob/main/checks/docker/add_instead_of_copy.rego) and a Kubernetes check [here](https://github.com/aquasecurity/trivy-checks/blob/main/checks/kubernetes/general/CPU_not_limited.rego).
|
||||
|
||||
|
||||
### Add Support for a New Service in an existing Provider
|
||||
|
||||
[Please reference the documentation on adding Support for a New Service](./service-support.md).
|
||||
|
||||
This guide also showcases how to add new properties for an existing Service.
|
||||
|
||||
## Create a new .rego file
|
||||
|
||||
The following directory in the trivy-checks repository contains all of our custom checks. Depending on what type of check you want to create, you will need to nest a new `.rego` file in either of the [subdirectories](https://github.com/aquasecurity/trivy-checks/tree/main/checks):
|
||||
|
||||
* cloud: All checks related to cloud providers and their services
|
||||
* docker: Docker specific checks
|
||||
* kubernetes: Kubernetes specific checks
|
||||
|
||||
## Check Package name
|
||||
|
||||
Have a look at the existing package names in the [built in checks](https://github.com/aquasecurity/trivy-checks/tree/main/checks).
|
||||
|
||||
The package name should be in the format `builtin.PROVIDER.SERVICE.ID`, e.g. `builtin.aws.rds.aws0176`.
|
||||
|
||||
## Generating an ID
|
||||
|
||||
Every check has a custom ID that is referenced throughout the metadata of the check to uniquely identify the check. If you plan to contribue your check back into the [trivy-checks](https://github.com/aquasecurity/trivy-checks) repository, it will require a valid ID.
|
||||
|
||||
Running `make id` in the root of the trivy-checks repository will provide you with the next available _ID_ for your rule.
|
||||
|
||||
## Check Schemas
|
||||
|
||||
Rego Checks for Trivy can utilise Schemas to map the input to specific objects. The schemas available are listed [here.](https://github.com/aquasecurity/trivy/tree/main/pkg/iac/rego/schemas).
|
||||
|
||||
More information on using the builtin schemas is provided in the [main documentation.](../../../docs/scanner/misconfiguration/custom/schema.md)
|
||||
|
||||
## Check Metadata
|
||||
|
||||
The metadata is the top section that starts with `# METADATA`, and has to be placed on top of the check. You can copy and paste from another check as a starting point. This format is effectively _yaml_ within a Rego comment, and is [defined as part of Rego itself](https://www.openpolicyagent.org/docs/latest/policy-language/#metadata).
|
||||
|
||||
For detailed information on each component of the Check Metadata, please refer to the [main documentation.](../../../docs/scanner/misconfiguration/custom/index.md)
|
||||
|
||||
Note that while the Metadata is optional in your own custom checks for Trivy, if you are contributing your check to the Trivy builtin checks, the Metadata section will be required.
|
||||
|
||||
|
||||
## Writing Rego Rules
|
||||
|
||||
Rules are defined using _OPA Rego_. You can find a number of examples in the `checks` directory ([Link](https://github.com/aquasecurity/trivy-checks/tree/main/checks)). The [OPA documentation](https://www.openpolicyagent.org/docs/latest/policy-language/) is a great place to start learning Rego. You can also check out the [Rego Playground](https://play.openpolicyagent.org/) to experiment with Rego, and [join the OPA Slack](https://slack.openpolicyagent.org/).
|
||||
|
||||
|
||||
```rego
|
||||
deny[res] {
|
||||
instance := input.aws.rds.instances[_]
|
||||
instance.engine.value == ["postgres", "mysql"][_]
|
||||
not instance.iamauthenabled.value
|
||||
res := result.new("Instance does not have IAM Authentication enabled", instance.iamauthenabled)
|
||||
}
|
||||
```
|
||||
|
||||
The rule should return a result, which can be created using `result.new`. This function does not need to be imported, it is defined internally and provided at runtime. The first argument is the message to display and the second argument is the resource that the issue was detected on.
|
||||
|
||||
It is possible to pass any rego variable that references a field of the input document.
|
||||
|
||||
## Generate docs
|
||||
|
||||
Finally, you'll want to generate documentation for your newly added rule. Please run `make docs` in the [trivy-checks](https://github.com/aquasecurity/trivy-checks) directory to generate the documentation for your new policy and submit a PR for us to take a look at.
|
||||
|
||||
## Adding Tests
|
||||
|
||||
All Rego checks need to have tests. There are many examples of these in the `checks` directory for each check ([Link](https://github.com/aquasecurity/trivy-checks/tree/main/checks)). More information on how to write tests for Rego checks is provided in the [custom misconfiguration](../../../docs/scanner/misconfiguration/custom/testing.md) section of the docs.
|
||||
|
||||
## Example PR
|
||||
|
||||
You can see a full example PR for a new rule being added here: [https://github.com/aquasecurity/defsec/pull/1000](https://github.com/aquasecurity/defsec/pull/1000).
|
||||
69
docs/community/contribute/checks/service-support.md
Normal file
69
docs/community/contribute/checks/service-support.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# Add Service Support
|
||||
|
||||
A service refers to a service by a cloud provider. This section details how to add a new service to an existing provider. All contributions need to be made to the [trivy repository](https://github.com/aquasecurity/trivy/).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before you begin, verify that the [provider](https://github.com/aquasecurity/trivy/tree/main/pkg/iac/providers) does not already have the service that you plan to add.
|
||||
|
||||
## Adding a new service to an existing provider
|
||||
|
||||
Adding a new service involves two steps. The service will need a data structure to store information about the required resources that will be scanned. Additionally, the service will require one or more adapters to convert the scan targetes as input(s) into the aforementioned data structure.
|
||||
|
||||
### Create a new file in the provider directory
|
||||
|
||||
In this example, we are adding the CodeBuild service to the AWS provider.
|
||||
|
||||
First, create a new directory and file for your new service under the provider directory: e.g. [aws/codebuild/codebuild.go](https://github.com/aquasecurity/trivy/blob/main/pkg/iac/providers/aws/codebuild/codebuild.go)
|
||||
|
||||
The CodeBuild service will require a structure `struct` to hold the information on the input that is scanned. The input is the CodeBuild resource that a user configured and wants to scan for misconfiguration.
|
||||
|
||||
```
|
||||
type CodeBuild struct {
|
||||
Projects []Project
|
||||
}
|
||||
```
|
||||
|
||||
The CodeBuild service manages `Project` resources. The `Project` struct has been added to hold information about each Project resources; `Project` Resources in turn manage `ArtifactSettings`:
|
||||
|
||||
```
|
||||
type Project struct {
|
||||
Metadata iacTypes.Metadata
|
||||
ArtifactSettings ArtifactSettings
|
||||
SecondaryArtifactSettings []ArtifactSettings
|
||||
}
|
||||
|
||||
type ArtifactSettings struct {
|
||||
Metadata iacTypes.Metadata
|
||||
EncryptionEnabled iacTypes.BoolValue
|
||||
}
|
||||
```
|
||||
|
||||
The `iacTypes.Metadata` struct is embedded in all of the Trivy types and provides a common set of metadata for all resources. This includes the file and line number where the resource was defined and the name of the resource.
|
||||
|
||||
A resource in this example `Project` can have a name and can optionally be encrypted. Instead of using raw string and bool types respectively, we use the trivy types `iacTypes.Metadata` and `iacTypes.BoolValue`. These types wrap the raw values and provide additional metadata about the value. For instance, whether it was set by the user and the file and line number where the resource was defined.
|
||||
|
||||
Have a look at the other providers and services in the [`iac/providers`](https://github.com/aquasecurity/trivy/tree/main/pkg/iac/providers) directory in Trivy.
|
||||
|
||||
Next you'll need to add a reference to your new service struct in the [provider struct](https://github.com/aquasecurity/trivy/blob/main/pkg/iac/providers/aws/aws.go) at `pkg/iac/providers/aws/aws.go`:
|
||||
|
||||
```
|
||||
type AWS struct {
|
||||
...
|
||||
CodeBuild codebuild.CodeBuild
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### Update Adapters
|
||||
|
||||
Now you'll need to update all of the [adapters](https://github.com/aquasecurity/trivy/tree/main/pkg/iac/adapters) which populate the struct of the provider that you have been using. Following the example above, if you want to add support for CodeBuild in Terraform, you'll need to update the Terraform AWS adatper as shown here: [`trivy/pkg/iac/adapters/terraform/aws/codebuild/adapt.go`](https://github.com/aquasecurity/trivy/blob/main/pkg/iac/adapters/terraform/aws/codebuild/adapt.go).
|
||||
|
||||
Another example for updating the adapters is provided in the [following PR.](https://github.com/aquasecurity/defsec/pull/1000/files) Additionally, please refer to the respective Terraform documentation on the provider to which you are adding the service. For instance, the Terraform documentation for AWS CodeBuild is provided [here.](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codebuild_project)
|
||||
|
||||
|
||||
## Create a new Schema for your provider
|
||||
|
||||
Once the new service has been added to the provider, you need to create the schema for the service as part of the provider schema.
|
||||
|
||||
This process has been automated with mage commands. In the Trivy root directory run `mage schema:generate` to generate the schema for your new service and `mage schema:verify`.
|
||||
@@ -114,6 +114,7 @@ mode:
|
||||
- server
|
||||
- aws
|
||||
- vm
|
||||
- plugin
|
||||
|
||||
os:
|
||||
|
||||
@@ -142,6 +143,7 @@ language:
|
||||
- go
|
||||
- elixir
|
||||
- dart
|
||||
- julia
|
||||
|
||||
vuln:
|
||||
|
||||
@@ -178,6 +180,7 @@ others:
|
||||
- helm
|
||||
- report
|
||||
- db
|
||||
- parser
|
||||
- deps
|
||||
|
||||
The `<scope>` can be empty (e.g. if the change is a global or difficult to assign to a single component), in which case the parentheses are omitted.
|
||||
|
||||
65
docs/community/maintainer/release-flow.md
Normal file
65
docs/community/maintainer/release-flow.md
Normal file
@@ -0,0 +1,65 @@
|
||||
# Release Flow
|
||||
|
||||
## Overview
|
||||
Trivy adopts [conventional commit messages][conventional-commits], and [Release Please][release-please] automatically creates a [release PR](https://github.com/googleapis/release-please?tab=readme-ov-file#whats-a-release-pr) based on the messages of the merged commits.
|
||||
This release PR is automatically updated every time a new commit is added to the release branch.
|
||||
|
||||
If a commit has the prefix `feat:`, a PR is automatically created to increment the minor version, and if a commit has the prefix `fix:`, a PR is created to increment the patch version.
|
||||
When the PR is merged, GitHub Actions automatically creates a version tag and the release is performed.
|
||||
For detailed behavior, please refer to [the GitHub Actions configuration][workflows].
|
||||
|
||||
!!! note
|
||||
Commits with prefixes like `chore` or `build` are not considered releasable, and no release PR is created.
|
||||
To include such commits in a release, you need to either include commits with `feat` or `fix` prefixes or perform a manual release as described [below](#manual-release).
|
||||
|
||||
## Flow
|
||||
The release flow consists of the following main steps:
|
||||
|
||||
1. Creating the release PR (automatically or manually)
|
||||
1. Drafting the release notes
|
||||
1. Merging the release PR
|
||||
1. Updating the release notes
|
||||
|
||||
### Automatic Release PR Creation
|
||||
When a releasable commit (a commit with `feat` or `fix` prefix) is merged, a release PR is automatically created.
|
||||
These Release PRs are kept up-to-date as additional work is merged.
|
||||
When it's ready to tag a release, simply merge the release PR.
|
||||
See the [Release Please documentation][release-please] for more information.
|
||||
|
||||
The title of the PR will be in the format `release: v${version} [${branch}]` (e.g., `release: v0.51.0 [main]`).
|
||||
The format of the PR title is important for identifying the release commit, so it should not be changed.
|
||||
|
||||
The `release/vX.Y` release branches are also subject to automatic release PR creation for patch releases.
|
||||
The PR title will be like `release: v0.51.1 [release/v0.51]`.
|
||||
|
||||
### Manual Release PR Creation
|
||||
If you want to release commits like `chore`, a release PR is not automatically created, so you need to manually trigger the creation of a release PR.
|
||||
The [Release Please workflow](https://github.com/aquasecurity/trivy/actions/workflows/release-please.yaml) supports `workflow_dispatch` and can be triggered manually.
|
||||
Click "Run workflow" in the top right corner and specify the release branch.
|
||||
In Trivy, the following branches are the release branches.
|
||||
|
||||
- `main`
|
||||
- `release/vX.Y` (e.g. `release/v0.51`)
|
||||
|
||||
Specify the release version (without the `v` prefix) and click "Run workflow" to create a release PR for the specified version.
|
||||
|
||||
### Drafting the Release Notes
|
||||
Next, create release notes for this version.
|
||||
Draft a new post in GitHub Discussions, and maintainers edit these release notes (e.g., https://github.com/aquasecurity/trivy/discussions/6605).
|
||||
Currently, the creation of this draft is done manually.
|
||||
For patch version updates, this step can be skipped since they only involve bug fixes.
|
||||
|
||||
### Merging the Release PR
|
||||
Once the draft of the release notes is complete, merge the release PR.
|
||||
When the PR is merged, a tag is automatically created, and [GoReleaser][goreleaser] releases binaries, container images, etc.
|
||||
|
||||
### Updating the Release Notes
|
||||
If the release completes without errors, a page for the release notes is created in GitHub Discussions (e.g., https://github.com/aquasecurity/trivy/discussions/6622).
|
||||
Copy the draft release notes, adjust the formatting, and finalize the release notes.
|
||||
|
||||
The release is now complete.
|
||||
|
||||
[conventional-commits]: https://www.conventionalcommits.org/en/v1.0.0/
|
||||
[release-please]: https://github.com/googleapis/release-please
|
||||
[goreleaser]: https://goreleaser.com/
|
||||
[workflows]: https://github.com/aquasecurity/trivy/tree/main/.github/workflows
|
||||
53
docs/community/principles.md
Normal file
53
docs/community/principles.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Trivy Project Principles
|
||||
This document outlines the guiding principles and governance framework for the Trivy project.
|
||||
|
||||
## Core Principles
|
||||
Trivy is a security scanner focused on static analysis and designed with simplicity and security at its core.
|
||||
All new proposals to the project must adhere to the following principles.
|
||||
|
||||
### Static Analysis (No Runtime Required)
|
||||
Trivy operates without requiring container or VM image startups, eliminating the need for Docker or similar runtimes, except for scanning images stored within a container runtime.
|
||||
This approach enhances security and efficiency by minimizing dependencies.
|
||||
|
||||
### External Dependency Free (Single Binary)
|
||||
Operating as a single binary, Trivy is independent of external environments and avoids executing external OS commands or processes.
|
||||
If specific functionality, like Maven's, is needed, Trivy opts for internal reimplementations or processing outputs of the tool without direct execution of external tools.
|
||||
|
||||
This approach obviously requires more effort but significantly reduces security risks associated with executing OS commands and dependency errors due to external environment versions.
|
||||
Simplifying the scanner's use by making it operational immediately upon binary download facilitates easier initiation of scans.
|
||||
|
||||
### No Setup Required
|
||||
Trivy must be ready to use immediately after installation.
|
||||
It's unacceptable for Trivy not to function without setting up a database or writing configuration files by default.
|
||||
Such setups should only be necessary for users requiring specific customizations.
|
||||
|
||||
Security often isn't a top priority for many organizations and can be easily deferred.
|
||||
Trivy aims to lower the barrier to entry by simplifying the setup process, making it easier for users to start securing their projects.
|
||||
|
||||
### Security Focus
|
||||
Trivy prioritizes the identification of security issues, excluding features unrelated to security, such as performance metrics or content listings of container images.
|
||||
It can, however, produce and output intermediate representations like SBOMs for comprehensive security assessments.
|
||||
|
||||
Trivy serves as a tool with opinions on security, used to warn users about potential issues.
|
||||
|
||||
### Detecting Unintended States
|
||||
Trivy is designed to detect unintended vulnerable states in projects, such as the use of vulnerable versions of dependencies or misconfigurations in Infrastructure as Code (IaC) that may unintentionally expose servers to the internet.
|
||||
The focus is on identifying developer mistakes or undesirable states, not on detecting intentional attacks, such as malicious images and malware.
|
||||
|
||||
## Out of Scope Features
|
||||
Aqua Security offers a premium version with several features not available in the open-source Trivy project.
|
||||
While detailed information can be found [here][trivy-aqua], it's beneficial to highlight specific functionalities frequently inquired about:
|
||||
|
||||
### Runtime Security
|
||||
As mentioned in [the Core Principles](#static-analysis-no-runtime-required), Trivy is a static analysis security scanner, making runtime security outside its scope.
|
||||
Runtime security needs are addressed by [Tracee][tracee] or [the commercial version of Aqua Security]().
|
||||
|
||||
### Intentional Attacks
|
||||
As mentioned in [the Core Principles](#detecting-unintended-states), detection of intentional attacks, such as malware or malicious container images, is not covered by Trivy and is supported in [the commercial version][aqua].
|
||||
|
||||
### User Interface
|
||||
Trivy primarily operates via CLI for displaying results, with a richer UI available in [the commercial version][aqua].
|
||||
|
||||
[trivy-aqua]: https://github.com/aquasecurity/resources/blob/main/trivy-aqua.md
|
||||
[tracee]: https://github.com/aquasecurity/tracee
|
||||
[aqua]: https://www.aquasec.com/
|
||||
@@ -129,14 +129,14 @@ $ trivy image --skip-db-update --skip-java-db-update --offline-scan alpine:3.12
|
||||
|
||||
No special measures are required to detect misconfigurations in an air-gapped environment.
|
||||
|
||||
### Run Trivy with `--skip-policy-update` option
|
||||
In an air-gapped environment, specify `--skip-policy-update` so that Trivy doesn't attempt to download the latest misconfiguration policies.
|
||||
### Run Trivy with `--skip-check-update` option
|
||||
In an air-gapped environment, specify `--skip-check-update` so that Trivy doesn't attempt to download the latest misconfiguration checks.
|
||||
|
||||
```
|
||||
$ trivy conf --skip-policy-update /path/to/conf
|
||||
```
|
||||
|
||||
[allowlist]: ../references/troubleshooting.md
|
||||
[oras]: https://oras.land/cli/
|
||||
[oras]: https://oras.land/docs/installation
|
||||
|
||||
[^1]: This is only required to scan `jar` files. More information about `Java index db` [here](../coverage/language/java.md)
|
||||
|
||||
@@ -1,236 +0,0 @@
|
||||
# Plugins
|
||||
Trivy provides a plugin feature to allow others to extend the Trivy CLI without the need to change the Trivycode base.
|
||||
This plugin system was inspired by the plugin system used in [kubectl][kubectl], [Helm][helm], and [Conftest][conftest].
|
||||
|
||||
## Overview
|
||||
Trivy plugins are add-on tools that integrate seamlessly with Trivy.
|
||||
They provide a way to extend the core feature set of Trivy, but without requiring every new feature to be written in Go and added to the core tool.
|
||||
|
||||
- They can be added and removed from a Trivy installation without impacting the core Trivy tool.
|
||||
- They can be written in any programming language.
|
||||
- They integrate with Trivy, and will show up in Trivy help and subcommands.
|
||||
|
||||
!!! warning
|
||||
Trivy plugins available in public are not audited for security.
|
||||
You should install and run third-party plugins at your own risk, since they are arbitrary programs running on your machine.
|
||||
|
||||
|
||||
## Installing a Plugin
|
||||
A plugin can be installed using the `trivy plugin install` command.
|
||||
This command takes a url and will download the plugin and install it in the plugin cache.
|
||||
|
||||
Trivy adheres to the XDG specification, so the location depends on whether XDG_DATA_HOME is set.
|
||||
Trivy will now search XDG_DATA_HOME for the location of the Trivy plugins cache.
|
||||
The preference order is as follows:
|
||||
|
||||
- XDG_DATA_HOME if set and .trivy/plugins exists within the XDG_DATA_HOME dir
|
||||
- ~/.trivy/plugins
|
||||
|
||||
Under the hood Trivy leverages [go-getter][go-getter] to download plugins.
|
||||
This means the following protocols are supported for downloading plugins:
|
||||
|
||||
- OCI Registries
|
||||
- Local Files
|
||||
- Git
|
||||
- HTTP/HTTPS
|
||||
- Mercurial
|
||||
- Amazon S3
|
||||
- Google Cloud Storage
|
||||
|
||||
For example, to download the Kubernetes Trivy plugin you can execute the following command:
|
||||
|
||||
```bash
|
||||
$ trivy plugin install github.com/aquasecurity/trivy-plugin-kubectl
|
||||
```
|
||||
Also, Trivy plugin can be installed from a local archive:
|
||||
```bash
|
||||
$ trivy plugin install myplugin.tar.gz
|
||||
```
|
||||
|
||||
## Using Plugins
|
||||
Once the plugin is installed, Trivy will load all available plugins in the cache on the start of the next Trivy execution.
|
||||
A plugin will be made in the Trivy CLI based on the plugin name.
|
||||
To display all plugins, you can list them by `trivy --help`
|
||||
|
||||
```bash
|
||||
$ trivy --help
|
||||
NAME:
|
||||
trivy - A simple and comprehensive vulnerability scanner for containers
|
||||
|
||||
USAGE:
|
||||
trivy [global options] command [command options] target
|
||||
|
||||
VERSION:
|
||||
dev
|
||||
|
||||
COMMANDS:
|
||||
image, i scan an image
|
||||
filesystem, fs scan local filesystem
|
||||
repository, repo scan remote repository
|
||||
client, c client mode
|
||||
server, s server mode
|
||||
plugin, p manage plugins
|
||||
kubectl scan kubectl resources
|
||||
help, h Shows a list of commands or help for one command
|
||||
```
|
||||
|
||||
As shown above, `kubectl` subcommand exists in the `COMMANDS` section.
|
||||
To call the kubectl plugin and scan existing Kubernetes deployments, you can execute the following command:
|
||||
|
||||
```
|
||||
$ trivy kubectl deployment <deployment-id> -- --ignore-unfixed --severity CRITICAL
|
||||
```
|
||||
|
||||
Internally the kubectl plugin calls the kubectl binary to fetch information about that deployment and passes the using images to Trivy.
|
||||
You can see the detail [here][trivy-plugin-kubectl].
|
||||
|
||||
If you want to omit even the subcommand, you can use `TRIVY_RUN_AS_PLUGIN` environment variable.
|
||||
|
||||
```bash
|
||||
$ TRIVY_RUN_AS_PLUGIN=kubectl trivy job your-job -- --format json
|
||||
```
|
||||
|
||||
## Installing and Running Plugins on the fly
|
||||
`trivy plugin run` installs a plugin and runs it on the fly.
|
||||
If the plugin is already present in the cache, the installation is skipped.
|
||||
|
||||
```bash
|
||||
trivy plugin run github.com/aquasecurity/trivy-plugin-kubectl pod your-pod -- --exit-code 1
|
||||
```
|
||||
|
||||
## Uninstalling Plugins
|
||||
Specify a plugin name with `trivy plugin uninstall` command.
|
||||
|
||||
```bash
|
||||
$ trivy plugin uninstall kubectl
|
||||
```
|
||||
|
||||
## Building Plugins
|
||||
Each plugin has a top-level directory, and then a plugin.yaml file.
|
||||
|
||||
```bash
|
||||
your-plugin/
|
||||
|
|
||||
|- plugin.yaml
|
||||
|- your-plugin.sh
|
||||
```
|
||||
|
||||
In the example above, the plugin is contained inside of a directory named `your-plugin`.
|
||||
It has two files: plugin.yaml (required) and an executable script, your-plugin.sh (optional).
|
||||
|
||||
The core of a plugin is a simple YAML file named plugin.yaml.
|
||||
Here is an example YAML of trivy-plugin-kubectl plugin that adds support for Kubernetes scanning.
|
||||
|
||||
```yaml
|
||||
name: "kubectl"
|
||||
repository: github.com/aquasecurity/trivy-plugin-kubectl
|
||||
version: "0.1.0"
|
||||
usage: scan kubectl resources
|
||||
description: |-
|
||||
A Trivy plugin that scans the images of a kubernetes resource.
|
||||
Usage: trivy kubectl TYPE[.VERSION][.GROUP] NAME
|
||||
platforms:
|
||||
- selector: # optional
|
||||
os: darwin
|
||||
arch: amd64
|
||||
uri: ./trivy-kubectl # where the execution file is (local file, http, git, etc.)
|
||||
bin: ./trivy-kubectl # path to the execution file
|
||||
- selector: # optional
|
||||
os: linux
|
||||
arch: amd64
|
||||
uri: https://github.com/aquasecurity/trivy-plugin-kubectl/releases/download/v0.1.0/trivy-kubectl.tar.gz
|
||||
bin: ./trivy-kubectl
|
||||
```
|
||||
|
||||
The `plugin.yaml` field should contain the following information:
|
||||
|
||||
- name: The name of the plugin. This also determines how the plugin will be made available in the Trivy CLI. For example, if the plugin is named kubectl, you can call the plugin with `trivy kubectl`. (required)
|
||||
- version: The version of the plugin. (required)
|
||||
- usage: A short usage description. (required)
|
||||
- description: A long description of the plugin. This is where you could provide a helpful documentation of your plugin. (required)
|
||||
- platforms: (required)
|
||||
- selector: The OS/Architecture specific variations of a execution file. (optional)
|
||||
- os: OS information based on GOOS (linux, darwin, etc.) (optional)
|
||||
- arch: The architecture information based on GOARCH (amd64, arm64, etc.) (optional)
|
||||
- uri: Where the executable file is. Relative path from the root directory of the plugin or remote URL such as HTTP and S3. (required)
|
||||
- bin: Which file to call when the plugin is executed. Relative path from the root directory of the plugin. (required)
|
||||
|
||||
The following rules will apply in deciding which platform to select:
|
||||
|
||||
- If both `os` and `arch` under `selector` match the current platform, search will stop and the platform will be used.
|
||||
- If `selector` is not present, the platform will be used.
|
||||
- If `os` matches and there is no more specific `arch` match, the platform will be used.
|
||||
- If no `platform` match is found, Trivy will exit with an error.
|
||||
|
||||
After determining platform, Trivy will download the execution file from `uri` and store it in the plugin cache.
|
||||
When the plugin is called via Trivy CLI, `bin` command will be executed.
|
||||
|
||||
The plugin is responsible for handling flags and arguments. Any arguments are passed to the plugin from the `trivy` command.
|
||||
|
||||
A plugin should be archived `*.tar.gz`.
|
||||
|
||||
```bash
|
||||
$ tar -czvf myplugin.tar.gz plugin.yaml script.py
|
||||
plugin.yaml
|
||||
script.py
|
||||
|
||||
$ trivy plugin install myplugin.tar.gz
|
||||
2023-03-03T19:04:42.026+0600 INFO Installing the plugin from myplugin.tar.gz...
|
||||
2023-03-03T19:04:42.026+0600 INFO Loading the plugin metadata...
|
||||
|
||||
$ trivy myplugin
|
||||
Hello from Trivy demo plugin!
|
||||
```
|
||||
|
||||
## Plugin Types
|
||||
Plugins are typically intended to be used as subcommands of Trivy,
|
||||
but some plugins can be invoked as part of Trivy's built-in commands.
|
||||
Currently, the following type of plugin is experimentally supported:
|
||||
|
||||
- Output plugins
|
||||
|
||||
### Output Plugins
|
||||
|
||||
!!! warning "EXPERIMENTAL"
|
||||
This feature might change without preserving backwards compatibility.
|
||||
|
||||
Trivy supports "output plugins" which process Trivy's output,
|
||||
such as by transforming the output format or sending it elsewhere.
|
||||
For instance, in the case of image scanning, the output plugin can be called as follows:
|
||||
|
||||
```shell
|
||||
$ trivy image --format json --output plugin=<plugin_name> [--output-plugin-arg <plugin_flags>] <image_name>
|
||||
```
|
||||
|
||||
Since scan results are passed to the plugin via standard input, plugins must be capable of handling standard input.
|
||||
|
||||
!!! warning
|
||||
To avoid Trivy hanging, you need to read all data from `Stdin` before the plugin exits successfully or stops with an error.
|
||||
|
||||
While the example passes JSON to the plugin, other formats like SBOM can also be passed (e.g., `--format cyclonedx`).
|
||||
|
||||
If a plugin requires flags or other arguments, they can be passed using `--output-plugin-arg`.
|
||||
This is directly forwarded as arguments to the plugin.
|
||||
For example, `--output plugin=myplugin --output-plugin-arg "--foo --bar=baz"` translates to `myplugin --foo --bar=baz` in execution.
|
||||
|
||||
An example of the output plugin is available [here](https://github.com/aquasecurity/trivy-output-plugin-count).
|
||||
It can be used as below:
|
||||
|
||||
```shell
|
||||
# Install the plugin first
|
||||
$ trivy plugin install github.com/aquasecurity/trivy-output-plugin-count
|
||||
|
||||
# Call the output plugin in image scanning
|
||||
$ trivy image --format json --output plugin=count --output-plugin-arg "--published-after 2023-10-01" debian:12
|
||||
```
|
||||
|
||||
## Example
|
||||
- https://github.com/aquasecurity/trivy-plugin-kubectl
|
||||
- https://github.com/aquasecurity/trivy-output-plugin-count
|
||||
|
||||
[kubectl]: https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/
|
||||
[helm]: https://helm.sh/docs/topics/plugins/
|
||||
[conftest]: https://www.conftest.dev/plugins/
|
||||
[go-getter]: https://github.com/hashicorp/go-getter
|
||||
[trivy-plugin-kubectl]: https://github.com/aquasecurity/trivy-plugin-kubectl
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Compliance Reports
|
||||
# Built-in Compliance Reports
|
||||
|
||||
!!! warning "EXPERIMENTAL"
|
||||
This feature might change without preserving backwards compatibility.
|
||||
|
||||
101
docs/docs/compliance/contrib-compliance.md
Normal file
101
docs/docs/compliance/contrib-compliance.md
Normal file
@@ -0,0 +1,101 @@
|
||||
# Custom Compliance Spec
|
||||
|
||||
Trivy supports several different compliance specs. The details on compliance scanning with Trivy are provided in the [compliance documentation](../../docs/compliance/compliance.md).
|
||||
All of the Compliance Specs currently available in Trivy can be found in the `trivy-checks/specs/compliance/` directory ([Link](https://github.com/aquasecurity/trivy-checks/tree/main/specs/compliance)).
|
||||
|
||||
New checks are based on the custom compliance report detailed in the [main documentation.](../../docs/compliance/compliance/#custom-compliance)
|
||||
If you would like to create your custom compliance report, please reference the information in the main documentation. This section details how community members can contribute new Compliance Specs to Trivy.
|
||||
|
||||
All compliance specs in Trivy are based on formal compliance reports such as CIS Benchmarks.
|
||||
|
||||
## Contributing new Compliance Specs
|
||||
|
||||
Compliance specs can be based on new compliance reports becoming available e.g. a new CIS Benchmark version, or identifying missing compliance specs that Trivy users would like to access.
|
||||
|
||||
### Create a new Compliance Spec
|
||||
|
||||
The existing compliance specs in Trivy are located under the `trivy-checks/specs/compliance/` directory ([Link](https://github.com/aquasecurity/trivy-checks/tree/main/specs/compliance)).
|
||||
|
||||
Create a new file under `trivy-checks/specs/compliance/` and name the file in the format of "provider-resource-spectype-version.yaml". For example, the file name for AWS CIS Benchmarks for EKS version 1.4 is: `aws-eks-cis-1.4.yaml`. Note that if the compliance spec is not specific to a provider, the `provider` field can be ignored.
|
||||
|
||||
### Minimum spec structure
|
||||
|
||||
The structure of the compliance spec is detailed in the [main documentation](./compliance/#custom-compliance).
|
||||
|
||||
The first section in the spec is focused on the metadata of the spec. Replace all the fields of the metadata with the information relevant to the compliance spec that will be added. This information can be taken from the official report e.g. the CIS Benchmark report.
|
||||
|
||||
### Populating the `control` section
|
||||
|
||||
Compliance specs detail a set of checks that should pass so that the resource is compliant with the official benchmark specifications. There are two ways in which Trivy compliance checks can enforce the compliance specification:
|
||||
|
||||
1. The check is available in Trivy, as part of the `trivy-checks` and can be referenced in the Compliance Spec
|
||||
2. The check is not available in Trivy and a manual check has to be added to the Compliance Spec
|
||||
|
||||
Additional information is provided below.
|
||||
|
||||
#### 1. Referencing a check that is already part of Trivy
|
||||
|
||||
Trivy has a comprehensive list of checks as part of its misconfiguration scanning. These can be found in the `trivy-policies/checks` directory ([Link](https://github.com/aquasecurity/trivy-checks/tree/main/checks)). If the check is present, the `AVD_ID` and other information from the check has to be used.
|
||||
|
||||
Note: Take a look at the more generic compliance specs that are already available in Trivy. If you are adding new compliance spec to Kubernetes e.g. AWS EKS CIS Benchmarks, chances are high that the check you would like to add to the new spec has already been defined in the general `k8s-ci-v.000.yaml` compliance spec. The same applies for creating specific Cloud Provider Compliance Specs and the [generic compliance specs](https://github.com/aquasecurity/trivy-checks/tree/main/specs/compliance) available.
|
||||
|
||||
For example, the following check is detailed in the AWS EKS CIS v1.4 Benchmark:
|
||||
`3.1.2 Ensure that the kubelet kubeconfig file ownership is set to root:root (Manual)`
|
||||
|
||||
This check can be found in the general K8s CIS Compliance Benchmark: `k8s-cis-1.23.yaml` ([Link](https://github.com/aquasecurity/trivy-checks/blob/31e779916f3863dd74a28cee869ea24fdc4ca8c2/specs/compliance/k8s-cis-1.23.yaml#L480))
|
||||
|
||||
Thus, we can use the information already present:
|
||||
|
||||
```
|
||||
- id: 3.1.2
|
||||
name: Ensure that the kubelet service file ownership is set to root:root (Manual)
|
||||
description: Ensure that the kubelet service file ownership is set to root:root
|
||||
checks:
|
||||
- id: AVD-KCV-0070
|
||||
severity: HIGH
|
||||
```
|
||||
|
||||
- The `ID`, `name`, and `description` is taken directly from the AWS EKS CIS Benchmarks
|
||||
- The `check` and `severity` are taken from the existing complaince check in the `k8s-cis-1.23.yaml`
|
||||
|
||||
|
||||
#### 2. Referencing a check manually that is not part of the Trivy default checks
|
||||
|
||||
If the check does not already exist in the [Aqua Vulnerability Database](https://avd.aquasec.com/) (AVD) and is not part of the trivy-checks, the fields in the compliance spec for the check have to be populated manually. This is done by referencing the information in the official compliance specification.
|
||||
|
||||
Below is the beginning of the information of the EKS CIS Benchmarks v1.4.0:
|
||||
|
||||

|
||||
|
||||
The corresponding check in the `control` section will look like this:
|
||||
|
||||
```
|
||||
- id: 2.1.1
|
||||
name: Enable audit Logs (Manual)
|
||||
description: |
|
||||
Control plane logs provide visibility into operation of the EKS Control plane components systems.
|
||||
The API server audit logs record all accepted and rejected requests in the cluster.
|
||||
When enabled via EKS configuration the control plane logs for a cluster are exported to a CloudWatch
|
||||
Log Group for persistence.
|
||||
checks: null
|
||||
severity: MEDIUM
|
||||
```
|
||||
|
||||
- Again, the `id`, `name` and `description` are taken directly from the EKS CIS Benchmarks v1.4.0
|
||||
- The `checks` is in this case `null` as the check is not currently present in the AVD and does not have a check in the [trivy policies](https://github.com/aquasecurity/trivy-checks/tree/main/checks) repository
|
||||
- Since the check does not exist in Trivy, the `severity` will be `MEDIUM`. However, in some cases, the compliance report e.g. the CIS Benchmark report will specify the severity
|
||||
|
||||
#### Contributing new checks to trivy-checks
|
||||
|
||||
All of the checks in trivy-policies can be referenced in the compliance specs.
|
||||
To write new Rego checks for Trivy, please take a look at the contributing documentation for checks.
|
||||
|
||||
### Test the Compliance Spec
|
||||
|
||||
To test the compliance check, pass the new path into the Trivy scan through the `--compliance` flag. For instance, to pass the check to the Trivy Kubernetes scan use the following command structure:
|
||||
|
||||
```
|
||||
trivy k8s cluster --compliance @</path/to/compliance.yaml> --report summary
|
||||
```
|
||||
|
||||
Note: The `@` is required before the filepath.
|
||||
@@ -3,7 +3,7 @@ The cache directory includes
|
||||
|
||||
- [Vulnerability Database][trivy-db][^1]
|
||||
- [Java Index Database][trivy-java-db][^2]
|
||||
- [Misconfiguration Policies][misconf-policies][^3]
|
||||
- [Misconfiguration Checks][misconf-checks][^3]
|
||||
- Cache of previous scans.
|
||||
|
||||
The cache option is common to all scanners.
|
||||
@@ -70,7 +70,7 @@ $ trivy server --cache-backend redis://localhost:6379 \
|
||||
|
||||
[trivy-db]: ./db.md#vulnerability-database
|
||||
[trivy-java-db]: ./db.md#java-index-database
|
||||
[misconf-policies]: ../scanner/misconfiguration/policy/builtin.md
|
||||
[misconf-checks]: ../scanner/misconfiguration/check/builtin.md
|
||||
|
||||
[^1]: Downloaded when scanning for vulnerabilities
|
||||
[^2]: Downloaded when scanning `jar/war/par/ear` files
|
||||
|
||||
@@ -54,18 +54,28 @@ $ trivy image --download-db-only
|
||||
$ trivy image --db-repository registry.gitlab.com/gitlab-org/security-products/dependencies/trivy-db
|
||||
```
|
||||
|
||||
!!!note
|
||||
Trivy automatically adds the `trivy-db` schema version as a tag if the tag is not used:
|
||||
|
||||
`trivy-db-registry:latest` => `trivy-db-registry:latest`, but `trivy-db-registry` => `trivy-db-registry:2`.
|
||||
|
||||
## Java Index Database
|
||||
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.
|
||||
|
||||
!!! Note
|
||||
In [Client/Server](../references/modes/client-server.md) mode, `Java index DB` is currently only used on the `client` side.
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
!!! Note
|
||||
In [Client/Server](../references/modes/client-server.md) mode, `Java index DB` is currently only used on the `client` side.
|
||||
!!!note
|
||||
Trivy automatically adds the `trivy-java-db` schema version as a tag if the tag is not used:
|
||||
|
||||
`java-db-registry:latest` => `java-db-registry:latest`, but `java-db-registry` => `java-db-registry:1`.
|
||||
|
||||
## Remove DBs
|
||||
The `--reset` flag removes all caches and databases.
|
||||
|
||||
@@ -1,81 +1,34 @@
|
||||
# Filtering
|
||||
Trivy provides various methods for filtering the results.
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
Issues("Detected\nIssues") --> Severity
|
||||
|
||||
## By Status
|
||||
|
||||
| Scanner | Supported |
|
||||
|:----------------:|:---------:|
|
||||
| Vulnerability | ✓ |
|
||||
| Misconfiguration | |
|
||||
| Secret | |
|
||||
| License | |
|
||||
|
||||
Trivy supports the following vulnerability statuses:
|
||||
|
||||
- `unknown`
|
||||
- `not_affected`: this package is not affected by this vulnerability on this platform
|
||||
- `affected`: this package is affected by this vulnerability on this platform, but there is no patch released yet
|
||||
- `fixed`: this vulnerability is fixed on this platform
|
||||
- `under_investigation`: it is currently unknown whether or not this vulnerability affects this package on this platform, and it is under investigation
|
||||
- `will_not_fix`: this package is affected by this vulnerability on this platform, but there is currently no intention to fix it (this would primarily be for flaws that are of Low or Moderate impact that pose no significant risk to customers)
|
||||
- `fix_deferred`: this package is affected by this vulnerability on this platform, and may be fixed in the future
|
||||
- `end_of_life`: this package has been identified to contain the impacted component, but analysis to determine whether it is affected or not by this vulnerability was not performed
|
||||
|
||||
Note that vulnerabilities with the `unknown`, `not_affected` or `under_investigation` status are not detected.
|
||||
These are only defined for comprehensiveness, and you will not have the opportunity to specify these statuses.
|
||||
|
||||
Some statuses are supported in limited distributions.
|
||||
|
||||
| OS | Fixed | Affected | Under Investigation | Will Not Fix | Fix Deferred | End of Life |
|
||||
|:----------:|:-----:|:--------:|:-------------------:|:------------:|:------------:|:-----------:|
|
||||
| Debian | ✓ | ✓ | | | ✓ | ✓ |
|
||||
| RHEL | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
||||
| Other OSes | ✓ | ✓ | | | | |
|
||||
|
||||
|
||||
To ignore vulnerabilities with specific statuses, use the `--ignore-status <list_of_statuses>` option.
|
||||
|
||||
|
||||
```bash
|
||||
$ trivy image --ignore-status affected,fixed ruby:2.4.0
|
||||
subgraph Filtering
|
||||
subgraph Prioritization
|
||||
direction TB
|
||||
Severity("By Severity") --> Status("By Status")
|
||||
end
|
||||
subgraph Suppression
|
||||
Status --> Ignore("By Finding IDs")
|
||||
Ignore --> Rego("By Rego")
|
||||
Rego --> VEX("By VEX")
|
||||
end
|
||||
end
|
||||
VEX --> Results
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
Similar to the functionality of filtering results, you can also limit the sub-targets for each scanner.
|
||||
For information on these settings, please refer to the scanner-specific documentation ([vulnerability](../scanner/vulnerability.md) , [misconfiguration](../scanner/misconfiguration/index.md), etc.).
|
||||
|
||||
```
|
||||
2019-05-16T12:50:14.786+0900 INFO Detecting Debian vulnerabilities...
|
||||
## Prioritization
|
||||
You can filter the results by
|
||||
|
||||
ruby:2.4.0 (debian 8.7)
|
||||
=======================
|
||||
Total: 527 (UNKNOWN: 0, LOW: 276, MEDIUM: 83, HIGH: 158, CRITICAL: 10)
|
||||
- [Severity](#by-severity)
|
||||
- [Status](#by-status)
|
||||
|
||||
┌─────────────────────────────┬──────────────────┬──────────┬──────────────┬────────────────────────────┬───────────────┬──────────────────────────────────────────────────────────────┐
|
||||
│ Library │ Vulnerability │ Severity │ Status │ Installed Version │ Fixed Version │ Title │
|
||||
├─────────────────────────────┼──────────────────┼──────────┼──────────────┼────────────────────────────┼───────────────┼──────────────────────────────────────────────────────────────┤
|
||||
│ binutils │ CVE-2014-9939 │ CRITICAL │ will_not_fix │ 2.25-5 │ │ binutils: buffer overflow in ihex.c │
|
||||
│ │ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2014-9939 │
|
||||
│ ├──────────────────┤ │ │ ├───────────────┼──────────────────────────────────────────────────────────────┤
|
||||
│ │ CVE-2017-6969 │ │ │ │ │ binutils: Heap-based buffer over-read in readelf when │
|
||||
│ │ │ │ │ │ │ processing corrupt RL78 binaries │
|
||||
│ │ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2017-6969 │
|
||||
│ ├──────────────────┤ │ │ ├───────────────┼──────────────────────────────────────────────────────────────┤
|
||||
...
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
!!! tip
|
||||
To skip all unfixed vulnerabilities, you can use the `--ignore-unfixed` flag .
|
||||
It is a shorthand of `--ignore-status affected,will_not_fix,fix_deferred,end_of_life`.
|
||||
It displays "fixed" vulnerabilities only.
|
||||
|
||||
```bash
|
||||
$ trivy image --ignore-unfixed ruby:2.4.0
|
||||
```
|
||||
|
||||
## By Severity
|
||||
### By Severity
|
||||
|
||||
| Scanner | Supported |
|
||||
|:----------------:|:---------:|
|
||||
@@ -202,11 +155,125 @@ See https://avd.aquasec.com/misconfig/avd-aws-0081
|
||||
```
|
||||
</details>
|
||||
|
||||
## By Finding IDs
|
||||
### By Status
|
||||
|
||||
| Scanner | Supported |
|
||||
|:----------------:|:---------:|
|
||||
| Vulnerability | ✓ |
|
||||
| Misconfiguration | |
|
||||
| Secret | |
|
||||
| License | |
|
||||
|
||||
Trivy supports the following vulnerability statuses:
|
||||
|
||||
- `unknown`
|
||||
- `not_affected`: this package is not affected by this vulnerability on this platform
|
||||
- `affected`: this package is affected by this vulnerability on this platform, but there is no patch released yet
|
||||
- `fixed`: this vulnerability is fixed on this platform
|
||||
- `under_investigation`: it is currently unknown whether or not this vulnerability affects this package on this platform, and it is under investigation
|
||||
- `will_not_fix`: this package is affected by this vulnerability on this platform, but there is currently no intention to fix it (this would primarily be for flaws that are of Low or Moderate impact that pose no significant risk to customers)
|
||||
- `fix_deferred`: this package is affected by this vulnerability on this platform, and may be fixed in the future
|
||||
- `end_of_life`: this package has been identified to contain the impacted component, but analysis to determine whether it is affected or not by this vulnerability was not performed
|
||||
|
||||
Note that vulnerabilities with the `unknown`, `not_affected` or `under_investigation` status are not detected.
|
||||
These are only defined for comprehensiveness, and you will not have the opportunity to specify these statuses.
|
||||
|
||||
Some statuses are supported in limited distributions.
|
||||
|
||||
| OS | Fixed | Affected | Under Investigation | Will Not Fix | Fix Deferred | End of Life |
|
||||
|:----------:|:-----:|:--------:|:-------------------:|:------------:|:------------:|:-----------:|
|
||||
| Debian | ✓ | ✓ | | | ✓ | ✓ |
|
||||
| RHEL | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
||||
| Other OSes | ✓ | ✓ | | | | |
|
||||
|
||||
|
||||
To ignore vulnerabilities with specific statuses, use the `--ignore-status <list_of_statuses>` option.
|
||||
|
||||
|
||||
```bash
|
||||
$ trivy image --ignore-status affected,fixed ruby:2.4.0
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
```
|
||||
2019-05-16T12:50:14.786+0900 INFO Detecting Debian vulnerabilities...
|
||||
|
||||
ruby:2.4.0 (debian 8.7)
|
||||
=======================
|
||||
Total: 527 (UNKNOWN: 0, LOW: 276, MEDIUM: 83, HIGH: 158, CRITICAL: 10)
|
||||
|
||||
┌─────────────────────────────┬──────────────────┬──────────┬──────────────┬────────────────────────────┬───────────────┬──────────────────────────────────────────────────────────────┐
|
||||
│ Library │ Vulnerability │ Severity │ Status │ Installed Version │ Fixed Version │ Title │
|
||||
├─────────────────────────────┼──────────────────┼──────────┼──────────────┼────────────────────────────┼───────────────┼──────────────────────────────────────────────────────────────┤
|
||||
│ binutils │ CVE-2014-9939 │ CRITICAL │ will_not_fix │ 2.25-5 │ │ binutils: buffer overflow in ihex.c │
|
||||
│ │ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2014-9939 │
|
||||
│ ├──────────────────┤ │ │ ├───────────────┼──────────────────────────────────────────────────────────────┤
|
||||
│ │ CVE-2017-6969 │ │ │ │ │ binutils: Heap-based buffer over-read in readelf when │
|
||||
│ │ │ │ │ │ │ processing corrupt RL78 binaries │
|
||||
│ │ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2017-6969 │
|
||||
│ ├──────────────────┤ │ │ ├───────────────┼──────────────────────────────────────────────────────────────┤
|
||||
...
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
!!! tip
|
||||
To skip all unfixed vulnerabilities, you can use the `--ignore-unfixed` flag .
|
||||
It is a shorthand of `--ignore-status affected,will_not_fix,fix_deferred,end_of_life`.
|
||||
It displays "fixed" vulnerabilities only.
|
||||
|
||||
```bash
|
||||
$ trivy image --ignore-unfixed ruby:2.4.0
|
||||
```
|
||||
|
||||
## Suppression
|
||||
You can filter the results by
|
||||
|
||||
- [Finding IDs](#by-finding-ids)
|
||||
- [Rego](#by-rego)
|
||||
- [Vulnerability Exploitability Exchange (VEX)](#by-vulnerability-exploitability-exchange-vex)
|
||||
|
||||
To show the suppressed results, use the `--show-suppressed` flag.
|
||||
|
||||
!!! note
|
||||
This flag is currently available only in the table format.
|
||||
|
||||
```bash
|
||||
$ trivy image --vex debian11.csaf.vex --ignorefile .trivyignore.yaml --show-suppressed debian:11
|
||||
...
|
||||
|
||||
Suppressed Vulnerabilities (Total: 9)
|
||||
|
||||
┌───────────────┬───────────────┬──────────┬──────────────┬─────────────────────────────────────────────┬───────────────────┐
|
||||
│ Library │ Vulnerability │ Severity │ Status │ Statement │ Source │
|
||||
├───────────────┼───────────────┼──────────┼──────────────┼─────────────────────────────────────────────┼───────────────────┤
|
||||
│ libdb5.3 │ CVE-2019-8457 │ CRITICAL │ not_affected │ vulnerable_code_not_in_execute_path │ CSAF VEX │
|
||||
├───────────────┼───────────────┼──────────┼──────────────┼─────────────────────────────────────────────┼───────────────────┤
|
||||
│ bsdutils │ CVE-2022-0563 │ LOW │ ignored │ Accept the risk │ .trivyignore.yaml │
|
||||
├───────────────┤ │ │ │ │ │
|
||||
│ libblkid1 │ │ │ │ │ │
|
||||
├───────────────┤ │ │ │ │ │
|
||||
│ libmount1 │ │ │ │ │ │
|
||||
├───────────────┤ │ │ │ │ │
|
||||
│ libsmartcols1 │ │ │ │ │ │
|
||||
├───────────────┤ │ │ │ │ │
|
||||
│ libuuid1 │ │ │ │ │ │
|
||||
├───────────────┤ │ │ │ │ │
|
||||
│ mount │ │ │ │ │ │
|
||||
├───────────────┼───────────────┤ │ ├─────────────────────────────────────────────┤ │
|
||||
│ tar │ CVE-2005-2541 │ │ │ The vulnerable configuration is not enabled │ │
|
||||
├───────────────┼───────────────┤ │ ├─────────────────────────────────────────────┤ │
|
||||
│ util-linux │ CVE-2022-0563 │ │ │ Accept the risk │ │
|
||||
└───────────────┴───────────────┴──────────┴──────────────┴─────────────────────────────────────────────┴───────────────────┘
|
||||
```
|
||||
|
||||
### By Finding IDs
|
||||
|
||||
Trivy supports the [.trivyignore](#trivyignore) and [.trivyignore.yaml](#trivyignoreyaml) ignore files.
|
||||
|
||||
### .trivyignore
|
||||
#### .trivyignore
|
||||
|
||||
| Scanner | Supported |
|
||||
|:----------------:|:---------:|
|
||||
@@ -254,7 +321,7 @@ Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)
|
||||
|
||||
</details>
|
||||
|
||||
### .trivyignore.yaml
|
||||
#### .trivyignore.yaml
|
||||
|
||||
| Scanner | Supported |
|
||||
|:----------------:|:---------:|
|
||||
@@ -271,12 +338,13 @@ For the `.trivyignore.yaml` file, you can set ignored IDs separately for `vulner
|
||||
|
||||
Available fields:
|
||||
|
||||
| Field | Required | Type | Description |
|
||||
|------------|:--------:|---------------------|------------------------------------------------------------------------------------------------------------|
|
||||
| id | ✓ | string | The identifier of the vulnerability, misconfiguration, secret, or license[^1]. |
|
||||
| paths | | string array | The list of file paths to be ignored. If `paths` is not set, the ignore finding is applied to all files. |
|
||||
| expired_at | | date (`yyyy-mm-dd`) | The expiration date of the ignore finding. If `expired_at` is not set, the ignore finding is always valid. |
|
||||
| statement | | string | The reason for ignoring the finding. (This field is not used for filtering.) |
|
||||
| Field | Required | Type | Description |
|
||||
|------------|:--------:|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| id | ✓ | string | The identifier of the vulnerability, misconfiguration, secret, or license[^1]. |
|
||||
| paths[^2] | | string array | The list of file paths to ignore. If `paths` is not set, the ignore finding is applied to all files. |
|
||||
| purls | | string array | The list of PURLs to ignore packages. If `purls` is not set, the ignore finding is applied to all packages. This field is currently available only for vulnerabilities. |
|
||||
| expired_at | | date (`yyyy-mm-dd`) | The expiration date of the ignore finding. If `expired_at` is not set, the ignore finding is always valid. |
|
||||
| statement | | string | The reason for ignoring the finding. (This field is not used for filtering.) |
|
||||
|
||||
```bash
|
||||
$ cat .trivyignore.yaml
|
||||
@@ -288,6 +356,8 @@ vulnerabilities:
|
||||
- id: CVE-2023-2650
|
||||
- id: CVE-2023-3446
|
||||
- id: CVE-2023-3817
|
||||
purls:
|
||||
- "pkg:deb/debian/libssl1.1"
|
||||
- id: CVE-2023-29491
|
||||
expired_at: 2023-09-01
|
||||
|
||||
@@ -339,83 +409,14 @@ Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
## By Vulnerability Target
|
||||
| Scanner | Supported |
|
||||
|:----------------:|:---------:|
|
||||
| Vulnerability | ✓ |
|
||||
| Misconfiguration | |
|
||||
| Secret | |
|
||||
| License | |
|
||||
|
||||
Use `--vuln-type` option.
|
||||
|
||||
```bash
|
||||
$ trivy image --vuln-type os ruby:2.4.0
|
||||
```
|
||||
|
||||
Available values:
|
||||
|
||||
- library
|
||||
- os
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
```bash
|
||||
2019-05-22T19:36:50.530+0200 [34mINFO[0m Updating vulnerability database...
|
||||
2019-05-22T19:36:51.681+0200 [34mINFO[0m Detecting Alpine vulnerabilities...
|
||||
2019-05-22T19:36:51.685+0200 [34mINFO[0m Updating npm Security DB...
|
||||
2019-05-22T19:36:52.389+0200 [34mINFO[0m Detecting npm vulnerabilities...
|
||||
2019-05-22T19:36:52.390+0200 [34mINFO[0m Updating pipenv Security DB...
|
||||
2019-05-22T19:36:53.406+0200 [34mINFO[0m Detecting pipenv vulnerabilities...
|
||||
|
||||
ruby:2.4.0 (debian 8.7)
|
||||
=======================
|
||||
Total: 7 (UNKNOWN: 0, LOW: 1, MEDIUM: 1, HIGH: 3, CRITICAL: 2)
|
||||
|
||||
+---------+------------------+----------+-------------------+---------------+----------------------------------+
|
||||
| LIBRARY | VULNERABILITY ID | 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 |
|
||||
+ +------------------+----------+ +---------------+----------------------------------+
|
||||
| | CVE-2018-16839 | HIGH | | 7.61.1-r1 | curl: Integer overflow leading |
|
||||
| | | | | | to heap-based buffer overflow in |
|
||||
| | | | | | Curl_sasl_create_plain_message() |
|
||||
+---------+------------------+----------+-------------------+---------------+----------------------------------+
|
||||
| git | CVE-2018-17456 | HIGH | 2.15.2-r0 | 2.15.3-r0 | git: arbitrary code execution |
|
||||
| | | | | | via .gitmodules |
|
||||
+ +------------------+ + + +----------------------------------+
|
||||
| | CVE-2018-19486 | | | | git: Improper handling of |
|
||||
| | | | | | PATH allows for commands to be |
|
||||
| | | | | | executed from... |
|
||||
+---------+------------------+----------+-------------------+---------------+----------------------------------+
|
||||
| libssh2 | CVE-2019-3855 | CRITICAL | 1.8.0-r2 | 1.8.1-r0 | libssh2: Integer overflow in |
|
||||
| | | | | | transport read resulting in |
|
||||
| | | | | | out of bounds write... |
|
||||
+---------+------------------+----------+-------------------+---------------+----------------------------------+
|
||||
| sqlite | CVE-2018-20346 | MEDIUM | 3.21.0-r1 | 3.25.3-r0 | CVE-2018-20505 CVE-2018-20506 |
|
||||
| | | | | | sqlite: Multiple flaws in |
|
||||
| | | | | | sqlite which can be triggered |
|
||||
| | | | | | via... |
|
||||
+---------+------------------+----------+-------------------+---------------+----------------------------------+
|
||||
| tar | CVE-2018-20482 | LOW | 1.29-r1 | 1.31-r0 | tar: Infinite read loop in |
|
||||
| | | | | | sparse_dump_region function in |
|
||||
| | | | | | sparse.c |
|
||||
+---------+------------------+----------+-------------------+---------------+----------------------------------+
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## By Rego
|
||||
### By Rego
|
||||
|
||||
| Scanner | Supported |
|
||||
|:----------------:|:---------:|
|
||||
| Vulnerability | ✓ |
|
||||
| Misconfiguration | ✓ |
|
||||
| Secret | |
|
||||
| License | |
|
||||
| Secret | ✓ |
|
||||
| License | ✓ |
|
||||
|
||||
!!! warning "EXPERIMENTAL"
|
||||
This feature might change without preserving backwards compatibility.
|
||||
@@ -460,7 +461,8 @@ trivy image -f json centos:7
|
||||
...
|
||||
```
|
||||
|
||||
Each individual vulnerability (under `Results.Vulnerabilities`) or Misconfiguration (under `Results.Misconfigurations`) is evaluated for exclusion or inclusion by the `ignore` rule.
|
||||
Each individual Vulnerability, Misconfiguration, License and Secret (under `Results.Vulnerabilities`, `Results.Misconfigurations`,
|
||||
`Results.Licenses`, `Results.Secrets`) is evaluated for exclusion or inclusion by the `ignore` rule.
|
||||
|
||||
The following is a Rego ignore policy that filters out every vulnerability with a specific CWE ID (as seen in the JSON example above):
|
||||
|
||||
@@ -481,41 +483,18 @@ trivy image --ignore-policy contrib/example_policy/basic.rego centos:7
|
||||
For more advanced use cases, there is a built-in Rego library with helper functions that you can import into your policy using: `import data.lib.trivy`.
|
||||
More info about the helper functions are in the library [here](https://github.com/aquasecurity/trivy/tree/{{ git.tag }}/pkg/result/module.go).
|
||||
|
||||
You can find more example policies [here](https://github.com/aquasecurity/trivy/tree/{{ git.tag }}/pkg/result/module.go)
|
||||
|
||||
## By Inline Comments
|
||||
You can find more example checks [here](https://github.com/aquasecurity/trivy/tree/{{ git.tag }}/pkg/result/module.go)
|
||||
|
||||
### By Vulnerability Exploitability Exchange (VEX)
|
||||
| Scanner | Supported |
|
||||
|:----------------:|:---------:|
|
||||
| Vulnerability | |
|
||||
| Misconfiguration | ✓ |
|
||||
| Vulnerability | ✓ |
|
||||
| Misconfiguration | |
|
||||
| Secret | |
|
||||
| License | |
|
||||
|
||||
Some configuration file formats (e.g. Terraform) support inline comments.
|
||||
Please refer to the [VEX documentation](../supply-chain/vex.md) for the details.
|
||||
|
||||
In cases where trivy can detect comments of a specific format immediately adjacent to resource definitions, it is possible to filter/ignore findings from a single point of resource definition (in contrast to `.trivyignore`, which has a directory-wide scope on all of the files scanned).
|
||||
|
||||
The format for these comments is `trivy:ignore:<Vulnerability ID>` immediately following the format-specific line-comment token. You can add multiple ignores on the same comment line.
|
||||
|
||||
For example, to filter a Vulnerability ID "AVD-GCP-0051" in a Terraform HCL file:
|
||||
|
||||
```terraform
|
||||
#trivy:ignore:AVD-GCP-0051
|
||||
resource "google_container_cluster" "one_off_test" {
|
||||
name = var.cluster_name
|
||||
location = var.region
|
||||
}
|
||||
```
|
||||
|
||||
For example, to filter vulnerabilities "AVD-GCP-0051" and "AVD-GCP-0053" in a Terraform HCL file:
|
||||
|
||||
```terraform
|
||||
#trivy:ignore:AVD-GCP-0051 trivy:ignore:AVD-GCP-0053
|
||||
resource "google_container_cluster" "one_off_test" {
|
||||
name = var.cluster_name
|
||||
location = var.region
|
||||
}
|
||||
```
|
||||
|
||||
[^1]: license name is used as id for `.trivyignore.yaml` files
|
||||
[^1]: license name is used as id for `.trivyignore.yaml` files.
|
||||
[^2]: This doesn't work for os package licenses (e.g. apk, dpkg, rpm). For projects which manage dependencies through a dependency file (e.g. go.mod, yarn.lock) `path` should point to that particular file.
|
||||
|
||||
@@ -63,6 +63,7 @@ The following languages are currently supported:
|
||||
| Go | [go.mod][go-mod] |
|
||||
| PHP | [composer.lock][composer-lock] |
|
||||
| Java | [pom.xml][pom-xml] |
|
||||
| | [*gradle.lockfile][gradle-lockfile] |
|
||||
| Dart | [pubspec.lock][pubspec-lock] |
|
||||
|
||||
This tree is the reverse of the dependency graph.
|
||||
@@ -398,7 +399,7 @@ $ trivy <target> [--format <format>] --output plugin=<plugin_name> [--output-plu
|
||||
```
|
||||
|
||||
This is useful for cases where you want to convert the output into a custom format, or when you want to send the output somewhere.
|
||||
For more details, please check [here](../advanced/plugins.md#output-plugins).
|
||||
For more details, please check [here](../plugin/user-guide.md#output-mode-support).
|
||||
|
||||
## Converting
|
||||
To generate multiple reports, you can generate the JSON report first and convert it to other formats with the `convert` subcommand.
|
||||
@@ -445,5 +446,6 @@ $ trivy convert --format table --severity CRITICAL result.json
|
||||
[go-mod]: ../coverage/language/golang.md#go-modules
|
||||
[composer-lock]: ../coverage/language/php.md#composer
|
||||
[pom-xml]: ../coverage/language/java.md#pomxml
|
||||
[gradle-lockfile]: ../coverage/language/java.md#gradlelock
|
||||
[pubspec-lock]: ../coverage/language/dart.md#dart
|
||||
[cargo-binaries]: ../coverage/language/rust.md#binaries
|
||||
@@ -11,7 +11,7 @@ The following scanners are supported.
|
||||
Trivy recursively searches directories and scans all found Helm files.
|
||||
|
||||
It evaluates variables, functions, and other elements within Helm templates and resolve the chart to Kubernetes manifests then run the Kubernetes checks.
|
||||
See [here](../../scanner/misconfiguration/policy/builtin.md) for more details on the built-in policies.
|
||||
See [here](../../scanner/misconfiguration/check/builtin.md) for more details on the built-in checks.
|
||||
|
||||
### Value overrides
|
||||
There are a number of options for overriding values in Helm charts.
|
||||
|
||||
@@ -8,14 +8,15 @@ Trivy scans Infrastructure as Code (IaC) files for
|
||||
|
||||
## Supported configurations
|
||||
|
||||
| Config type | File patterns |
|
||||
|-------------------------------------|-------------------------------|
|
||||
| [Kubernetes](kubernetes.md) | *.yml, *.yaml, *.json |
|
||||
| [Docker](docker.md) | Dockerfile, Containerfile |
|
||||
| [Terraform](terraform.md) | *.tf, *.tf.json, *.tfvars, |
|
||||
| [CloudFormation](cloudformation.md) | *.yml, *.yaml, *.json |
|
||||
| [Azure ARM Template](azure-arm.md) | *.json |
|
||||
| [Helm](helm.md) | *.yaml, *.tpl, *.tar.gz, etc. |
|
||||
| Config type | File patterns |
|
||||
|-------------------------------------|-----------------------------------------------|
|
||||
| [Kubernetes](kubernetes.md) | \*.yml, \*.yaml, \*.json |
|
||||
| [Docker](docker.md) | Dockerfile, Containerfile |
|
||||
| [Terraform](terraform.md) | \*.tf, \*.tf.json, \*.tfvars |
|
||||
| [Terraform Plan](terraform.md) | tfplan, \*.tfplan, \*.tfplan.json, \*.tf.json |
|
||||
| [CloudFormation](cloudformation.md) | \*.yml, \*.yaml, \*.json |
|
||||
| [Azure ARM Template](azure-arm.md) | \*.json |
|
||||
| [Helm](helm.md) | \*.yaml, \*.tpl, \*.tar.gz, etc. |
|
||||
|
||||
[misconf]: ../../scanner/misconfiguration/index.md
|
||||
[secret]: ../../scanner/secret.md
|
||||
|
||||
@@ -8,18 +8,23 @@ Trivy supports the scanners listed in the table below.
|
||||
|
||||
It supports the following formats:
|
||||
|
||||
| Format | Supported |
|
||||
|:---------:|:---------:|
|
||||
| JSON | ✓ |
|
||||
| HCL | ✓ |
|
||||
| Plan JSON | ✓ |
|
||||
|
||||
Trivy can scan the results of `terraform plan`.
|
||||
You can scan by passing the file generated as shown below to Trivy:
|
||||
| Format | Supported |
|
||||
|:-------------:|:---------:|
|
||||
| JSON | ✓ |
|
||||
| HCL | ✓ |
|
||||
| Plan Snapshot | ✓ |
|
||||
| Plan JSON | ✓ |
|
||||
|
||||
Trivy can scan Terraform Plan files (snapshots) or their JSON representations. To create a Terraform Plan and scan it, run the following command:
|
||||
```bash
|
||||
terraform plan --out tfplan
|
||||
trivy conf tfplan
|
||||
```
|
||||
$ terraform plan --out tfplan.binary
|
||||
$ terraform show -json tfplan.binary > tfplan.json
|
||||
|
||||
To scan a Terraform Plan representation in JSON format, run the following command:
|
||||
```bash
|
||||
terraform show -json tfplan > tfplan.json
|
||||
trivy conf tfplan.json
|
||||
```
|
||||
|
||||
## Misconfiguration
|
||||
|
||||
@@ -1,23 +1,34 @@
|
||||
# C/C++
|
||||
|
||||
Trivy supports [Conan][conan] C/C++ Package Manager.
|
||||
Trivy supports Conan C/C++ Package Manager ([v1][conanV1] and [v2][conanV2] with limitations).
|
||||
|
||||
The following scanners are supported.
|
||||
|
||||
| Package manager | SBOM | Vulnerability | License |
|
||||
| --------------- | :---: | :-----------: | :-----: |
|
||||
| Conan | ✓ | ✓ | - |
|
||||
| Package manager | SBOM | Vulnerability | License |
|
||||
|-----------------|:----:|:-------------:|:-------:|
|
||||
| Conan | ✓ | ✓ | ✓[^1] |
|
||||
|
||||
The following table provides an outline of the features Trivy offers.
|
||||
|
||||
| Package manager | File | Transitive dependencies | Dev dependencies | [Dependency graph][dependency-graph] | Position |
|
||||
| --------------- | -------------- | :---------------------: | :--------------: | :----------------------------------: | :------: |
|
||||
| Conan | conan.lock[^1] | ✓ | Excluded | ✓ | ✓ |
|
||||
| Package manager | File | Transitive dependencies | Dev dependencies | [Dependency graph][dependency-graph] | Position |
|
||||
|-----------------------|----------------|:-----------------------:|:----------------:|:------------------------------------:|:--------:|
|
||||
| Conan (lockfile v1) | conan.lock[^2] | ✓ | Excluded | ✓ | ✓ |
|
||||
| Conan (lockfile v2) | conan.lock[^2] | ✓ [^3] | Excluded | - | ✓ |
|
||||
|
||||
## Conan
|
||||
In order to detect dependencies, Trivy searches for `conan.lock`[^1].
|
||||
|
||||
[conan]: https://docs.conan.io/1/index.html
|
||||
[conanV1]: https://docs.conan.io/1/index.html
|
||||
[conanV2]: https://docs.conan.io/2/
|
||||
|
||||
### Licenses
|
||||
The Conan lock file doesn't contain any license information.
|
||||
To obtain licenses we parse the `conanfile.py` files from the [conan cache directory][conan-cache-dir].
|
||||
To correctly detection licenses, ensure that the cache directory contains all dependencies used.
|
||||
|
||||
[conan-cache-dir]: https://docs.conan.io/1/mastering/custom_cache.html
|
||||
[dependency-graph]: ../../configuration/reporting.md#show-origins-of-vulnerable-dependencies
|
||||
|
||||
[^1]: `conan.lock` is default name. To scan a custom filename use [file-patterns](../../configuration/skipping.md#file-patterns)
|
||||
[^1]: The local cache should contain the dependencies used. See [licenses](#licenses).
|
||||
[^2]: `conan.lock` is default name. To scan a custom filename use [file-patterns](../../configuration/skipping.md#file-patterns).
|
||||
[^3]: For `conan.lock` in version 2, indirect dependencies are included in analysis but not flagged explicitly in dependency tree
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# Go
|
||||
|
||||
## Data Sources
|
||||
The data sources are listed [here](../../scanner/vulnerability.md#data-sources-1).
|
||||
Trivy uses Go Vulnerability Database for standard packages, such as `net/http`, and uses GitHub Advisory Database for third-party packages.
|
||||
|
||||
## Features
|
||||
Trivy supports two types of Go scanning, Go Modules and binaries built by Go.
|
||||
|
||||
@@ -12,10 +16,10 @@ The following scanners are supported.
|
||||
|
||||
The table below provides an outline of the features Trivy offers.
|
||||
|
||||
| Artifact | Offline[^1] | Dev dependencies | [Dependency graph][dependency-graph] |
|
||||
|----------|:-----------:|:-----------------|:----------------------------------:|
|
||||
| Modules | ✅ | Include | ✅[^2] |
|
||||
| Binaries | ✅ | Exclude | - |
|
||||
| Artifact | Offline[^1] | Dev dependencies | [Dependency graph][dependency-graph] | Stdlib |
|
||||
|----------|:-----------:|:-----------------|:------------------------------------:|:------:|
|
||||
| Modules | ✅ | Include | ✅[^2] | - |
|
||||
| Binaries | ✅ | Exclude | - | ✅[^4] |
|
||||
|
||||
!!! note
|
||||
Trivy scans only dependencies of the Go project.
|
||||
@@ -74,7 +78,20 @@ $ trivy rootfs ./your_binary
|
||||
!!! note
|
||||
It doesn't work with UPX-compressed binaries.
|
||||
|
||||
#### Empty versions
|
||||
There are times when Go uses the `(devel)` version for modules/dependencies.
|
||||
|
||||
- Only Go binaries installed using the `go install` command contain correct (semver) version for the main module.
|
||||
In other cases, Go uses the `(devel)` version[^3].
|
||||
- Dependencies replaced with local ones use the `(devel)` versions.
|
||||
|
||||
In the first case, Trivy will attempt to parse any `-ldflags` as a secondary source, and will leave the version
|
||||
empty if it cannot do so[^5]. For the second case, the version of such packages is empty.
|
||||
|
||||
[^1]: It doesn't require the Internet access.
|
||||
[^2]: Need to download modules to local cache beforehand
|
||||
[^3]: See https://github.com/aquasecurity/trivy/issues/1837#issuecomment-1832523477
|
||||
[^4]: Identify the Go version used to compile the binary and detect its vulnerabilities
|
||||
[^5]: See https://github.com/golang/go/issues/63432#issuecomment-1751610604
|
||||
|
||||
[dependency-graph]: ../../configuration/reporting.md#show-origins-of-vulnerable-dependencies
|
||||
[dependency-graph]: ../../configuration/reporting.md#show-origins-of-vulnerable-dependencies
|
||||
|
||||
@@ -47,6 +47,7 @@ On the other hand, when the target is a post-build artifact, like a container im
|
||||
| [Dart](dart.md) | pubspec.lock | - | - | ✅ | ✅ |
|
||||
| [Swift](swift.md) | Podfile.lock | - | - | ✅ | ✅ |
|
||||
| | Package.resolved | - | - | ✅ | ✅ |
|
||||
| [Julia](julia.md) | Manifest.toml | ✅ | ✅ | ✅ | ✅ |
|
||||
|
||||
The path of these files does not matter.
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ Trivy supports three types of Java scanning: `JAR/WAR/PAR/EAR`, `pom.xml` and `*
|
||||
|
||||
Each artifact supports the following scanners:
|
||||
|
||||
| Artifact | SBOM | Vulnerability | License |
|
||||
| ---------------- | :---: | :-----------: | :-----: |
|
||||
| JAR/WAR/PAR/EAR | ✓ | ✓ | - |
|
||||
| pom.xml | ✓ | ✓ | ✓ |
|
||||
| *gradle.lockfile | ✓ | ✓ | - |
|
||||
| Artifact | SBOM | Vulnerability | License |
|
||||
|------------------|:----:|:-------------:|:-------:|
|
||||
| JAR/WAR/PAR/EAR | ✓ | ✓ | - |
|
||||
| pom.xml | ✓ | ✓ | ✓ |
|
||||
| *gradle.lockfile | ✓ | ✓ | ✓ |
|
||||
|
||||
The following table provides an outline of the features Trivy offers.
|
||||
|
||||
@@ -15,7 +15,7 @@ The following table provides an outline of the features Trivy offers.
|
||||
|------------------|:---------------------:|:----------------:|:------------------------------------:|:--------:|
|
||||
| JAR/WAR/PAR/EAR | Trivy Java DB | Include | - | - |
|
||||
| pom.xml | Maven repository [^1] | Exclude | ✓ | ✓[^7] |
|
||||
| *gradle.lockfile | - | Exclude | - | - |
|
||||
| *gradle.lockfile | - | Exclude | ✓ | ✓ |
|
||||
|
||||
These may be enabled or disabled depending on the target.
|
||||
See [here](./index.md) for the detail.
|
||||
@@ -42,7 +42,19 @@ Trivy parses your `pom.xml` file and tries to find files with dependencies from
|
||||
- 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/).
|
||||
### remote repositories
|
||||
If your machine doesn't have the necessary files - Trivy tries to find the information about these dependencies in the remote repositories:
|
||||
|
||||
- [repositories from pom files][maven-pom-repos]
|
||||
- [maven central repository][maven-central]
|
||||
|
||||
Trivy reproduces Maven's repository selection and priority:
|
||||
|
||||
- for snapshot artifacts:
|
||||
- check only snapshot repositories from pom files (if exists)
|
||||
- for other artifacts:
|
||||
- check release repositories from pom files (if exists)
|
||||
- check [maven central][maven-central]
|
||||
|
||||
!!! Note
|
||||
Trivy only takes information about packages. We don't take a list of vulnerabilities for packages from the `maven repository`.
|
||||
@@ -55,12 +67,33 @@ 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
|
||||
### maven-invoker-plugin
|
||||
Typically, the integration tests directory (`**/[src|target]/it/*/pom.xml`) of [maven-invoker-plugin][maven-invoker-plugin] doesn't contain actual `pom.xml` files and should be skipped to avoid noise.
|
||||
|
||||
Trivy marks dependencies from these files as the development dependencies and skip them by default.
|
||||
If you need to show them, use the `--include-dev-deps` flag.
|
||||
|
||||
|
||||
## Gradle.lock
|
||||
`gradle.lock` files only contain information about used dependencies.
|
||||
|
||||
!!!note
|
||||
All necessary files are checked locally. Gradle file scanning doesn't require internet access.
|
||||
|
||||
### Dependency-tree
|
||||
!!! warning "EXPERIMENTAL"
|
||||
This feature might change without preserving backwards compatibility.
|
||||
Trivy finds child dependencies from `*.pom` files in the cache[^8] directory.
|
||||
|
||||
But there is no reliable way to determine direct dependencies (even using other files).
|
||||
Therefore, we mark all dependencies as indirect to use logic to guess direct dependencies and build a dependency tree.
|
||||
|
||||
### Licenses
|
||||
Trity also can detect licenses for dependencies.
|
||||
|
||||
Make sure that you have cache[^8] directory to find licenses from `*.pom` dependency files.
|
||||
|
||||
[^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`
|
||||
@@ -68,5 +101,9 @@ It doesn't require the internet access.
|
||||
[^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
|
||||
[^7]: To avoid confusion, Trivy only finds locations for direct dependencies from the base pom.xml file.
|
||||
[^8]: The supported directories are `$GRADLE_USER_HOME/caches` and `$HOME/.gradle/caches` (`%HOMEPATH%\.gradle\caches` for Windows).
|
||||
|
||||
[dependency-graph]: ../../configuration/reporting.md#show-origins-of-vulnerable-dependencies
|
||||
[dependency-graph]: ../../configuration/reporting.md#show-origins-of-vulnerable-dependencies
|
||||
[maven-invoker-plugin]: https://maven.apache.org/plugins/maven-invoker-plugin/usage.html
|
||||
[maven-central]: https://repo.maven.apache.org/maven2/
|
||||
[maven-pom-repos]: https://maven.apache.org/settings.html#repositories
|
||||
30
docs/docs/coverage/language/julia.md
Normal file
30
docs/docs/coverage/language/julia.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Julia
|
||||
|
||||
## Features
|
||||
|
||||
Trivy supports [Pkg.jl](https://pkgdocs.julialang.org/v1/), which is the Julia package manager.
|
||||
The following scanners are supported.
|
||||
|
||||
| Package manager | SBOM | Vulnerability | License |
|
||||
|-----------------|:----:|:-------------:|:-------:|
|
||||
| Pkg.jl | ✓ | - | - |
|
||||
|
||||
The following table provides an outline of the features Trivy offers.
|
||||
|
||||
| Package manager | File | Transitive dependencies | Dev dependencies | License | Dependency graph | Position |
|
||||
| --------------- | ------------- | :---------------------: | :--------------- | :-----: | :--------------: | :------: |
|
||||
| Pkg.jl | Manifest.toml | ✅ | Excluded[^1] | - | ✅ | ✅ |
|
||||
|
||||
### Pkg.jl
|
||||
|
||||
Trivy searches for `Manifest.toml` to detect dependencies.
|
||||
|
||||
Trivy also supports dependency trees; however, to display an accurate tree, it needs to know whether each package is a direct dependency of the project.
|
||||
Since this information is not included in `Manifest.toml`, Trivy parses `Project.toml`, which should be located next to `Project.toml`.
|
||||
If you want to see the dependency tree, please ensure that `Project.toml` is present.
|
||||
|
||||
Scanning `Manifest.toml` and `Project.toml` together also removes developer dependencies.
|
||||
|
||||
Dependency extensions are currently ignored.
|
||||
|
||||
[^1]: When you scan `Manifest.toml` and `Project.toml` together.
|
||||
@@ -13,12 +13,12 @@ The following scanners are supported.
|
||||
|
||||
The following table provides an outline of the features Trivy offers.
|
||||
|
||||
| Package manager | File | Transitive dependencies | Dev dependencies | [Dependency graph][dependency-graph] | Position |
|
||||
|:---------------:|-------------------|:-----------------------:|:-----------------:|:------------------------------------:|:--------:|
|
||||
| npm | package-lock.json | ✓ | [Excluded](#npm) | ✓ | ✓ |
|
||||
| Yarn | yarn.lock | ✓ | [Excluded](#yarn) | ✓ | ✓ |
|
||||
| pnpm | pnpm-lock.yaml | ✓ | Excluded | ✓ | - |
|
||||
| Bun | yarn.lock | ✓ | [Excluded](#yarn) | ✓ | ✓ |
|
||||
| Package manager | File | Transitive dependencies | Dev dependencies | [Dependency graph][dependency-graph] | Position |
|
||||
|:---------------:|-------------------|:-----------------------:|:---------------------------------:|:------------------------------------:|:--------:|
|
||||
| npm | package-lock.json | ✓ | [Excluded](#npm) | ✓ | ✓ |
|
||||
| Yarn | yarn.lock | ✓ | [Excluded](#yarn) | ✓ | ✓ |
|
||||
| pnpm | pnpm-lock.yaml | ✓ | [Excluded](#lock-file-v9-version) | ✓ | - |
|
||||
| Bun | yarn.lock | ✓ | [Excluded](#yarn) | ✓ | ✓ |
|
||||
|
||||
In addition, Trivy scans installed packages with `package.json`.
|
||||
|
||||
@@ -55,6 +55,9 @@ By default, Trivy doesn't report development dependencies. Use the `--include-de
|
||||
### pnpm
|
||||
Trivy parses `pnpm-lock.yaml`, then finds production dependencies and builds a [tree][dependency-graph] of dependencies with vulnerabilities.
|
||||
|
||||
#### lock file v9 version
|
||||
Trivy supports `Dev` field for `pnpm-lock.yaml` v9 or later. Use the `--include-dev-deps` flag to include the developer's dependencies in the result.
|
||||
|
||||
### Bun
|
||||
Trivy supports scanning `yarn.lock` files generated by [Bun](https://bun.sh/docs/install/lockfile#how-do-i-inspect-bun-s-lockfile). You can use the command `bun install -y` to generate a Yarn-compatible `yarn.lock`.
|
||||
|
||||
@@ -69,5 +72,6 @@ Trivy searches for `package.json` files under `node_modules` and identifies inst
|
||||
It only extracts package names, versions and licenses for those packages.
|
||||
|
||||
[dependency-graph]: ../../configuration/reporting.md#show-origins-of-vulnerable-dependencies
|
||||
[pnpm-lockfile-v6]: https://github.com/pnpm/spec/blob/fd3238639af86c09b7032cc942bab3438b497036/lockfile/6.0.md
|
||||
|
||||
[^1]: [yarn.lock](#bun) must be generated
|
||||
|
||||
@@ -3,29 +3,29 @@
|
||||
Trivy supports three types of Python package managers: `pip`, `Pipenv` and `Poetry`.
|
||||
The following scanners are supported for package managers.
|
||||
|
||||
| Package manager | SBOM | Vulnerability | License |
|
||||
| --------------- | :---: | :-----------: | :-----: |
|
||||
| pip | ✓ | ✓ | - |
|
||||
| Pipenv | ✓ | ✓ | - |
|
||||
| Poetry | ✓ | ✓ | - |
|
||||
| Package manager | SBOM | Vulnerability | License |
|
||||
|-----------------|:----:|:-------------:|:-------:|
|
||||
| pip | ✓ | ✓ | ✓ |
|
||||
| Pipenv | ✓ | ✓ | - |
|
||||
| Poetry | ✓ | ✓ | - |
|
||||
|
||||
In addition, Trivy supports three formats of Python packages: `egg`, `wheel` and `conda`.
|
||||
The following scanners are supported for Python packages.
|
||||
|
||||
| Packaging | SBOM | Vulnerability | License |
|
||||
| --------- | :---: | :-----------: | :-----: |
|
||||
| Egg | ✓ | ✓ | ✓ |
|
||||
| Wheel | ✓ | ✓ | ✓ |
|
||||
| Conda | ✓ | - | - |
|
||||
| Packaging | SBOM | Vulnerability | License |
|
||||
|-----------|:----:|:-------------:|:-------:|
|
||||
| Egg | ✓ | ✓ | ✓ |
|
||||
| Wheel | ✓ | ✓ | ✓ |
|
||||
| Conda | ✓ | - | - |
|
||||
|
||||
|
||||
The following table provides an outline of the features Trivy offers.
|
||||
|
||||
| Package manager | File | Transitive dependencies | Dev dependencies | [Dependency graph][dependency-graph] | Position |
|
||||
|-----------------|------------------|:-----------------------:|:----------------:|:------------------------------------:|:--------:|
|
||||
| pip | requirements.txt | - | Include | - | - |
|
||||
| pip | requirements.txt | - | Include | - | ✓ |
|
||||
| Pipenv | Pipfile.lock | ✓ | Include | - | ✓ |
|
||||
| Poetry | poetry.lock | ✓ | Exclude | ✓ | |
|
||||
| Poetry | poetry.lock | ✓ | Exclude | ✓ | - |
|
||||
|
||||
|
||||
| Packaging | Dependency graph |
|
||||
@@ -40,6 +40,8 @@ See [here](./index.md) for the detail.
|
||||
Trivy parses your files generated by package managers in filesystem/repository scanning.
|
||||
|
||||
### pip
|
||||
|
||||
#### Dependency detection
|
||||
Trivy only parses [version specifiers](https://packaging.python.org/en/latest/specifications/version-specifiers/#id4) with `==` comparison operator and without `.*`.
|
||||
To convert unsupported version specifiers - use the `pip freeze` command.
|
||||
|
||||
@@ -91,7 +93,16 @@ urllib3==1.26.15
|
||||
`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`.
|
||||
#### License detection
|
||||
|
||||
`requirements.txt` files don't contain information about licenses.
|
||||
Therefore, Trivy checks `METADATA` files from `lib/site-packages` directory.
|
||||
|
||||
Trivy uses 3 ways to detect `site-packages` directory:
|
||||
|
||||
- Checks `VIRTUAL_ENV` environment variable.
|
||||
- Detects path to `python`[^1] binary and checks `../lib/pythonX.Y/site-packages` directory.
|
||||
- Detects path to `python`[^1] binary and checks `../../lib/site-packages` directory.
|
||||
|
||||
### Pipenv
|
||||
Trivy parses `Pipfile.lock`.
|
||||
@@ -116,4 +127,6 @@ Trivy looks for `*.egg-info`, `*.egg-info/PKG-INFO`, `*.egg` and `EGG-INFO/PKG-I
|
||||
### Wheel
|
||||
Trivy looks for `.dist-info/META-DATA` to identify Python packages.
|
||||
|
||||
[^1]: Trivy checks `python`, `python3`, `python2` and `python.exe` file names.
|
||||
|
||||
[dependency-graph]: ../../configuration/reporting.md#show-origins-of-vulnerable-dependencies
|
||||
|
||||
36
docs/docs/coverage/os/conda.md
Normal file
36
docs/docs/coverage/os/conda.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Conda
|
||||
|
||||
Trivy supports the following scanners for Conda packages.
|
||||
|
||||
| Scanner | Supported |
|
||||
|:-------------:|:---------:|
|
||||
| SBOM | ✓ |
|
||||
| Vulnerability | - |
|
||||
| License | ✓[^1] |
|
||||
|
||||
|
||||
## SBOM
|
||||
Trivy detects packages that have been installed with `Conda`.
|
||||
|
||||
|
||||
### `<package>.json`
|
||||
Trivy parses `<conda-root>/envs/<env>/conda-meta/<package>.json` files to find the version and license for the dependencies installed in your env.
|
||||
|
||||
### `environment.yml`[^2]
|
||||
Trivy supports parsing [environment.yml][environment.yml][^2] files to find dependency list.
|
||||
|
||||
!!! note
|
||||
License detection is currently not supported.
|
||||
|
||||
`environment.yml`[^2] files supports [version range][env-version-range]. We can't be sure about versions for these dependencies.
|
||||
Therefore, you need to use `conda env export` command to get dependency list in `Conda` default format before scanning `environment.yml`[^2] file.
|
||||
|
||||
!!! note
|
||||
For dependencies in a non-Conda format, Trivy doesn't include a version of them.
|
||||
|
||||
|
||||
[^1]: License detection is only supported for `<package>.json` files
|
||||
[^2]: Trivy supports both `yaml` and `yml` extensions.
|
||||
|
||||
[environment.yml]: https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#sharing-an-environment
|
||||
[env-version-range]: https://docs.conda.io/projects/conda-build/en/latest/resources/package-spec.html#examples-of-package-specs
|
||||
@@ -9,23 +9,24 @@ Trivy supports operating systems for
|
||||
|
||||
## Supported OS
|
||||
|
||||
| OS | Supported Versions | Package Managers |
|
||||
|-----------------------------------------------|-------------------------------------|------------------|
|
||||
| [Alpine Linux](alpine.md) | 2.2 - 2.7, 3.0 - 3.19, edge | apk |
|
||||
| [Wolfi Linux](wolfi.md) | (n/a) | apk |
|
||||
| [Chainguard](chainguard.md) | (n/a) | apk |
|
||||
| [Red Hat Enterprise Linux](rhel.md) | 6, 7, 8 | dnf/yum/rpm |
|
||||
| [CentOS](centos.md)[^1] | 6, 7, 8 | dnf/yum/rpm |
|
||||
| [AlmaLinux](alma.md) | 8, 9 | dnf/yum/rpm |
|
||||
| [Rocky Linux](rocky.md) | 8, 9 | dnf/yum/rpm |
|
||||
| [Oracle Linux](oracle.md) | 5, 6, 7, 8 | dnf/yum/rpm |
|
||||
| [CBL-Mariner](cbl-mariner.md) | 1.0, 2.0 | dnf/yum/rpm |
|
||||
| [Amazon Linux](amazon.md) | 1, 2, 2023 | dnf/yum/rpm |
|
||||
| [openSUSE Leap](suse.md) | 42, 15 | zypper/rpm |
|
||||
| [SUSE Enterprise Linux](suse.md) | 11, 12, 15 | zypper/rpm |
|
||||
| [Photon OS](photon.md) | 1.0, 2.0, 3.0, 4.0 | tndf/yum/rpm |
|
||||
| [Debian GNU/Linux](debian.md) | 7, 8, 9, 10, 11, 12 | apt/dpkg |
|
||||
| [Ubuntu](ubuntu.md) | All versions supported by Canonical | apt/dpkg |
|
||||
| OS | Supported Versions | Package Managers |
|
||||
|--------------------------------------|-------------------------------------|------------------|
|
||||
| [Alpine Linux](alpine.md) | 2.2 - 2.7, 3.0 - 3.20, edge | apk |
|
||||
| [Wolfi Linux](wolfi.md) | (n/a) | apk |
|
||||
| [Chainguard](chainguard.md) | (n/a) | apk |
|
||||
| [Red Hat Enterprise Linux](rhel.md) | 6, 7, 8 | dnf/yum/rpm |
|
||||
| [CentOS](centos.md)[^1] | 6, 7, 8 | dnf/yum/rpm |
|
||||
| [AlmaLinux](alma.md) | 8, 9 | dnf/yum/rpm |
|
||||
| [Rocky Linux](rocky.md) | 8, 9 | dnf/yum/rpm |
|
||||
| [Oracle Linux](oracle.md) | 5, 6, 7, 8 | dnf/yum/rpm |
|
||||
| [CBL-Mariner](cbl-mariner.md) | 1.0, 2.0 | dnf/yum/rpm |
|
||||
| [Amazon Linux](amazon.md) | 1, 2, 2023 | dnf/yum/rpm |
|
||||
| [openSUSE Leap](suse.md) | 42, 15 | zypper/rpm |
|
||||
| [SUSE Enterprise Linux](suse.md) | 11, 12, 15 | zypper/rpm |
|
||||
| [Photon OS](photon.md) | 1.0, 2.0, 3.0, 4.0 | tndf/yum/rpm |
|
||||
| [Debian GNU/Linux](debian.md) | 7, 8, 9, 10, 11, 12 | apt/dpkg |
|
||||
| [Ubuntu](ubuntu.md) | All versions supported by Canonical | apt/dpkg |
|
||||
| [OSs with installed Conda](conda.md) | - | conda |
|
||||
|
||||
## Supported container images
|
||||
|
||||
|
||||
213
docs/docs/plugin/developer-guide.md
Normal file
213
docs/docs/plugin/developer-guide.md
Normal file
@@ -0,0 +1,213 @@
|
||||
# Developer Guide
|
||||
|
||||
## Developing Trivy plugins
|
||||
This section will guide you through the process of developing Trivy plugins.
|
||||
To help you get started quickly, we have published a [plugin template repository][plugin-template].
|
||||
You can use this template as a starting point for your plugin development.
|
||||
|
||||
### Introduction
|
||||
If you are looking to start developing plugins for Trivy, read [the user guide](./user-guide.md) first.
|
||||
|
||||
The development process involves the following steps:
|
||||
|
||||
- Create a repository for your plugin, named `trivy-plugin-<name>`.
|
||||
- Create an executable binary that can be invoked as `trivy <name>`.
|
||||
- Place the executable binary in a repository.
|
||||
- Create a `plugin.yaml` file that describes the plugin.
|
||||
- (Submit your plugin to the [Trivy plugin index][trivy-plugin-index].)
|
||||
|
||||
After you develop a plugin with a good name following the best practices and publish it, you can submit your plugin to the [Trivy plugin index][trivy-plugin-index].
|
||||
|
||||
### Naming
|
||||
This section describes guidelines for naming your plugins.
|
||||
|
||||
#### Use `trivy-plugin-` prefix
|
||||
The name of the plugin repository should be prefixed with `trivy-plugin-`.
|
||||
|
||||
#### Use lowercase and hyphens
|
||||
Plugin names must be all lowercase and separate words with hyphens.
|
||||
Don’t use camelCase, PascalCase, or snake_case; use kebab-case.
|
||||
|
||||
- NO: `trivy OpenSvc`
|
||||
- YES: `trivy open-svc`
|
||||
|
||||
#### Be specific
|
||||
Plugin names should not be verbs or nouns that are generic, already overloaded, or likely to be used for broader purposes by another plugin.
|
||||
|
||||
- NO: trivy sast (Too broad)
|
||||
- YES: trivy govulncheck
|
||||
|
||||
|
||||
#### Be unique
|
||||
Find a unique name for your plugin that differentiates it from other plugins that perform a similar function.
|
||||
|
||||
- NO: `trivy images` (Unclear how it is different from the builtin “image" command)
|
||||
- YES: `trivy registry-images` (Unique name).
|
||||
|
||||
#### Prefix Vendor Identifiers
|
||||
Use vendor-specific strings as prefix, separated with a dash.
|
||||
This makes it easier to search/group plugins that are about a specific vendor.
|
||||
|
||||
- NO: `trivy security-hub-aws (Makes it harder to search or locate in a plugin list)
|
||||
- YES: `trivy aws-security-hub (Will show up together with other aws-* plugins)
|
||||
|
||||
### Choosing a language
|
||||
Since Trivy plugins are standalone executables, you can write them in any programming language.
|
||||
|
||||
If you are planning to write a plugin with Go, check out [the Report struct](https://github.com/aquasecurity/trivy/blob/787b466e069e2d04e73b3eddbda621e5eec8543b/pkg/types/report.go#L13-L24),
|
||||
which is the output of Trivy scan.
|
||||
|
||||
|
||||
### Writing your plugin
|
||||
Each plugin has a top-level directory, and then a `plugin.yaml` file.
|
||||
|
||||
```bash
|
||||
your-plugin/
|
||||
|
|
||||
|- plugin.yaml
|
||||
|- your-plugin.sh
|
||||
```
|
||||
|
||||
In the example above, the plugin is contained inside a directory named `your-plugin`.
|
||||
It has two files: `plugin.yaml` (required) and an executable script, `your-plugin.sh` (optional).
|
||||
|
||||
#### Writing a plugin manifest
|
||||
The plugin manifest is a simple YAML file named `plugin.yaml`.
|
||||
Here is an example YAML of [trivy-plugin-kubectl][trivy-plugin-kubectl] plugin that adds support for Kubernetes scanning.
|
||||
|
||||
```yaml
|
||||
name: "kubectl"
|
||||
version: "0.1.0"
|
||||
repository: github.com/aquasecurity/trivy-plugin-kubectl
|
||||
maintainer: aquasecurity
|
||||
output: false
|
||||
summary: Scan kubectl resources
|
||||
description: |-
|
||||
A Trivy plugin that scans the images of a kubernetes resource.
|
||||
Usage: trivy kubectl TYPE[.VERSION][.GROUP] NAME
|
||||
platforms:
|
||||
- selector: # optional
|
||||
os: darwin
|
||||
arch: amd64
|
||||
uri: ./trivy-kubectl # where the execution file is (local file, http, git, etc.)
|
||||
bin: ./trivy-kubectl # path to the execution file
|
||||
- selector: # optional
|
||||
os: linux
|
||||
arch: amd64
|
||||
uri: https://github.com/aquasecurity/trivy-plugin-kubectl/releases/download/v0.1.0/trivy-kubectl.tar.gz
|
||||
bin: ./trivy-kubectl
|
||||
```
|
||||
|
||||
We encourage you to copy and adapt plugin manifests of existing plugins.
|
||||
|
||||
- [count][trivy-plugin-count]
|
||||
- [referrer][trivy-plugin-referrer]
|
||||
|
||||
The `plugin.yaml` field should contain the following information:
|
||||
|
||||
- name: The name of the plugin. This also determines how the plugin will be made available in the Trivy CLI. For example, if the plugin is named kubectl, you can call the plugin with `trivy kubectl`. (required)
|
||||
- version: The version of the plugin. [Semantic Versioning][semver] should be used. (required)
|
||||
- repository: The repository name where the plugin is hosted. (required)
|
||||
- maintainer: The name of the maintainer of the plugin. (required)
|
||||
- output: Whether the plugin supports [the output mode](./user-guide.md#output-mode-support). (optional)
|
||||
- usage: Deprecated: use summary instead. (optional)
|
||||
- summary: A short usage description. (required)
|
||||
- description: A long description of the plugin. This is where you could provide a helpful documentation of your plugin. (required)
|
||||
- platforms: (required)
|
||||
- selector: The OS/Architecture specific variations of a execution file. (optional)
|
||||
- os: OS information based on GOOS (linux, darwin, etc.) (optional)
|
||||
- arch: The architecture information based on GOARCH (amd64, arm64, etc.) (optional)
|
||||
- uri: Where the executable file is. Relative path from the root directory of the plugin or remote URL such as HTTP and S3. (required)
|
||||
- bin: Which file to call when the plugin is executed. Relative path from the root directory of the plugin. (required)
|
||||
|
||||
The following rules will apply in deciding which platform to select:
|
||||
|
||||
- If both `os` and `arch` under `selector` match the current platform, search will stop and the platform will be used.
|
||||
- If `selector` is not present, the platform will be used.
|
||||
- If `os` matches and there is no more specific `arch` match, the platform will be used.
|
||||
- If no `platform` match is found, Trivy will exit with an error.
|
||||
|
||||
After determining platform, Trivy will download the execution file from `uri` and store it in the plugin cache.
|
||||
When the plugin is called via Trivy CLI, `bin` command will be executed.
|
||||
|
||||
#### Tagging plugin repositories
|
||||
If you are hosting your plugin in a Git repository, it is strongly recommended to tag your releases with a version number.
|
||||
By tagging your releases, Trivy can install specific versions of your plugin.
|
||||
|
||||
```bash
|
||||
$ trivy plugin install referrer@v0.3.0
|
||||
```
|
||||
|
||||
When tagging versions, you must follow [the Semantic Versioning][semver] and prefix the tag with `v`, like `v1.2.3`.
|
||||
|
||||
#### Plugin arguments/flags
|
||||
The plugin is responsible for handling flags and arguments.
|
||||
Any arguments are passed to the plugin from the `trivy` command.
|
||||
|
||||
#### Testing plugin installation locally
|
||||
A plugin should be archived `*.tar.gz`.
|
||||
After you have archived your plugin into a `.tar.gz` file, you can verify that your plugin installs correctly with Trivy.
|
||||
|
||||
```bash
|
||||
$ tar -czvf myplugin.tar.gz plugin.yaml script.py
|
||||
plugin.yaml
|
||||
script.py
|
||||
|
||||
$ trivy plugin install myplugin.tar.gz
|
||||
2023-03-03T19:04:42.026+0600 INFO Installing the plugin from myplugin.tar.gz...
|
||||
2023-03-03T19:04:42.026+0600 INFO Loading the plugin metadata...
|
||||
|
||||
$ trivy myplugin
|
||||
Hello from Trivy demo plugin!
|
||||
```
|
||||
|
||||
## Publishing plugins
|
||||
The [plugin.yaml](#writing-a-plugin-manifest) file is the core of your plugin, so as long as it is published somewhere, your plugin can be installed.
|
||||
If you choose to publish your plugin on GitHub, you can make it installable by placing the plugin.yaml file in the root directory of your repository.
|
||||
Users can then install your plugin with the command, `trivy plugin install github.com/org/repo`.
|
||||
|
||||
While the `uri` specified in the plugin.yaml file doesn't necessarily need to point to the same repository, it's a good practice to host the executable file within the same repository when using GitHub.
|
||||
You can utilize GitHub Releases to distribute the executable file.
|
||||
For an example of how to structure your plugin repository, refer to [the plugin template repository][plugin-template].
|
||||
|
||||
## Distributing plugins via the Trivy plugin index
|
||||
Trivy can install plugins directly by specifying a repository, like `trivy plugin install github.com/aquasecurity/trivy-plugin-referrer`,
|
||||
so you don't necessarily need to register your plugin in the Trivy plugin index.
|
||||
However, we would recommend distributing your plugin via the Trivy plugin index
|
||||
since it makes it easier for other users to find (`trivy plugin search`) and install your plugin (e.g. `trivy plugin install kubectl`).
|
||||
|
||||
### Pre-submit checklist
|
||||
- Review [the plugin naming guide](#naming).
|
||||
- Ensure the `plugin.yaml` file has all the required fields.
|
||||
- Tag a git release with a semantic version (e.g. v1.0.0).
|
||||
- [Test your plugin installation locally](#testing-plugin-installation-locally).
|
||||
|
||||
### Submitting plugins
|
||||
Submitting your plugin to the plugin index is a straightforward process.
|
||||
All you need to do is create a YAML file for your plugin and place it in the [plugins/](https://github.com/aquasecurity/trivy-plugin-index/tree/main/plugins) directory of [the index repository][trivy-plugin-index].
|
||||
|
||||
Once you've done that, create a pull request (PR) and have it reviewed by the maintainers.
|
||||
Once your PR is merged, the index will be updated, and your plugin will be available for installation.
|
||||
[The plugin index page][plugin-list] will also be automatically updated to list your newly added plugin.
|
||||
|
||||
The content of the YAML file is very simple.
|
||||
You only need to specify the name of your plugin and the repository where it is distributed.
|
||||
|
||||
```yaml
|
||||
name: referrer
|
||||
repository: github.com/aquasecurity/trivy-plugin-referrer
|
||||
```
|
||||
|
||||
After your PR is merged, the CI system will automatically retrieve the `plugin.yaml` file from your repository and update [the index.yaml file][index].
|
||||
If any required fields are missing from your `plugin.yaml`, the CI will fail, so make sure your `plugin.yaml` has all the required fields before creating a PR.
|
||||
Once [the index.yaml][index] has been updated, running `trivy plugin update` will download the updated index to your local machine.
|
||||
|
||||
|
||||
[plugin-template]: https://github.com/aquasecurity/trivy-plugin-template
|
||||
[plugin-list]: https://aquasecurity.github.io/trivy-plugin-index/
|
||||
[index]: https://aquasecurity.github.io/trivy-plugin-index/v1/index.yaml
|
||||
[semver]: https://semver.org/
|
||||
[trivy-plugin-index]: https://github.com/aquasecurity/trivy-plugin-index
|
||||
[trivy-plugin-kubectl]: https://github.com/aquasecurity/trivy-plugin-kubectl
|
||||
[trivy-plugin-count]: https://github.com/aquasecurity/trivy-plugin-count/blob/main/plugin.yaml
|
||||
[trivy-plugin-referrer]: https://github.com/aquasecurity/trivy-plugin-referrer/blob/main/plugin.yaml
|
||||
70
docs/docs/plugin/index.md
Normal file
70
docs/docs/plugin/index.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# Plugins
|
||||
Trivy provides a plugin feature to allow others to extend the Trivy CLI without the need to change the Trivy code base.
|
||||
This plugin system was inspired by the plugin system used in [kubectl][kubectl], [Helm][helm], and [Conftest][conftest].
|
||||
|
||||
## Overview
|
||||
Trivy plugins are add-on tools that integrate seamlessly with Trivy.
|
||||
They provide a way to extend the core feature set of Trivy, but without requiring every new feature to be written in Go and added to the core tool.
|
||||
|
||||
- They can be added and removed from a Trivy installation without impacting the core Trivy tool.
|
||||
- They can be written in any programming language.
|
||||
- They integrate with Trivy, and will show up in Trivy help and subcommands.
|
||||
|
||||
!!! warning
|
||||
Trivy plugins available in public are not audited for security.
|
||||
You should install and run third-party plugins at your own risk, since they are arbitrary programs running on your machine.
|
||||
|
||||
## Quickstart
|
||||
Trivy helps you discover and install plugins on your machine.
|
||||
|
||||
You can install and use a wide variety of Trivy plugins to enhance your experience.
|
||||
|
||||
Let’s get started:
|
||||
|
||||
1. Download the plugin list:
|
||||
|
||||
```bash
|
||||
$ trivy plugin update
|
||||
```
|
||||
|
||||
2. Discover Trivy plugins available on the plugin index:
|
||||
|
||||
```bash
|
||||
$ trivy plugin search
|
||||
NAME DESCRIPTION MAINTAINER OUTPUT
|
||||
aqua A plugin for integration with Aqua Security SaaS platform aquasecurity
|
||||
kubectl A plugin scanning the images of a kubernetes resource aquasecurity
|
||||
referrer A plugin for OCI referrers aquasecurity ✓
|
||||
[...]
|
||||
```
|
||||
|
||||
3. Choose a plugin from the list and install it:
|
||||
|
||||
```bash
|
||||
$ trivy plugin install referrer
|
||||
```
|
||||
|
||||
4. Use the installed plugin:
|
||||
|
||||
```bash
|
||||
$ trivy referrer --help
|
||||
```
|
||||
|
||||
5. Keep your plugins up-to-date:
|
||||
|
||||
```bash
|
||||
$ trivy plugin upgrade
|
||||
```
|
||||
|
||||
6. Uninstall a plugin you no longer use:
|
||||
|
||||
```bash
|
||||
trivy plugin uninstall referrer
|
||||
```
|
||||
|
||||
This is practically all you need to know to start using Trivy plugins.
|
||||
|
||||
|
||||
[kubectl]: https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/
|
||||
[helm]: https://helm.sh/docs/topics/plugins/
|
||||
[conftest]: https://www.conftest.dev/plugins/
|
||||
218
docs/docs/plugin/user-guide.md
Normal file
218
docs/docs/plugin/user-guide.md
Normal file
@@ -0,0 +1,218 @@
|
||||
# User Guide
|
||||
|
||||
## Discovering Plugins
|
||||
You can find a list of Trivy plugins distributed via trivy-plugin-index [here][trivy-plugin-index].
|
||||
However, you can find plugins using the command line as well.
|
||||
|
||||
First, refresh your local copy of the plugin index:
|
||||
|
||||
```bash
|
||||
$ trivy plugin update
|
||||
```
|
||||
|
||||
To list all plugins available, run:
|
||||
|
||||
```bash
|
||||
$ trivy plugin search
|
||||
NAME DESCRIPTION MAINTAINER OUTPUT
|
||||
aqua A plugin for integration with Aqua Security SaaS platform aquasecurity
|
||||
kubectl A plugin scanning the images of a kubernetes resource aquasecurity
|
||||
referrer A plugin for OCI referrers aquasecurity ✓
|
||||
```
|
||||
|
||||
You can specify search keywords as arguments:
|
||||
|
||||
```bash
|
||||
$ trivy plugin search referrer
|
||||
|
||||
NAME DESCRIPTION MAINTAINER OUTPUT
|
||||
referrer A plugin for OCI referrers aquasecurity ✓
|
||||
```
|
||||
|
||||
It lists plugins with the keyword in the name or description.
|
||||
|
||||
## Installing Plugins
|
||||
Plugins can be installed with the `trivy plugin install` command:
|
||||
|
||||
```bash
|
||||
$ trivy plugin install referrer
|
||||
```
|
||||
|
||||
This command will download the plugin and install it in the plugin cache.
|
||||
|
||||
|
||||
|
||||
Trivy adheres to the XDG specification, so the location depends on whether XDG_DATA_HOME is set.
|
||||
Trivy will now search XDG_DATA_HOME for the location of the Trivy plugins cache.
|
||||
The preference order is as follows:
|
||||
|
||||
- XDG_DATA_HOME if set and .trivy/plugins exists within the XDG_DATA_HOME dir
|
||||
- ~/.trivy/plugins
|
||||
|
||||
Furthermore, it is possible to download plugins that are not registered in the index by specifying the URL directly or by specifying the file path.
|
||||
|
||||
```bash
|
||||
$ trivy plugin install github.com/aquasecurity/trivy-plugin-kubectl
|
||||
```
|
||||
```bash
|
||||
$ trivy plugin install myplugin.tar.gz
|
||||
```
|
||||
|
||||
If the plugin's Git repository is [properly tagged](./developer-guide.md#tagging-plugin-repositories), you can specify the version to install like this:
|
||||
|
||||
```bash
|
||||
$ trivy plugin install referrer@v0.3.0
|
||||
```
|
||||
|
||||
!!! note
|
||||
The leading `v` in the version is required. Also, the version must follow the [Semantic Versioning](https://semver.org/).
|
||||
|
||||
Under the hood Trivy leverages [go-getter][go-getter] to download plugins.
|
||||
This means the following protocols are supported for downloading plugins:
|
||||
|
||||
- OCI Registries
|
||||
- Local Files
|
||||
- Git
|
||||
- HTTP/HTTPS
|
||||
- Mercurial
|
||||
- Amazon S3
|
||||
- Google Cloud Storage
|
||||
|
||||
## Listing Installed Plugins
|
||||
To list all plugins installed, run:
|
||||
|
||||
```bash
|
||||
$ trivy plugin list
|
||||
```
|
||||
|
||||
## Using Plugins
|
||||
Once the plugin is installed, Trivy will load all available plugins in the cache on the start of the next Trivy execution.
|
||||
A plugin will be made in the Trivy CLI based on the plugin name.
|
||||
To display all plugins, you can list them by `trivy --help`
|
||||
|
||||
```bash
|
||||
$ trivy --help
|
||||
NAME:
|
||||
trivy - A simple and comprehensive vulnerability scanner for containers
|
||||
|
||||
USAGE:
|
||||
trivy [global options] command [command options] target
|
||||
|
||||
VERSION:
|
||||
dev
|
||||
|
||||
Scanning Commands
|
||||
aws [EXPERIMENTAL] Scan AWS account
|
||||
config Scan config files for misconfigurations
|
||||
filesystem Scan local filesystem
|
||||
image Scan a container image
|
||||
|
||||
...
|
||||
|
||||
Plugin Commands
|
||||
kubectl scan kubectl resources
|
||||
referrer Put referrers to OCI registry
|
||||
```
|
||||
|
||||
As shown above, `kubectl` subcommand exists in the `Plugin Commands` section.
|
||||
To call the kubectl plugin and scan existing Kubernetes deployments, you can execute the following command:
|
||||
|
||||
```
|
||||
$ trivy kubectl deployment <deployment-id> -- --ignore-unfixed --severity CRITICAL
|
||||
```
|
||||
|
||||
Internally the kubectl plugin calls the kubectl binary to fetch information about that deployment and passes the using images to Trivy.
|
||||
You can see the detail [here][trivy-plugin-kubectl].
|
||||
|
||||
If you want to omit even the subcommand, you can use `TRIVY_RUN_AS_PLUGIN` environment variable.
|
||||
|
||||
```bash
|
||||
$ TRIVY_RUN_AS_PLUGIN=kubectl trivy job your-job -- --format json
|
||||
```
|
||||
|
||||
## Installing and Running Plugins on the fly
|
||||
`trivy plugin run` installs a plugin and runs it on the fly.
|
||||
If the plugin is already present in the cache, the installation is skipped.
|
||||
|
||||
```bash
|
||||
trivy plugin run kubectl pod your-pod -- --exit-code 1
|
||||
```
|
||||
|
||||
## Upgrading Plugins
|
||||
To upgrade all plugins that you have installed to their latest versions, run:
|
||||
|
||||
```bash
|
||||
$ trivy plugin upgrade
|
||||
```
|
||||
|
||||
To upgrade only certain plugins, you can explicitly specify their names:
|
||||
|
||||
```bash
|
||||
$ trivy plugin upgrade <PLUGIN1> <PLUGIN2>
|
||||
```
|
||||
|
||||
## Uninstalling Plugins
|
||||
Specify a plugin name with `trivy plugin uninstall` command.
|
||||
|
||||
```bash
|
||||
$ trivy plugin uninstall kubectl
|
||||
```
|
||||
|
||||
Here's the revised English documentation based on your requested changes:
|
||||
|
||||
## Output Mode Support
|
||||
While plugins are typically intended to be used as subcommands of Trivy, plugins supporting the output mode can be invoked as part of Trivy's built-in commands.
|
||||
|
||||
!!! warning "EXPERIMENTAL"
|
||||
This feature might change without preserving backwards compatibility.
|
||||
|
||||
Trivy supports plugins that are compatible with the output mode, which process Trivy's output, such as by transforming the output format or sending it elsewhere.
|
||||
You can determine whether a plugin supports the output mode by checking the `OUTPUT` column in the output of `trivy plugin search` or `trivy plugin list`.
|
||||
|
||||
```bash
|
||||
$ trivy plugin search
|
||||
NAME DESCRIPTION MAINTAINER OUTPUT
|
||||
aqua A plugin for integration with Aqua Security SaaS platform aquasecurity
|
||||
kubectl A plugin scanning the images of a kubernetes resource aquasecurity
|
||||
referrer A plugin for OCI referrers aquasecurity ✓
|
||||
```
|
||||
|
||||
In this case, the `referrer` plugin supports the output mode.
|
||||
|
||||
For instance, in the case of image scanning, a plugin supporting the output mode can be called as follows:
|
||||
|
||||
```bash
|
||||
$ trivy image --format json --output plugin=<plugin_name> [--output-plugin-arg <plugin_flags>] <image_name>
|
||||
```
|
||||
|
||||
Since scan results are passed to the plugin via standard input, plugins must be capable of handling standard input.
|
||||
|
||||
!!! warning
|
||||
To avoid Trivy hanging, you need to read all data from `Stdin` before the plugin exits successfully or stops with an error.
|
||||
|
||||
While the example passes JSON to the plugin, other formats like SBOM can also be passed (e.g., `--format cyclonedx`).
|
||||
|
||||
If a plugin requires flags or other arguments, they can be passed using `--output-plugin-arg`.
|
||||
This is directly forwarded as arguments to the plugin.
|
||||
For example, `--output plugin=myplugin --output-plugin-arg "--foo --bar=baz"` translates to `myplugin --foo --bar=baz` in execution.
|
||||
|
||||
An example of a plugin supporting the output mode is available [here][trivy-plugin-count].
|
||||
It can be used as below:
|
||||
|
||||
```bash
|
||||
# Install the plugin first
|
||||
$ trivy plugin install count
|
||||
|
||||
# Call the plugin supporting the output mode in image scanning
|
||||
$ trivy image --format json --output plugin=count --output-plugin-arg "--published-after 2023-10-01" debian:12
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
- [kubectl][trivy-plugin-kubectl]
|
||||
- [count][trivy-plugin-count]
|
||||
|
||||
[trivy-plugin-index]: https://aquasecurity.github.io/trivy-plugin-index/
|
||||
[go-getter]: https://github.com/hashicorp/go-getter
|
||||
[trivy-plugin-kubectl]: https://github.com/aquasecurity/trivy-plugin-kubectl
|
||||
[trivy-plugin-count]: https://github.com/aquasecurity/trivy-plugin-count
|
||||
@@ -53,7 +53,7 @@ trivy [global flags] command [flags] target
|
||||
* [trivy plugin](trivy_plugin.md) - Manage plugins
|
||||
* [trivy repository](trivy_repository.md) - Scan a repository
|
||||
* [trivy rootfs](trivy_rootfs.md) - Scan rootfs
|
||||
* [trivy sbom](trivy_sbom.md) - Scan SBOM for vulnerabilities
|
||||
* [trivy sbom](trivy_sbom.md) - Scan SBOM for vulnerabilities and licenses
|
||||
* [trivy server](trivy_server.md) - Server mode
|
||||
* [trivy version](trivy_version.md) - Print the version
|
||||
* [trivy vm](trivy_vm.md) - [EXPERIMENTAL] Scan a virtual machine image
|
||||
|
||||
@@ -69,13 +69,17 @@ trivy aws [flags]
|
||||
--account string The AWS account to scan. It's useful to specify this when reviewing cached results for multiple accounts.
|
||||
--arn string The AWS ARN to show results for. Useful to filter results once a scan is cached.
|
||||
--cf-params strings specify paths to override the CloudFormation parameters files
|
||||
--check-namespaces strings Rego namespaces
|
||||
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "ghcr.io/aquasecurity/trivy-checks:0")
|
||||
--compliance string compliance report to generate (aws-cis-1.2,aws-cis-1.4)
|
||||
--config-data strings specify paths from which data for the Rego policies will be recursively loaded
|
||||
--config-policy strings specify the paths to the Rego policy files or to the directories containing them, applying config files
|
||||
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
|
||||
--config-data strings specify paths from which data for the Rego checks will be recursively loaded
|
||||
--dependency-tree [EXPERIMENTAL] show dependency origin tree of vulnerable packages
|
||||
--endpoint string AWS Endpoint override
|
||||
--exit-code int specify exit code when any security issues are found
|
||||
-f, --format string format (table,json,template,sarif,cyclonedx,spdx,spdx-json,github,cosign-vuln) (default "table")
|
||||
--helm-api-versions strings Available API versions used for Capabilities.APIVersions. This flag is the same as the api-versions flag of the helm template command. (can specify multiple or separate values with commas: policy/v1/PodDisruptionBudget,apps/v1/Deployment)
|
||||
--helm-kube-version string Kubernetes version used for Capabilities.KubeVersion. This flag is the same as the kube-version flag of the helm template command.
|
||||
--helm-set strings specify Helm values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
|
||||
--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)
|
||||
@@ -83,20 +87,19 @@ trivy aws [flags]
|
||||
-h, --help help for aws
|
||||
--ignore-policy string specify the Rego file path to evaluate each vulnerability
|
||||
--ignorefile string specify .trivyignore file (default ".trivyignore")
|
||||
--include-deprecated-checks include deprecated checks
|
||||
--include-non-failures include successes and exceptions, available with '--scanners misconfig'
|
||||
--list-all-pkgs enabling the option will output all packages regardless of vulnerability
|
||||
--max-cache-age duration The maximum age of the cloud cache. Cached data will be requeried from the cloud provider if it is older than this. (default 24h0m0s)
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan])
|
||||
--list-all-pkgs output all packages in the JSON report regardless of vulnerability
|
||||
--max-cache-age duration The maximum age of the cloud cache. Cached data will be required from the cloud provider if it is older than this. (default 24h0m0s)
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan-json,terraformplan-snapshot])
|
||||
-o, --output string output file name
|
||||
--output-plugin-arg string [EXPERIMENTAL] output plugin arguments
|
||||
--policy-bundle-repository string OCI registry URL to retrieve policy bundle from (default "ghcr.io/aquasecurity/trivy-policies:0")
|
||||
--policy-namespaces strings Rego namespaces
|
||||
--region string AWS Region to scan
|
||||
--report string specify a report format for the output (all,summary) (default "all")
|
||||
--reset-policy-bundle remove policy bundle
|
||||
--reset-checks-bundle remove checks bundle
|
||||
--service strings Only scan AWS Service(s) specified with this flag. Can specify multiple services using --service A --service B etc.
|
||||
-s, --severity strings severities of security issues to be displayed (UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL) (default [UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL])
|
||||
--skip-policy-update skip fetching rego policy updates
|
||||
--skip-check-update skip fetching rego check updates
|
||||
--skip-service strings Skip selected AWS Service(s) specified with this flag. Can specify multiple services using --skip-service A --skip-service B etc.
|
||||
-t, --template string output template
|
||||
--tf-exclude-downloaded-modules exclude misconfigurations for downloaded terraform modules
|
||||
|
||||
@@ -12,14 +12,18 @@ trivy config [flags] DIR
|
||||
--cache-backend string cache backend (e.g. redis://localhost:6379) (default "fs")
|
||||
--cache-ttl duration cache TTL when using redis as cache backend
|
||||
--cf-params strings specify paths to override the CloudFormation parameters files
|
||||
--check-namespaces strings Rego namespaces
|
||||
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "ghcr.io/aquasecurity/trivy-checks:0")
|
||||
--clear-cache clear image caches without scanning
|
||||
--compliance string compliance report to generate
|
||||
--config-data strings specify paths from which data for the Rego policies will be recursively loaded
|
||||
--config-policy strings specify the paths to the Rego policy files or to the directories containing them, applying config files
|
||||
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
|
||||
--config-data strings specify paths from which data for the Rego checks will be recursively loaded
|
||||
--enable-modules strings [EXPERIMENTAL] module names to enable
|
||||
--exit-code int specify exit code when any security issues are found
|
||||
--file-patterns strings specify config file patterns
|
||||
-f, --format string format (table,json,template,sarif,cyclonedx,spdx,spdx-json,github,cosign-vuln) (default "table")
|
||||
--helm-api-versions strings Available API versions used for Capabilities.APIVersions. This flag is the same as the api-versions flag of the helm template command. (can specify multiple or separate values with commas: policy/v1/PodDisruptionBudget,apps/v1/Deployment)
|
||||
--helm-kube-version string Kubernetes version used for Capabilities.KubeVersion. This flag is the same as the kube-version flag of the helm template command.
|
||||
--helm-set strings specify Helm values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
|
||||
--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)
|
||||
@@ -27,26 +31,25 @@ trivy config [flags] DIR
|
||||
-h, --help help for config
|
||||
--ignore-policy string specify the Rego file path to evaluate each vulnerability
|
||||
--ignorefile string specify .trivyignore file (default ".trivyignore")
|
||||
--include-deprecated-checks include deprecated checks
|
||||
--include-non-failures include successes and exceptions, available with '--scanners misconfig'
|
||||
--k8s-version string specify k8s version to validate outdated api by it (example: 1.21.0)
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan])
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan-json,terraformplan-snapshot])
|
||||
--module-dir string specify directory to the wasm modules that will be loaded (default "$HOME/.trivy/modules")
|
||||
-o, --output string output file name
|
||||
--output-plugin-arg string [EXPERIMENTAL] output plugin arguments
|
||||
--password strings password. Comma-separated passwords allowed. TRIVY_PASSWORD should be used for security reasons.
|
||||
--policy-bundle-repository string OCI registry URL to retrieve policy bundle from (default "ghcr.io/aquasecurity/trivy-policies:0")
|
||||
--policy-namespaces strings Rego namespaces
|
||||
--redis-ca string redis ca file location, if using redis as cache backend
|
||||
--redis-cert string redis certificate file location, if using redis as cache backend
|
||||
--redis-key string redis key file location, if using redis as cache backend
|
||||
--redis-tls enable redis TLS with public certificates, if using redis as cache backend
|
||||
--registry-token string registry token
|
||||
--report string specify a compliance report format for the output (all,summary) (default "all")
|
||||
--reset-policy-bundle remove policy bundle
|
||||
--reset-checks-bundle remove checks bundle
|
||||
-s, --severity strings severities of security issues to be displayed (UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL) (default [UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL])
|
||||
--skip-check-update skip fetching rego check updates
|
||||
--skip-dirs strings specify the directories or glob patterns to skip
|
||||
--skip-files strings specify the files or glob patterns to skip
|
||||
--skip-policy-update skip fetching rego policy updates
|
||||
-t, --template string output template
|
||||
--tf-exclude-downloaded-modules exclude misconfigurations for downloaded terraform modules
|
||||
--tf-vars strings specify paths to override the Terraform tfvars files
|
||||
|
||||
@@ -26,11 +26,12 @@ trivy convert [flags] RESULT_JSON
|
||||
-h, --help help for convert
|
||||
--ignore-policy string specify the Rego file path to evaluate each vulnerability
|
||||
--ignorefile string specify .trivyignore file (default ".trivyignore")
|
||||
--list-all-pkgs enabling the option will output all packages regardless of vulnerability
|
||||
--list-all-pkgs output all packages in the JSON report regardless of vulnerability
|
||||
-o, --output string output file name
|
||||
--output-plugin-arg string [EXPERIMENTAL] output plugin arguments
|
||||
--report string specify a report format for the output (all,summary) (default "all")
|
||||
-s, --severity strings severities of security issues to be displayed (UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL) (default [UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL])
|
||||
--show-suppressed [EXPERIMENTAL] show suppressed vulnerabilities
|
||||
-t, --template string output template
|
||||
```
|
||||
|
||||
|
||||
@@ -22,12 +22,14 @@ trivy filesystem [flags] PATH
|
||||
--cache-backend string cache backend (e.g. redis://localhost:6379) (default "fs")
|
||||
--cache-ttl duration cache TTL when using redis as cache backend
|
||||
--cf-params strings specify paths to override the CloudFormation parameters files
|
||||
--check-namespaces strings Rego namespaces
|
||||
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "ghcr.io/aquasecurity/trivy-checks:0")
|
||||
--clear-cache clear image caches without scanning
|
||||
--compliance string compliance report to generate
|
||||
--config-data strings specify paths from which data for the Rego policies will be recursively loaded
|
||||
--config-policy strings specify the paths to the Rego policy files or to the directories containing them, applying config files
|
||||
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
|
||||
--config-data strings specify paths from which data for the Rego checks will be recursively loaded
|
||||
--custom-headers strings custom headers in client mode
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db")
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db:2")
|
||||
--dependency-tree [EXPERIMENTAL] show dependency origin tree of vulnerable packages
|
||||
--download-db-only download/update vulnerability database but don't run a scan
|
||||
--download-java-db-only download/update Java index database but don't run a scan
|
||||
@@ -35,6 +37,8 @@ trivy filesystem [flags] PATH
|
||||
--exit-code int specify exit code when any security issues are found
|
||||
--file-patterns strings specify config file patterns
|
||||
-f, --format string format (table,json,template,sarif,cyclonedx,spdx,spdx-json,github,cosign-vuln) (default "table")
|
||||
--helm-api-versions strings Available API versions used for Capabilities.APIVersions. This flag is the same as the api-versions flag of the helm template command. (can specify multiple or separate values with commas: policy/v1/PodDisruptionBudget,apps/v1/Deployment)
|
||||
--helm-kube-version string Kubernetes version used for Capabilities.KubeVersion. This flag is the same as the kube-version flag of the helm template command.
|
||||
--helm-set strings specify Helm values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
|
||||
--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)
|
||||
@@ -45,13 +49,14 @@ trivy filesystem [flags] PATH
|
||||
--ignore-unfixed display only fixed vulnerabilities
|
||||
--ignored-licenses strings specify a list of license to ignore
|
||||
--ignorefile string specify .trivyignore file (default ".trivyignore")
|
||||
--include-deprecated-checks include deprecated checks
|
||||
--include-dev-deps include development dependencies in the report (supported: npm, yarn)
|
||||
--include-non-failures include successes and exceptions, available with '--scanners misconfig'
|
||||
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db")
|
||||
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db:1")
|
||||
--license-confidence-level float specify license classifier's confidence level (default 0.9)
|
||||
--license-full eagerly look for licenses in source code headers and license files
|
||||
--list-all-pkgs enabling the option will output all packages regardless of vulnerability
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan])
|
||||
--list-all-pkgs output all packages in the JSON report regardless of vulnerability
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan-json,terraformplan-snapshot])
|
||||
--module-dir string specify directory to the wasm modules that will be loaded (default "$HOME/.trivy/modules")
|
||||
--no-progress suppress progress bar
|
||||
--offline-scan do not issue API requests to identify dependencies
|
||||
@@ -59,8 +64,6 @@ trivy filesystem [flags] PATH
|
||||
--output-plugin-arg string [EXPERIMENTAL] output plugin arguments
|
||||
--parallel int number of goroutines enabled for parallel scanning, set 0 to auto-detect parallelism (default 5)
|
||||
--password strings password. Comma-separated passwords allowed. TRIVY_PASSWORD should be used for security reasons.
|
||||
--policy-bundle-repository string OCI registry URL to retrieve policy bundle from (default "ghcr.io/aquasecurity/trivy-policies:0")
|
||||
--policy-namespaces strings Rego namespaces
|
||||
--redis-ca string redis ca file location, if using redis as cache backend
|
||||
--redis-cert string redis certificate file location, if using redis as cache backend
|
||||
--redis-key string redis key file location, if using redis as cache backend
|
||||
@@ -69,17 +72,18 @@ trivy filesystem [flags] PATH
|
||||
--rekor-url string [EXPERIMENTAL] address of rekor STL server (default "https://rekor.sigstore.dev")
|
||||
--report string specify a compliance report format for the output (all,summary) (default "all")
|
||||
--reset remove all caches and database
|
||||
--reset-policy-bundle remove policy bundle
|
||||
--reset-checks-bundle remove checks bundle
|
||||
--sbom-sources strings [EXPERIMENTAL] try to retrieve SBOM from the specified sources (oci,rekor)
|
||||
--scanners strings comma-separated list of what security issues to detect (vuln,misconfig,secret,license) (default [vuln,secret])
|
||||
--secret-config string specify a path to config file for secret scanning (default "trivy-secret.yaml")
|
||||
--server string server address in client mode
|
||||
-s, --severity strings severities of security issues to be displayed (UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL) (default [UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL])
|
||||
--show-suppressed [EXPERIMENTAL] show suppressed vulnerabilities
|
||||
--skip-check-update skip fetching rego check updates
|
||||
--skip-db-update skip updating vulnerability database
|
||||
--skip-dirs strings specify the directories or glob patterns to skip
|
||||
--skip-files strings specify the files or glob patterns to skip
|
||||
--skip-java-db-update skip updating Java index database
|
||||
--skip-policy-update skip fetching rego policy updates
|
||||
-t, --template string output template
|
||||
--tf-exclude-downloaded-modules exclude misconfigurations for downloaded terraform modules
|
||||
--tf-vars strings specify paths to override the Terraform tfvars files
|
||||
|
||||
@@ -36,12 +36,14 @@ trivy image [flags] IMAGE_NAME
|
||||
```
|
||||
--cache-backend string cache backend (e.g. redis://localhost:6379) (default "fs")
|
||||
--cache-ttl duration cache TTL when using redis as cache backend
|
||||
--check-namespaces strings Rego namespaces
|
||||
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "ghcr.io/aquasecurity/trivy-checks:0")
|
||||
--clear-cache clear image caches without scanning
|
||||
--compliance string compliance report to generate (docker-cis)
|
||||
--config-data strings specify paths from which data for the Rego policies will be recursively loaded
|
||||
--config-policy strings specify the paths to the Rego policy files or to the directories containing them, applying config files
|
||||
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
|
||||
--config-data strings specify paths from which data for the Rego checks will be recursively loaded
|
||||
--custom-headers strings custom headers in client mode
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db")
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db:2")
|
||||
--dependency-tree [EXPERIMENTAL] show dependency origin tree of vulnerable packages
|
||||
--docker-host string unix domain socket path to use for docker scanning
|
||||
--download-db-only download/update vulnerability database but don't run a scan
|
||||
@@ -51,6 +53,8 @@ trivy image [flags] IMAGE_NAME
|
||||
--exit-on-eol int exit with the specified code when the OS reaches end of service/life
|
||||
--file-patterns strings specify config file patterns
|
||||
-f, --format string format (table,json,template,sarif,cyclonedx,spdx,spdx-json,github,cosign-vuln) (default "table")
|
||||
--helm-api-versions strings Available API versions used for Capabilities.APIVersions. This flag is the same as the api-versions flag of the helm template command. (can specify multiple or separate values with commas: policy/v1/PodDisruptionBudget,apps/v1/Deployment)
|
||||
--helm-kube-version string Kubernetes version used for Capabilities.KubeVersion. This flag is the same as the kube-version flag of the helm template command.
|
||||
--helm-set strings specify Helm values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
|
||||
--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)
|
||||
@@ -63,13 +67,14 @@ trivy image [flags] IMAGE_NAME
|
||||
--ignorefile string specify .trivyignore file (default ".trivyignore")
|
||||
--image-config-scanners strings comma-separated list of what security issues to detect on container image configurations (misconfig,secret)
|
||||
--image-src strings image source(s) to use, in priority order (docker,containerd,podman,remote) (default [docker,containerd,podman,remote])
|
||||
--include-deprecated-checks include deprecated checks
|
||||
--include-non-failures include successes and exceptions, available with '--scanners misconfig'
|
||||
--input string input file path instead of image name
|
||||
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db")
|
||||
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db:1")
|
||||
--license-confidence-level float specify license classifier's confidence level (default 0.9)
|
||||
--license-full eagerly look for licenses in source code headers and license files
|
||||
--list-all-pkgs enabling the option will output all packages regardless of vulnerability
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan])
|
||||
--list-all-pkgs output all packages in the JSON report regardless of vulnerability
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan-json,terraformplan-snapshot])
|
||||
--module-dir string specify directory to the wasm modules that will be loaded (default "$HOME/.trivy/modules")
|
||||
--no-progress suppress progress bar
|
||||
--offline-scan do not issue API requests to identify dependencies
|
||||
@@ -78,8 +83,7 @@ trivy image [flags] IMAGE_NAME
|
||||
--parallel int number of goroutines enabled for parallel scanning, set 0 to auto-detect parallelism (default 5)
|
||||
--password strings password. Comma-separated passwords allowed. TRIVY_PASSWORD should be used for security reasons.
|
||||
--platform string set platform in the form os/arch if image is multi-platform capable
|
||||
--policy-bundle-repository string OCI registry URL to retrieve policy bundle from (default "ghcr.io/aquasecurity/trivy-policies:0")
|
||||
--policy-namespaces strings Rego namespaces
|
||||
--podman-host string unix podman socket path to use for podman scanning
|
||||
--redis-ca string redis ca file location, if using redis as cache backend
|
||||
--redis-cert string redis certificate file location, if using redis as cache backend
|
||||
--redis-key string redis key file location, if using redis as cache backend
|
||||
@@ -89,17 +93,18 @@ trivy image [flags] IMAGE_NAME
|
||||
--removed-pkgs detect vulnerabilities of removed packages (only for Alpine)
|
||||
--report string specify a format for the compliance report. (all,summary) (default "summary")
|
||||
--reset remove all caches and database
|
||||
--reset-policy-bundle remove policy bundle
|
||||
--reset-checks-bundle remove checks bundle
|
||||
--sbom-sources strings [EXPERIMENTAL] try to retrieve SBOM from the specified sources (oci,rekor)
|
||||
--scanners strings comma-separated list of what security issues to detect (vuln,misconfig,secret,license) (default [vuln,secret])
|
||||
--secret-config string specify a path to config file for secret scanning (default "trivy-secret.yaml")
|
||||
--server string server address in client mode
|
||||
-s, --severity strings severities of security issues to be displayed (UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL) (default [UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL])
|
||||
--show-suppressed [EXPERIMENTAL] show suppressed vulnerabilities
|
||||
--skip-check-update skip fetching rego check updates
|
||||
--skip-db-update skip updating vulnerability database
|
||||
--skip-dirs strings specify the directories or glob patterns to skip
|
||||
--skip-files strings specify the files or glob patterns to skip
|
||||
--skip-java-db-update skip updating Java index database
|
||||
--skip-policy-update skip fetching rego policy updates
|
||||
-t, --template string output template
|
||||
--tf-exclude-downloaded-modules exclude misconfigurations for downloaded terraform modules
|
||||
--token string for authentication in client/server mode
|
||||
|
||||
@@ -2,50 +2,56 @@
|
||||
|
||||
[EXPERIMENTAL] Scan kubernetes cluster
|
||||
|
||||
### Synopsis
|
||||
|
||||
Default context in kube configuration will be used unless specified
|
||||
|
||||
```
|
||||
trivy kubernetes [flags] { cluster | all | specific resources like kubectl. eg: pods, pod/NAME }
|
||||
trivy kubernetes [flags] [CONTEXT]
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
```
|
||||
# cluster scanning
|
||||
$ trivy k8s --report summary cluster
|
||||
$ trivy k8s --report summary
|
||||
|
||||
# namespace scanning:
|
||||
$ trivy k8s -n kube-system --report summary all
|
||||
# cluster scanning with specific namespace:
|
||||
$ trivy k8s --include-namespaces kube-system --report summary
|
||||
|
||||
# resources scanning:
|
||||
$ trivy k8s --report=summary deploy
|
||||
$ trivy k8s --namespace=kube-system --report=summary deploy,configmaps
|
||||
|
||||
# resource scanning:
|
||||
$ trivy k8s deployment/orion
|
||||
# cluster with specific context:
|
||||
$ trivy k8s kind-kind --report summary
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-A, --all-namespaces fetch resources from all cluster namespaces
|
||||
--burst int specify the maximum burst for throttle (default 10)
|
||||
--cache-backend string cache backend (e.g. redis://localhost:6379) (default "fs")
|
||||
--cache-ttl duration cache TTL when using redis as cache backend
|
||||
--check-namespaces strings Rego namespaces
|
||||
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "ghcr.io/aquasecurity/trivy-checks:0")
|
||||
--clear-cache clear image caches without scanning
|
||||
--compliance string compliance report to generate (k8s-nsa,k8s-cis,k8s-pss-baseline,k8s-pss-restricted)
|
||||
--components strings specify which components to scan (workload,infra) (default [workload,infra])
|
||||
--config-data strings specify paths from which data for the Rego policies will be recursively loaded
|
||||
--config-policy strings specify the paths to the Rego policy files or to the directories containing them, applying config files
|
||||
--context string specify a context to scan
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db")
|
||||
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
|
||||
--config-data strings specify paths from which data for the Rego checks will be recursively loaded
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db:2")
|
||||
--dependency-tree [EXPERIMENTAL] show dependency origin tree of vulnerable packages
|
||||
--disable-node-collector When the flag is activated, the node-collector job will not be executed, thus skipping misconfiguration findings on the node.
|
||||
--download-db-only download/update vulnerability database but don't run a scan
|
||||
--download-java-db-only download/update Java index database but don't run a scan
|
||||
--exclude-kinds strings indicate the kinds exclude from scanning (example: node)
|
||||
--exclude-namespaces strings indicate the namespaces excluded from scanning (example: kube-system)
|
||||
--exclude-nodes strings indicate the node labels that the node-collector job should exclude from scanning (example: kubernetes.io/arch:arm64,team:dev)
|
||||
--exclude-owned exclude resources that have an owner reference
|
||||
--exit-code int specify exit code when any security issues are found
|
||||
--file-patterns strings specify config file patterns
|
||||
-f, --format string format (table,json,cyclonedx) (default "table")
|
||||
--helm-api-versions strings Available API versions used for Capabilities.APIVersions. This flag is the same as the api-versions flag of the helm template command. (can specify multiple or separate values with commas: policy/v1/PodDisruptionBudget,apps/v1/Deployment)
|
||||
--helm-kube-version string Kubernetes version used for Capabilities.KubeVersion. This flag is the same as the kube-version flag of the helm template command.
|
||||
--helm-set strings specify Helm values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
|
||||
--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)
|
||||
@@ -56,23 +62,23 @@ trivy kubernetes [flags] { cluster | all | specific resources like kubectl. eg:
|
||||
--ignore-unfixed display only fixed vulnerabilities
|
||||
--ignorefile string specify .trivyignore file (default ".trivyignore")
|
||||
--image-src strings image source(s) to use, in priority order (docker,containerd,podman,remote) (default [docker,containerd,podman,remote])
|
||||
--include-deprecated-checks include deprecated checks
|
||||
--include-kinds strings indicate the kinds included in scanning (example: node)
|
||||
--include-namespaces strings indicate the namespaces included in scanning (example: kube-system)
|
||||
--include-non-failures include successes and exceptions, available with '--scanners misconfig'
|
||||
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db")
|
||||
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db:1")
|
||||
--k8s-version string specify k8s version to validate outdated api by it (example: 1.21.0)
|
||||
--kubeconfig string specify the kubeconfig file path to use
|
||||
--list-all-pkgs enabling the option will output all packages regardless of vulnerability
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan])
|
||||
-n, --namespace string specify a namespace to scan
|
||||
--list-all-pkgs output all packages in the JSON report regardless of vulnerability
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan-json,terraformplan-snapshot])
|
||||
--no-progress suppress progress bar
|
||||
--node-collector-imageref string indicate the image reference for the node-collector scan job (default "ghcr.io/aquasecurity/node-collector:0.0.9")
|
||||
--node-collector-imageref string indicate the image reference for the node-collector scan job (default "ghcr.io/aquasecurity/node-collector:0.2.1")
|
||||
--node-collector-namespace string specify the namespace in which the node-collector job should be deployed (default "trivy-temp")
|
||||
--offline-scan do not issue API requests to identify dependencies
|
||||
-o, --output string output file name
|
||||
--output-plugin-arg string [EXPERIMENTAL] output plugin arguments
|
||||
--parallel int number of goroutines enabled for parallel scanning, set 0 to auto-detect parallelism (default 5)
|
||||
--password strings password. Comma-separated passwords allowed. TRIVY_PASSWORD should be used for security reasons.
|
||||
--policy-bundle-repository string OCI registry URL to retrieve policy bundle from (default "ghcr.io/aquasecurity/trivy-policies:0")
|
||||
--policy-namespaces strings Rego namespaces
|
||||
--qps float specify the maximum QPS to the master from this client (default 5)
|
||||
--redis-ca string redis ca file location, if using redis as cache backend
|
||||
--redis-cert string redis certificate file location, if using redis as cache backend
|
||||
@@ -82,16 +88,18 @@ trivy kubernetes [flags] { cluster | all | specific resources like kubectl. eg:
|
||||
--rekor-url string [EXPERIMENTAL] address of rekor STL server (default "https://rekor.sigstore.dev")
|
||||
--report string specify a report format for the output (all,summary) (default "all")
|
||||
--reset remove all caches and database
|
||||
--reset-policy-bundle remove policy bundle
|
||||
--reset-checks-bundle remove checks bundle
|
||||
--sbom-sources strings [EXPERIMENTAL] try to retrieve SBOM from the specified sources (oci,rekor)
|
||||
--scanners strings comma-separated list of what security issues to detect (vuln,misconfig,secret,rbac) (default [vuln,misconfig,secret,rbac])
|
||||
--secret-config string specify a path to config file for secret scanning (default "trivy-secret.yaml")
|
||||
-s, --severity strings severities of security issues to be displayed (UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL) (default [UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL])
|
||||
--show-suppressed [EXPERIMENTAL] show suppressed vulnerabilities
|
||||
--skip-check-update skip fetching rego check updates
|
||||
--skip-db-update skip updating vulnerability database
|
||||
--skip-dirs strings specify the directories or glob patterns to skip
|
||||
--skip-files strings specify the files or glob patterns to skip
|
||||
--skip-images skip the downloading and scanning of images (vulnerabilities and secrets) in the cluster resources
|
||||
--skip-java-db-update skip updating Java index database
|
||||
--skip-policy-update skip fetching rego policy updates
|
||||
-t, --template string output template
|
||||
--tf-exclude-downloaded-modules exclude misconfigurations for downloaded terraform modules
|
||||
--tolerations strings specify node-collector job tolerations (example: key1=value1:NoExecute,key2=value2:NoSchedule)
|
||||
|
||||
@@ -28,6 +28,8 @@ Manage plugins
|
||||
* [trivy plugin install](trivy_plugin_install.md) - Install a plugin
|
||||
* [trivy plugin list](trivy_plugin_list.md) - List installed plugin
|
||||
* [trivy plugin run](trivy_plugin_run.md) - Run a plugin on the fly
|
||||
* [trivy plugin search](trivy_plugin_search.md) - List Trivy plugins available on the plugin index and search among them
|
||||
* [trivy plugin uninstall](trivy_plugin_uninstall.md) - Uninstall a plugin
|
||||
* [trivy plugin update](trivy_plugin_update.md) - Update an existing plugin
|
||||
* [trivy plugin update](trivy_plugin_update.md) - Update the local copy of the plugin index
|
||||
* [trivy plugin upgrade](trivy_plugin_upgrade.md) - Upgrade installed plugins to newer versions
|
||||
|
||||
|
||||
@@ -3,7 +3,20 @@
|
||||
Install a plugin
|
||||
|
||||
```
|
||||
trivy plugin install URL | FILE_PATH
|
||||
trivy plugin install NAME | URL | FILE_PATH
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
```
|
||||
# Install a plugin from the plugin index
|
||||
$ trivy plugin install referrer
|
||||
|
||||
# Specify the version of the plugin to install
|
||||
$ trivy plugin install referrer@v0.3.0
|
||||
|
||||
# Install a plugin from a URL
|
||||
$ trivy plugin install github.com/aquasecurity/trivy-plugin-referrer
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Run a plugin on the fly
|
||||
|
||||
```
|
||||
trivy plugin run URL | FILE_PATH
|
||||
trivy plugin run NAME | URL | FILE_PATH
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
## trivy plugin search
|
||||
|
||||
List Trivy plugins available on the plugin index and search among them
|
||||
|
||||
```
|
||||
trivy plugin search [KEYWORD]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for search
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--cache-dir string cache directory (default "/path/to/cache")
|
||||
-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
|
||||
-q, --quiet suppress progress bar and log output
|
||||
--timeout duration timeout (default 5m0s)
|
||||
-v, --version show version
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [trivy plugin](trivy_plugin.md) - Manage plugins
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
## trivy plugin update
|
||||
|
||||
Update an existing plugin
|
||||
Update the local copy of the plugin index
|
||||
|
||||
```
|
||||
trivy plugin update PLUGIN_NAME
|
||||
trivy plugin update
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
## trivy plugin upgrade
|
||||
|
||||
Upgrade installed plugins to newer versions
|
||||
|
||||
```
|
||||
trivy plugin upgrade [PLUGIN_NAMES]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for upgrade
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--cache-dir string cache directory (default "/path/to/cache")
|
||||
-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
|
||||
-q, --quiet suppress progress bar and log output
|
||||
--timeout duration timeout (default 5m0s)
|
||||
-v, --version show version
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [trivy plugin](trivy_plugin.md) - Manage plugins
|
||||
|
||||
@@ -22,12 +22,14 @@ trivy repository [flags] (REPO_PATH | REPO_URL)
|
||||
--cache-backend string cache backend (e.g. redis://localhost:6379) (default "fs")
|
||||
--cache-ttl duration cache TTL when using redis as cache backend
|
||||
--cf-params strings specify paths to override the CloudFormation parameters files
|
||||
--check-namespaces strings Rego namespaces
|
||||
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "ghcr.io/aquasecurity/trivy-checks:0")
|
||||
--clear-cache clear image caches without scanning
|
||||
--commit string pass the commit hash to be scanned
|
||||
--config-data strings specify paths from which data for the Rego policies will be recursively loaded
|
||||
--config-policy strings specify the paths to the Rego policy files or to the directories containing them, applying config files
|
||||
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
|
||||
--config-data strings specify paths from which data for the Rego checks will be recursively loaded
|
||||
--custom-headers strings custom headers in client mode
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db")
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db:2")
|
||||
--dependency-tree [EXPERIMENTAL] show dependency origin tree of vulnerable packages
|
||||
--download-db-only download/update vulnerability database but don't run a scan
|
||||
--download-java-db-only download/update Java index database but don't run a scan
|
||||
@@ -35,6 +37,8 @@ trivy repository [flags] (REPO_PATH | REPO_URL)
|
||||
--exit-code int specify exit code when any security issues are found
|
||||
--file-patterns strings specify config file patterns
|
||||
-f, --format string format (table,json,template,sarif,cyclonedx,spdx,spdx-json,github,cosign-vuln) (default "table")
|
||||
--helm-api-versions strings Available API versions used for Capabilities.APIVersions. This flag is the same as the api-versions flag of the helm template command. (can specify multiple or separate values with commas: policy/v1/PodDisruptionBudget,apps/v1/Deployment)
|
||||
--helm-kube-version string Kubernetes version used for Capabilities.KubeVersion. This flag is the same as the kube-version flag of the helm template command.
|
||||
--helm-set strings specify Helm values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
|
||||
--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)
|
||||
@@ -45,13 +49,14 @@ trivy repository [flags] (REPO_PATH | REPO_URL)
|
||||
--ignore-unfixed display only fixed vulnerabilities
|
||||
--ignored-licenses strings specify a list of license to ignore
|
||||
--ignorefile string specify .trivyignore file (default ".trivyignore")
|
||||
--include-deprecated-checks include deprecated checks
|
||||
--include-dev-deps include development dependencies in the report (supported: npm, yarn)
|
||||
--include-non-failures include successes and exceptions, available with '--scanners misconfig'
|
||||
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db")
|
||||
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db:1")
|
||||
--license-confidence-level float specify license classifier's confidence level (default 0.9)
|
||||
--license-full eagerly look for licenses in source code headers and license files
|
||||
--list-all-pkgs enabling the option will output all packages regardless of vulnerability
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan])
|
||||
--list-all-pkgs output all packages in the JSON report regardless of vulnerability
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan-json,terraformplan-snapshot])
|
||||
--module-dir string specify directory to the wasm modules that will be loaded (default "$HOME/.trivy/modules")
|
||||
--no-progress suppress progress bar
|
||||
--offline-scan do not issue API requests to identify dependencies
|
||||
@@ -59,8 +64,6 @@ trivy repository [flags] (REPO_PATH | REPO_URL)
|
||||
--output-plugin-arg string [EXPERIMENTAL] output plugin arguments
|
||||
--parallel int number of goroutines enabled for parallel scanning, set 0 to auto-detect parallelism (default 5)
|
||||
--password strings password. Comma-separated passwords allowed. TRIVY_PASSWORD should be used for security reasons.
|
||||
--policy-bundle-repository string OCI registry URL to retrieve policy bundle from (default "ghcr.io/aquasecurity/trivy-policies:0")
|
||||
--policy-namespaces strings Rego namespaces
|
||||
--redis-ca string redis ca file location, if using redis as cache backend
|
||||
--redis-cert string redis certificate file location, if using redis as cache backend
|
||||
--redis-key string redis key file location, if using redis as cache backend
|
||||
@@ -68,17 +71,18 @@ trivy repository [flags] (REPO_PATH | REPO_URL)
|
||||
--registry-token string registry token
|
||||
--rekor-url string [EXPERIMENTAL] address of rekor STL server (default "https://rekor.sigstore.dev")
|
||||
--reset remove all caches and database
|
||||
--reset-policy-bundle remove policy bundle
|
||||
--reset-checks-bundle remove checks bundle
|
||||
--sbom-sources strings [EXPERIMENTAL] try to retrieve SBOM from the specified sources (oci,rekor)
|
||||
--scanners strings comma-separated list of what security issues to detect (vuln,misconfig,secret,license) (default [vuln,secret])
|
||||
--secret-config string specify a path to config file for secret scanning (default "trivy-secret.yaml")
|
||||
--server string server address in client mode
|
||||
-s, --severity strings severities of security issues to be displayed (UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL) (default [UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL])
|
||||
--show-suppressed [EXPERIMENTAL] show suppressed vulnerabilities
|
||||
--skip-check-update skip fetching rego check updates
|
||||
--skip-db-update skip updating vulnerability database
|
||||
--skip-dirs strings specify the directories or glob patterns to skip
|
||||
--skip-files strings specify the files or glob patterns to skip
|
||||
--skip-java-db-update skip updating Java index database
|
||||
--skip-policy-update skip fetching rego policy updates
|
||||
--tag string pass the tag name to be scanned
|
||||
-t, --template string output template
|
||||
--tf-exclude-downloaded-modules exclude misconfigurations for downloaded terraform modules
|
||||
|
||||
@@ -25,11 +25,13 @@ trivy rootfs [flags] ROOTDIR
|
||||
--cache-backend string cache backend (e.g. redis://localhost:6379) (default "fs")
|
||||
--cache-ttl duration cache TTL when using redis as cache backend
|
||||
--cf-params strings specify paths to override the CloudFormation parameters files
|
||||
--check-namespaces strings Rego namespaces
|
||||
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "ghcr.io/aquasecurity/trivy-checks:0")
|
||||
--clear-cache clear image caches without scanning
|
||||
--config-data strings specify paths from which data for the Rego policies will be recursively loaded
|
||||
--config-policy strings specify the paths to the Rego policy files or to the directories containing them, applying config files
|
||||
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
|
||||
--config-data strings specify paths from which data for the Rego checks will be recursively loaded
|
||||
--custom-headers strings custom headers in client mode
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db")
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db:2")
|
||||
--dependency-tree [EXPERIMENTAL] show dependency origin tree of vulnerable packages
|
||||
--download-db-only download/update vulnerability database but don't run a scan
|
||||
--download-java-db-only download/update Java index database but don't run a scan
|
||||
@@ -38,6 +40,8 @@ trivy rootfs [flags] ROOTDIR
|
||||
--exit-on-eol int exit with the specified code when the OS reaches end of service/life
|
||||
--file-patterns strings specify config file patterns
|
||||
-f, --format string format (table,json,template,sarif,cyclonedx,spdx,spdx-json,github,cosign-vuln) (default "table")
|
||||
--helm-api-versions strings Available API versions used for Capabilities.APIVersions. This flag is the same as the api-versions flag of the helm template command. (can specify multiple or separate values with commas: policy/v1/PodDisruptionBudget,apps/v1/Deployment)
|
||||
--helm-kube-version string Kubernetes version used for Capabilities.KubeVersion. This flag is the same as the kube-version flag of the helm template command.
|
||||
--helm-set strings specify Helm values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
|
||||
--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)
|
||||
@@ -48,12 +52,13 @@ trivy rootfs [flags] ROOTDIR
|
||||
--ignore-unfixed display only fixed vulnerabilities
|
||||
--ignored-licenses strings specify a list of license to ignore
|
||||
--ignorefile string specify .trivyignore file (default ".trivyignore")
|
||||
--include-deprecated-checks include deprecated checks
|
||||
--include-non-failures include successes and exceptions, available with '--scanners misconfig'
|
||||
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db")
|
||||
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db:1")
|
||||
--license-confidence-level float specify license classifier's confidence level (default 0.9)
|
||||
--license-full eagerly look for licenses in source code headers and license files
|
||||
--list-all-pkgs enabling the option will output all packages regardless of vulnerability
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan])
|
||||
--list-all-pkgs output all packages in the JSON report regardless of vulnerability
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan-json,terraformplan-snapshot])
|
||||
--module-dir string specify directory to the wasm modules that will be loaded (default "$HOME/.trivy/modules")
|
||||
--no-progress suppress progress bar
|
||||
--offline-scan do not issue API requests to identify dependencies
|
||||
@@ -61,8 +66,6 @@ trivy rootfs [flags] ROOTDIR
|
||||
--output-plugin-arg string [EXPERIMENTAL] output plugin arguments
|
||||
--parallel int number of goroutines enabled for parallel scanning, set 0 to auto-detect parallelism (default 5)
|
||||
--password strings password. Comma-separated passwords allowed. TRIVY_PASSWORD should be used for security reasons.
|
||||
--policy-bundle-repository string OCI registry URL to retrieve policy bundle from (default "ghcr.io/aquasecurity/trivy-policies:0")
|
||||
--policy-namespaces strings Rego namespaces
|
||||
--redis-ca string redis ca file location, if using redis as cache backend
|
||||
--redis-cert string redis certificate file location, if using redis as cache backend
|
||||
--redis-key string redis key file location, if using redis as cache backend
|
||||
@@ -70,17 +73,18 @@ trivy rootfs [flags] ROOTDIR
|
||||
--registry-token string registry token
|
||||
--rekor-url string [EXPERIMENTAL] address of rekor STL server (default "https://rekor.sigstore.dev")
|
||||
--reset remove all caches and database
|
||||
--reset-policy-bundle remove policy bundle
|
||||
--reset-checks-bundle remove checks bundle
|
||||
--sbom-sources strings [EXPERIMENTAL] try to retrieve SBOM from the specified sources (oci,rekor)
|
||||
--scanners strings comma-separated list of what security issues to detect (vuln,misconfig,secret,license) (default [vuln,secret])
|
||||
--secret-config string specify a path to config file for secret scanning (default "trivy-secret.yaml")
|
||||
--server string server address in client mode
|
||||
-s, --severity strings severities of security issues to be displayed (UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL) (default [UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL])
|
||||
--show-suppressed [EXPERIMENTAL] show suppressed vulnerabilities
|
||||
--skip-check-update skip fetching rego check updates
|
||||
--skip-db-update skip updating vulnerability database
|
||||
--skip-dirs strings specify the directories or glob patterns to skip
|
||||
--skip-files strings specify the files or glob patterns to skip
|
||||
--skip-java-db-update skip updating Java index database
|
||||
--skip-policy-update skip fetching rego policy updates
|
||||
-t, --template string output template
|
||||
--tf-exclude-downloaded-modules exclude misconfigurations for downloaded terraform modules
|
||||
--tf-vars strings specify paths to override the Terraform tfvars files
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## trivy sbom
|
||||
|
||||
Scan SBOM for vulnerabilities
|
||||
Scan SBOM for vulnerabilities and licenses
|
||||
|
||||
```
|
||||
trivy sbom [flags] SBOM_PATH
|
||||
@@ -25,7 +25,7 @@ trivy sbom [flags] SBOM_PATH
|
||||
--clear-cache clear image caches without scanning
|
||||
--compliance string compliance report to generate
|
||||
--custom-headers strings custom headers in client mode
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db")
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db:2")
|
||||
--download-db-only download/update vulnerability database but don't run a scan
|
||||
--download-java-db-only download/update Java index database but don't run a scan
|
||||
--exit-code int specify exit code when any security issues are found
|
||||
@@ -36,9 +36,10 @@ trivy sbom [flags] SBOM_PATH
|
||||
--ignore-policy string specify the Rego file path to evaluate each vulnerability
|
||||
--ignore-status strings comma-separated list of vulnerability status to ignore (unknown,not_affected,affected,fixed,under_investigation,will_not_fix,fix_deferred,end_of_life)
|
||||
--ignore-unfixed display only fixed vulnerabilities
|
||||
--ignored-licenses strings specify a list of license to ignore
|
||||
--ignorefile string specify .trivyignore file (default ".trivyignore")
|
||||
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db")
|
||||
--list-all-pkgs enabling the option will output all packages regardless of vulnerability
|
||||
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db:1")
|
||||
--list-all-pkgs output all packages in the JSON report regardless of vulnerability
|
||||
--no-progress suppress progress bar
|
||||
--offline-scan do not issue API requests to identify dependencies
|
||||
-o, --output string output file name
|
||||
@@ -50,8 +51,10 @@ trivy sbom [flags] SBOM_PATH
|
||||
--rekor-url string [EXPERIMENTAL] address of rekor STL server (default "https://rekor.sigstore.dev")
|
||||
--reset remove all caches and database
|
||||
--sbom-sources strings [EXPERIMENTAL] try to retrieve SBOM from the specified sources (oci,rekor)
|
||||
--scanners strings comma-separated list of what security issues to detect (vuln,license) (default [vuln])
|
||||
--server string server address in client mode
|
||||
-s, --severity strings severities of security issues to be displayed (UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL) (default [UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL])
|
||||
--show-suppressed [EXPERIMENTAL] show suppressed vulnerabilities
|
||||
--skip-db-update skip updating vulnerability database
|
||||
--skip-dirs strings specify the directories or glob patterns to skip
|
||||
--skip-files strings specify the files or glob patterns to skip
|
||||
|
||||
@@ -23,7 +23,7 @@ trivy server [flags]
|
||||
--cache-backend string cache backend (e.g. redis://localhost:6379) (default "fs")
|
||||
--cache-ttl duration cache TTL when using redis as cache backend
|
||||
--clear-cache clear image caches without scanning
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db")
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db:2")
|
||||
--download-db-only download/update vulnerability database but don't run a scan
|
||||
--enable-modules strings [EXPERIMENTAL] module names to enable
|
||||
-h, --help help for server
|
||||
|
||||
@@ -23,10 +23,11 @@ trivy vm [flags] VM_IMAGE
|
||||
--aws-region string AWS region to scan
|
||||
--cache-backend string cache backend (e.g. redis://localhost:6379) (default "fs")
|
||||
--cache-ttl duration cache TTL when using redis as cache backend
|
||||
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "ghcr.io/aquasecurity/trivy-checks:0")
|
||||
--clear-cache clear image caches without scanning
|
||||
--compliance string compliance report to generate
|
||||
--custom-headers strings custom headers in client mode
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db")
|
||||
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db:2")
|
||||
--dependency-tree [EXPERIMENTAL] show dependency origin tree of vulnerable packages
|
||||
--download-db-only download/update vulnerability database but don't run a scan
|
||||
--download-java-db-only download/update Java index database but don't run a scan
|
||||
@@ -35,6 +36,8 @@ trivy vm [flags] VM_IMAGE
|
||||
--exit-on-eol int exit with the specified code when the OS reaches end of service/life
|
||||
--file-patterns strings specify config file patterns
|
||||
-f, --format string format (table,json,template,sarif,cyclonedx,spdx,spdx-json,github,cosign-vuln) (default "table")
|
||||
--helm-api-versions strings Available API versions used for Capabilities.APIVersions. This flag is the same as the api-versions flag of the helm template command. (can specify multiple or separate values with commas: policy/v1/PodDisruptionBudget,apps/v1/Deployment)
|
||||
--helm-kube-version string Kubernetes version used for Capabilities.KubeVersion. This flag is the same as the kube-version flag of the helm template command.
|
||||
--helm-set strings specify Helm values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
|
||||
--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)
|
||||
@@ -45,28 +48,28 @@ trivy vm [flags] VM_IMAGE
|
||||
--ignore-unfixed display only fixed vulnerabilities
|
||||
--ignorefile string specify .trivyignore file (default ".trivyignore")
|
||||
--include-non-failures include successes and exceptions, available with '--scanners misconfig'
|
||||
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db")
|
||||
--list-all-pkgs enabling the option will output all packages regardless of vulnerability
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan])
|
||||
--java-db-repository string OCI repository to retrieve trivy-java-db from (default "ghcr.io/aquasecurity/trivy-java-db:1")
|
||||
--list-all-pkgs output all packages in the JSON report regardless of vulnerability
|
||||
--misconfig-scanners strings comma-separated list of misconfig scanners to use for misconfiguration scanning (default [azure-arm,cloudformation,dockerfile,helm,kubernetes,terraform,terraformplan-json,terraformplan-snapshot])
|
||||
--module-dir string specify directory to the wasm modules that will be loaded (default "$HOME/.trivy/modules")
|
||||
--no-progress suppress progress bar
|
||||
--offline-scan do not issue API requests to identify dependencies
|
||||
-o, --output string output file name
|
||||
--output-plugin-arg string [EXPERIMENTAL] output plugin arguments
|
||||
--parallel int number of goroutines enabled for parallel scanning, set 0 to auto-detect parallelism (default 5)
|
||||
--policy-bundle-repository string OCI registry URL to retrieve policy bundle from (default "ghcr.io/aquasecurity/trivy-policies:0")
|
||||
--redis-ca string redis ca file location, if using redis as cache backend
|
||||
--redis-cert string redis certificate file location, if using redis as cache backend
|
||||
--redis-key string redis key file location, if using redis as cache backend
|
||||
--redis-tls enable redis TLS with public certificates, if using redis as cache backend
|
||||
--rekor-url string [EXPERIMENTAL] address of rekor STL server (default "https://rekor.sigstore.dev")
|
||||
--reset remove all caches and database
|
||||
--reset-policy-bundle remove policy bundle
|
||||
--reset-checks-bundle remove checks bundle
|
||||
--sbom-sources strings [EXPERIMENTAL] try to retrieve SBOM from the specified sources (oci,rekor)
|
||||
--scanners strings comma-separated list of what security issues to detect (vuln,misconfig,secret,license) (default [vuln,secret])
|
||||
--secret-config string specify a path to config file for secret scanning (default "trivy-secret.yaml")
|
||||
--server string server address in client mode
|
||||
-s, --severity strings severities of security issues to be displayed (UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL) (default [UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL])
|
||||
--show-suppressed [EXPERIMENTAL] show suppressed vulnerabilities
|
||||
--skip-db-update skip updating vulnerability database
|
||||
--skip-dirs strings specify the directories or glob patterns to skip
|
||||
--skip-files strings specify the files or glob patterns to skip
|
||||
|
||||
@@ -81,6 +81,15 @@ severity:
|
||||
- MEDIUM
|
||||
- HIGH
|
||||
- CRITICAL
|
||||
|
||||
scan:
|
||||
# Same as '--compliance'
|
||||
# Default is empty
|
||||
compliance:
|
||||
|
||||
# Same as '--show-suppressed'
|
||||
# Default is false
|
||||
show-suppressed: false
|
||||
```
|
||||
|
||||
## Scan Options
|
||||
@@ -106,7 +115,7 @@ scan:
|
||||
|
||||
# Same as '--offline-scan'
|
||||
# Default is false
|
||||
offline-scan: false
|
||||
offline: false
|
||||
|
||||
# Same as '--scanners'
|
||||
# Default depends on subcommand
|
||||
@@ -115,6 +124,24 @@ scan:
|
||||
- misconfig
|
||||
- secret
|
||||
- license
|
||||
-
|
||||
# Same as '--parallel'
|
||||
# Default is 5
|
||||
parallel: 1
|
||||
|
||||
# Same as '--sbom-sources'
|
||||
# Default is empty
|
||||
sbom-sources:
|
||||
- oci
|
||||
- rekor
|
||||
|
||||
# Same as '--rekor-url'
|
||||
# Default is 'https://rekor.sigstore.dev'
|
||||
rekor-url: https://rekor.sigstore.dev
|
||||
|
||||
# Same as '--include-dev-deps'
|
||||
# Default is false
|
||||
include-dev-deps: false
|
||||
```
|
||||
|
||||
## Cache Options
|
||||
@@ -131,6 +158,9 @@ cache:
|
||||
|
||||
# Redis options
|
||||
redis:
|
||||
# Same as '--redis-tls'
|
||||
# Default is false
|
||||
tls:
|
||||
# Same as '--redis-ca'
|
||||
# Default is empty
|
||||
ca:
|
||||
@@ -148,21 +178,25 @@ cache:
|
||||
|
||||
```yaml
|
||||
db:
|
||||
# Same as '--no-progress'
|
||||
# Default is false
|
||||
no-progress: false
|
||||
|
||||
# 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 'ghcr.io/aquasecurity/trivy-db'
|
||||
repository: ghcr.io/aquasecurity/trivy-db
|
||||
# Default is 'ghcr.io/aquasecurity/trivy-db:2'
|
||||
repository: ghcr.io/aquasecurity/trivy-db:2
|
||||
|
||||
# Same as '--skip-java-db-update'
|
||||
# Default is false
|
||||
java-skip-update: false
|
||||
|
||||
# Same as '--java-db-repository'
|
||||
# Default is 'ghcr.io/aquasecurity/trivy-java-db'
|
||||
java-repository: ghcr.io/aquasecurity/trivy-java-db
|
||||
# Default is 'ghcr.io/aquasecurity/trivy-java-db:1'
|
||||
java-repository: ghcr.io/aquasecurity/trivy-java-db:1
|
||||
```
|
||||
|
||||
## Registry Options
|
||||
@@ -197,12 +231,29 @@ image:
|
||||
|
||||
# Same as '--platform'
|
||||
# Default is empty
|
||||
platform:
|
||||
platform:
|
||||
|
||||
# Same as '--image-src'
|
||||
# Default is 'docker,containerd,podman,remote'
|
||||
source:
|
||||
- podman
|
||||
- docker
|
||||
|
||||
# Same as '--image-config-scanners'
|
||||
# Default is empty
|
||||
image-config-scanners:
|
||||
- misconfig
|
||||
- secret
|
||||
|
||||
docker:
|
||||
# Same as '--docker-host'
|
||||
# Default is empty
|
||||
host:
|
||||
|
||||
podman:
|
||||
# Same as '--podman-host'
|
||||
# Default is empty
|
||||
host:
|
||||
```
|
||||
|
||||
## Vulnerability Options
|
||||
@@ -219,6 +270,67 @@ vulnerability:
|
||||
# Same as '--ignore-unfixed'
|
||||
# Default is false
|
||||
ignore-unfixed: false
|
||||
|
||||
# Same as '--ignore-unfixed'
|
||||
# Default is empty
|
||||
ignore-status:
|
||||
- end_of_life
|
||||
```
|
||||
|
||||
## License Options
|
||||
Available with license scanning
|
||||
|
||||
```yaml
|
||||
license:
|
||||
# Same as '--license-full'
|
||||
# Default is false
|
||||
full: false
|
||||
|
||||
# Same as '--ignored-licenses'
|
||||
# Default is empty
|
||||
ignored:
|
||||
- MPL-2.0
|
||||
- MIT
|
||||
|
||||
# Same as '--license-confidence-level'
|
||||
# Default is 0.9
|
||||
confidenceLevel: 0.9
|
||||
|
||||
# Set list of forbidden licenses
|
||||
# Default is https://github.com/aquasecurity/trivy/blob/164b025413c5fb9c6759491e9a306b46b869be93/pkg/licensing/category.go#L171
|
||||
forbidden:
|
||||
- AGPL-1.0
|
||||
- AGPL-3.0
|
||||
|
||||
# Set list of restricted licenses
|
||||
# Default is https://github.com/aquasecurity/trivy/blob/164b025413c5fb9c6759491e9a306b46b869be93/pkg/licensing/category.go#L199
|
||||
restricted:
|
||||
- AGPL-1.0
|
||||
- AGPL-3.0
|
||||
|
||||
# Set list of reciprocal licenses
|
||||
# Default is https://github.com/aquasecurity/trivy/blob/164b025413c5fb9c6759491e9a306b46b869be93/pkg/licensing/category.go#L238
|
||||
reciprocal:
|
||||
- AGPL-1.0
|
||||
- AGPL-3.0
|
||||
|
||||
# Set list of notice licenses
|
||||
# Default is https://github.com/aquasecurity/trivy/blob/164b025413c5fb9c6759491e9a306b46b869be93/pkg/licensing/category.go#L260
|
||||
notice:
|
||||
- AGPL-1.0
|
||||
- AGPL-3.0
|
||||
|
||||
# Set list of permissive licenses
|
||||
# Default is empty
|
||||
permissive:
|
||||
- AGPL-1.0
|
||||
- AGPL-3.0
|
||||
|
||||
# Set list of unencumbered licenses
|
||||
# Default is https://github.com/aquasecurity/trivy/blob/164b025413c5fb9c6759491e9a306b46b869be93/pkg/licensing/category.go#L334
|
||||
unencumbered:
|
||||
- AGPL-1.0
|
||||
- AGPL-3.0
|
||||
```
|
||||
|
||||
## Secret Options
|
||||
@@ -234,11 +346,15 @@ secret:
|
||||
## Rego Options
|
||||
|
||||
```yaml
|
||||
rego
|
||||
rego:
|
||||
# Same as '--trace'
|
||||
# Default is false
|
||||
trace: false
|
||||
|
||||
# Same as '--skip-policy-update'
|
||||
# Default is false
|
||||
skip-policy-update: false
|
||||
|
||||
# Same as '--config-policy'
|
||||
# Default is empty
|
||||
policy:
|
||||
@@ -267,6 +383,14 @@ misconfiguration:
|
||||
# Default is false
|
||||
include-non-failures: false
|
||||
|
||||
# Same as '--include-deprecated-checks'
|
||||
# Default is false
|
||||
include-deprecated-checks: false
|
||||
|
||||
# Same as '--check-bundle-repository' and '--policy-bundle-repository'
|
||||
# Default is 'ghcr.io/aquasecurity/trivy-checks:0'
|
||||
check-bundle-repository: ghcr.io/aquasecurity/trivy-checks:0
|
||||
|
||||
# Same as '--miconfig-scanners'
|
||||
# Default is all scanners
|
||||
scanners:
|
||||
@@ -274,36 +398,46 @@ misconfiguration:
|
||||
- terraform
|
||||
|
||||
# helm value override configurations
|
||||
# set individual values
|
||||
helm:
|
||||
# set individual values
|
||||
set:
|
||||
- securityContext.runAsUser=10001
|
||||
|
||||
# set values with file
|
||||
helm:
|
||||
# set values with file
|
||||
values:
|
||||
- overrides.yaml
|
||||
|
||||
# set specific values from specific files
|
||||
helm:
|
||||
# set specific values from specific files
|
||||
set-file:
|
||||
- image=dev-overrides.yaml
|
||||
|
||||
# set as string and preserve type
|
||||
helm:
|
||||
# set as string and preserve type
|
||||
set-string:
|
||||
- name=true
|
||||
|
||||
# Available API versions used for Capabilities.APIVersions. This flag is the same as the api-versions flag of the helm template command.
|
||||
api-versions:
|
||||
- policy/v1/PodDisruptionBudget
|
||||
- apps/v1/Deployment
|
||||
|
||||
# Kubernetes version used for Capabilities.KubeVersion. This flag is the same as the kube-version flag of the helm template command.
|
||||
kube-version: "v1.21.0"
|
||||
|
||||
# terraform tfvars overrrides
|
||||
terraform:
|
||||
vars:
|
||||
- dev-terraform.tfvars
|
||||
- common-terraform.tfvars
|
||||
|
||||
# Same as '--tf-exclude-downloaded-modules'
|
||||
# Default is false
|
||||
terraform:
|
||||
# Same as '--tf-exclude-downloaded-modules'
|
||||
# Default is false
|
||||
exclude-downloaded-modules: false
|
||||
|
||||
# Same as '--cf-params'
|
||||
# Default is false
|
||||
cloudformation:
|
||||
params:
|
||||
- params.json
|
||||
```
|
||||
|
||||
## Kubernetes Options
|
||||
@@ -318,6 +452,58 @@ kubernetes:
|
||||
# Same as '--namespace'
|
||||
# Default is empty
|
||||
namespace:
|
||||
|
||||
# Same as '--kubeconfig'
|
||||
# Default is empty
|
||||
kubeconfig: ~/.kube/config2
|
||||
|
||||
# Same as '--components'
|
||||
# Default is 'workload,infra'
|
||||
components:
|
||||
- workload
|
||||
- infra
|
||||
|
||||
# Same as '--k8s-version'
|
||||
# Default is empty
|
||||
k8s-version: 1.21.0
|
||||
|
||||
# Same as '--tolerations'
|
||||
# Default is empty
|
||||
tolerations:
|
||||
- key1=value1:NoExecute
|
||||
- key2=value2:NoSchedule
|
||||
|
||||
# Same as '--all-namespaces'
|
||||
# Default is false
|
||||
all-namespaces: false
|
||||
|
||||
node-collector:
|
||||
# Same as '--node-collector-namespace'
|
||||
# Default is 'trivy-temp'
|
||||
namespace: ~/.kube/config2
|
||||
|
||||
# Same as '--node-collector-imageref'
|
||||
# Default is 'ghcr.io/aquasecurity/node-collector:0.0.9'
|
||||
imageref: ghcr.io/aquasecurity/node-collector:0.0.9
|
||||
|
||||
exclude:
|
||||
# Same as '--exclude-owned'
|
||||
# Default is false
|
||||
owned: true
|
||||
|
||||
# Same as '--exclude-nodes'
|
||||
# Default is empty
|
||||
nodes:
|
||||
- kubernetes.io/arch:arm64
|
||||
- team:dev
|
||||
|
||||
# Same as '--qps'
|
||||
# Default is 5.0
|
||||
qps: 5.0
|
||||
|
||||
# Same as '--burst'
|
||||
# Default is 10
|
||||
burst: 10
|
||||
```
|
||||
|
||||
## Repository Options
|
||||
@@ -388,6 +574,35 @@ cloud:
|
||||
|
||||
# the aws account to use (this will be determined from your environment when not set)
|
||||
account: 123456789012
|
||||
|
||||
# the aws specific services
|
||||
service:
|
||||
- s3
|
||||
- ec2
|
||||
|
||||
# the aws specific arn
|
||||
arn: arn:aws:s3:::example-bucket
|
||||
|
||||
# skip the aws specific services
|
||||
skip-service:
|
||||
- s3
|
||||
- ec2
|
||||
```
|
||||
|
||||
## Module Options
|
||||
Available for modules
|
||||
|
||||
```yaml
|
||||
module:
|
||||
# Same as '--module-dir'
|
||||
# Default is '$HOME/.trivy/modules'
|
||||
dir: $HOME/.trivy/modules
|
||||
|
||||
# Same as '--enable-modules'
|
||||
# Default is empty
|
||||
enable-modules:
|
||||
- trivy-module-spring4shell
|
||||
- trivy-module-wordpress
|
||||
```
|
||||
|
||||
[example]: https://github.com/aquasecurity/trivy/tree/{{ git.tag }}/examples/trivy-conf/trivy.yaml
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
Trivy has client/server mode. Trivy server has vulnerability database and Trivy client doesn't have to download vulnerability database. It is useful if you want to scan images or files at multiple locations and do not want to download the database at every location.
|
||||
|
||||
| Client/Server Mode | Image | Rootfs | Filesystem | Repository | Config | AWS | K8s |
|
||||
|:---------------------:|:-----:|:------:|:----------:|:----------:|:------:|:---:|:---:|
|
||||
| Supported | ✅ | ✅ | ✅ | ✅ | ✅ | X | X |
|
||||
|
||||
## Server
|
||||
At first, you need to launch Trivy server. It downloads vulnerability database automatically and continue to fetch the latest DB in the background.
|
||||
```
|
||||
|
||||
@@ -154,14 +154,42 @@ $ TMPDIR=/my/custom/path trivy repo ...
|
||||
write /tmp/fanal-3323732142: no space left on device
|
||||
```
|
||||
|
||||
Trivy uses the `/tmp` directory during image scan, if the image is large or `/tmp` is of insufficient size then the scan fails You can set the `TMPDIR` environment variable to use redirect trivy to use a directory with adequate storage.
|
||||
Trivy uses a temporary directory during image scans.
|
||||
The directory path would be determined as follows:
|
||||
|
||||
Try:
|
||||
- On Unix systems: Use `$TMPDIR` if non-empty, else `/tmp`.
|
||||
- On Windows: Uses GetTempPath, returning the first non-empty value from `%TMP%`, `%TEMP%`, `%USERPROFILE%`, or the Windows directory.
|
||||
|
||||
See [this documentation](https://golang.org/pkg/os/#TempDir) for more details.
|
||||
|
||||
If the image is large or the temporary directory has insufficient space, the scan will fail.
|
||||
You can configure the directory path to redirect Trivy to a directory with adequate storage.
|
||||
On Unix systems, you can set the `$TMPDIR` environment variable.
|
||||
|
||||
```
|
||||
$ TMPDIR=/my/custom/path trivy image ...
|
||||
```
|
||||
|
||||
When scanning images from a container registry, Trivy processes each layer by streaming, loading only the necessary files for the scan into memory and discarding unnecessary files.
|
||||
If a layer contains large files that are necessary for the scan (such as JAR files or binary files), Trivy saves them to a temporary directory (e.g. $TMPDIR) on local storage to avoid increased memory consumption.
|
||||
Although these files are deleted after the scan is complete, they can temporarily increase disk consumption and potentially exhaust storage.
|
||||
In such cases, there are currently three workarounds:
|
||||
|
||||
1. Use a temporary directory with sufficient capacity
|
||||
|
||||
This is the same as explained above.
|
||||
|
||||
2. Specify a small value for `--parallel`
|
||||
|
||||
By default, multiple layers are processed in parallel.
|
||||
If each layer contains large files, disk space may be consumed rapidly.
|
||||
By specifying a small value such as `--parallel 1`, parallelism is reduced, which can mitigate the issue.
|
||||
|
||||
3. Specify `--skip-files` or `--skip-dirs`
|
||||
|
||||
If the container image contains large files that do not need to be scanned, you can skip their processing by specifying --skip-files or --skip-dirs.
|
||||
For more details, please refer to [this documentation](../configuration/skipping.md).
|
||||
|
||||
## DB
|
||||
### Old DB schema
|
||||
|
||||
|
||||
@@ -22,18 +22,16 @@ Check out [the coverage document][coverage] for details.
|
||||
To enable extended license scanning, you can use `--license-full`.
|
||||
In addition to package licenses, Trivy scans source code files, Markdown documents, text files and `LICENSE` documents to identify license usage within the image or filesystem.
|
||||
|
||||
By default, Trivy only classifies licenses that are matched with a confidence level of 0.9 or more by the classifer.
|
||||
By default, Trivy only classifies licenses that are matched with a confidence level of 0.9 or more by the classifier.
|
||||
To configure the confidence level, you can use `--license-confidence-level`. This enables us to classify licenses that might be matched with a lower confidence level by the classifer.
|
||||
|
||||
!!! note
|
||||
The full license scanning is expensive. It takes a while.
|
||||
|
||||
Currently, the standard license scanning doesn't support filesystem and repository scanning.
|
||||
|
||||
| License scanning | Image | Rootfs | Filesystem | Repository |
|
||||
| :-------------------: | :---: | :----: | :--------: | :--------: |
|
||||
| Standard | ✅ | ✅ | - | - |
|
||||
| Full (--license-full) | ✅ | ✅ | ✅ | ✅ |
|
||||
| License scanning | Image | Rootfs | Filesystem | Repository | SBOM |
|
||||
|:---------------------:|:-----:|:------:|:----------:|:----------:|:----:|
|
||||
| Standard | ✅ | ✅ | ✅[^1][^2] | ✅[^1][^2] | ✅ |
|
||||
| Full (--license-full) | ✅ | ✅ | ✅ | ✅ | - |
|
||||
|
||||
License checking classifies the identified licenses and map the classification to severity.
|
||||
|
||||
@@ -344,6 +342,8 @@ license:
|
||||
permissive: []
|
||||
```
|
||||
|
||||
[^1]: See the list of supported language files [here](../coverage/language/index.md).
|
||||
[^2]: Some lock files require additional files (e.g. files from the cache directory) to detect licenses. Check [coverage][coverage] for more information.
|
||||
|
||||
[coverage]: ../coverage/index.md
|
||||
[google-license-classification]: https://opensource.google/documentation/reference/thirdparty/licenses
|
||||
|
||||
21
docs/docs/scanner/misconfiguration/check/builtin.md
Normal file
21
docs/docs/scanner/misconfiguration/check/builtin.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Built-in Checks
|
||||
|
||||
## Check Sources
|
||||
Built-in checks are mainly written in [Rego][rego] and Go.
|
||||
Those checks are managed under [trivy-checks repository][trivy-checks].
|
||||
See [here](../../../coverage/iac/index.md) for the list of supported config types.
|
||||
|
||||
For suggestions or issues regarding policy content, please open an issue under the [trivy-checks][trivy-checks] repository.
|
||||
|
||||
## Check Distribution
|
||||
Trivy checks 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 checks are then loaded into Trivy OPA engine and used for detecting misconfigurations.
|
||||
If Trivy is unable to pull down newer checks, it will use the embedded set of checks as a fallback. This is also the case in air-gap environments where `--skip-policy-update` might be passed.
|
||||
|
||||
## 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/
|
||||
[trivy-checks]: https://github.com/aquasecurity/trivy-checks
|
||||
[ghcr]: https://github.com/aquasecurity/trivy-checks/pkgs/container/trivy-checks
|
||||
@@ -3,10 +3,10 @@ Exceptions let you specify cases where you allow policy violations.
|
||||
Trivy supports two types of exceptions.
|
||||
|
||||
!!! info
|
||||
Exceptions can be applied to built-in policies as well as custom policies.
|
||||
Exceptions can be applied to built-in checks as well as custom checks.
|
||||
|
||||
## Namespace-based exceptions
|
||||
There are some cases where you need to disable built-in policies partially or fully.
|
||||
There are some cases where you need to disable built-in checks partially or fully.
|
||||
Namespace-based exceptions lets you rough choose which individual packages to exempt.
|
||||
|
||||
To use namespace-based exceptions, create a Rego rule with the name `exception` that returns the package names to exempt.
|
||||
@@ -26,9 +26,7 @@ The `exception` rule must be defined under `namespace.exceptions`.
|
||||
}
|
||||
```
|
||||
|
||||
This example exempts all built-in policies for Kubernetes.
|
||||
|
||||
For more details, see [an example][ns-example].
|
||||
This example exempts all built-in checks for Kubernetes.
|
||||
|
||||
## Rule-based exceptions
|
||||
There are some cases where you need more flexibility and granularity in defining which cases to exempt.
|
||||
@@ -75,7 +73,7 @@ The above would provide an exception from `deny_foo` and `deny_bar`.
|
||||
}
|
||||
```
|
||||
|
||||
If you want to apply rule-based exceptions to built-in policies, you have to define the exception under the same package.
|
||||
If you want to apply rule-based exceptions to built-in checks, you have to define the exception under the same package.
|
||||
|
||||
!!! example
|
||||
``` rego
|
||||
@@ -87,12 +85,8 @@ If you want to apply rule-based exceptions to built-in policies, you have to def
|
||||
}
|
||||
```
|
||||
|
||||
This exception is applied to [KSV012][ksv012] in trivy-policies.
|
||||
You can get the package names in the [trivy-policies repository][trivy-policies] or the JSON output from Trivy.
|
||||
This exception is applied to [KSV012][ksv012] in trivy-checks.
|
||||
You can get the package names in the [trivy-checks repository][trivy-checks] or the JSON output from Trivy.
|
||||
|
||||
For more details, see [an example][rule-example].
|
||||
|
||||
[ns-example]: https://github.com/aquasecurity/trivy/tree/{{ git.commit }}/examples/misconf/namespace-exception
|
||||
[rule-example]: https://github.com/aquasecurity/trivy/tree/{{ git.commit }}/examples/misconf/rule-exception
|
||||
[ksv012]: https://github.com/aquasecurity/trivy-policies/blob/main/rules/kubernetes/policies/pss/restricted/3_runs_as_root.rego
|
||||
[trivy-policies]: https://github.com/aquasecurity/trivy-policies/
|
||||
[ksv012]: https://github.com/aquasecurity/trivy-checks/blob/f36a5b732c4b1293a720c40baab0a7c106ea455e/checks/kubernetes/pss/restricted/3_runs_as_root.rego
|
||||
[trivy-checks]: https://github.com/aquasecurity/trivy-checks/
|
||||
@@ -0,0 +1,5 @@
|
||||
## Contribute Rego Checks
|
||||
|
||||
The contributing section provides detailed information on how to contribute custom checks to the [trivy-checks repository](../../../../community/contribute/checks/overview.md/)
|
||||
|
||||
This way, they become accessible as default [checks.](https://github.com/aquasecurity/trivy-checks)
|
||||
@@ -1,6 +1,6 @@
|
||||
# Custom Data
|
||||
|
||||
Custom policies may require additional data in order to determine an answer.
|
||||
Custom checks may require additional data in order to determine an answer.
|
||||
|
||||
For example, an allowed list of resources that can be created.
|
||||
Instead of hardcoding this information inside your policy, Trivy allows passing paths to data files with the `--data` flag.
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Debugging policies
|
||||
# Debugging checks
|
||||
When working on more complex queries (or when learning Rego), it's useful to see exactly how the policy is applied.
|
||||
For this purpose you can use the `--trace` flag.
|
||||
This will output a large trace from Open Policy Agent like the following:
|
||||
|
||||
!!! tip
|
||||
Only failed policies show traces. If you want to debug a passed policy, you need to make it fail on purpose.
|
||||
Only failed checks show traces. If you want to debug a passed check, you need to make it fail on purpose.
|
||||
|
||||
```shell
|
||||
$ trivy conf --trace configs/
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Custom Policies
|
||||
# Custom Checks
|
||||
|
||||
## Overview
|
||||
You can write custom policies in [Rego][rego].
|
||||
Once you finish writing custom policies, you can pass the policy files or the directory where those policies are stored with `--policy` option.
|
||||
You can write custom checks in [Rego][rego].
|
||||
Once you finish writing custom checks, you can pass the policy files or the directory where those policies are stored with `--policy` option.
|
||||
|
||||
``` bash
|
||||
trivy conf --policy /path/to/policy.rego --policy /path/to/custom_policies --namespaces user /path/to/config_dir
|
||||
@@ -27,7 +27,7 @@ In the above general file formats, Trivy automatically identifies the following
|
||||
- CloudFormation (JSON/YAML)
|
||||
- Kubernetes (JSON/YAML)
|
||||
- Helm (YAML)
|
||||
- Terraform Plan (JSON)
|
||||
- Terraform Plan (JSON/Snapshot)
|
||||
|
||||
This is useful for filtering inputs, as described below.
|
||||
|
||||
@@ -61,9 +61,9 @@ If you add a new custom policy, it must be defined under a new package like `use
|
||||
|
||||
### Policy structure
|
||||
|
||||
`# METADATA` (optional)
|
||||
`# METADATA` (optional unless the check will be contributed into Trivy)
|
||||
: - SHOULD be defined for clarity since these values will be displayed in the scan results
|
||||
- `custom.input` SHOULD be set to indicate the input type the policy should be applied to. See [list of available types](https://github.com/aquasecurity/defsec/blob/418759b4dc97af25f30f32e0bd365be7984003a1/pkg/types/sources.go)
|
||||
- `custom.input` SHOULD be set to indicate the input type the policy should be applied to. See [list of available types][source-types]
|
||||
|
||||
`package` (required)
|
||||
: - MUST follow the Rego's [specification][package]
|
||||
@@ -80,7 +80,6 @@ If you add a new custom policy, it must be defined under a new package like `use
|
||||
- A `string` denoting the detected issue
|
||||
- Although `object` with `msg` field is accepted, other fields are dropped and `string` is recommended if `result.new()` is not utilised.
|
||||
- e.g. `{"msg": "deny message", "details": "something"}`
|
||||
|
||||
|
||||
### Package
|
||||
A package name must be unique per policy.
|
||||
@@ -91,7 +90,7 @@ A package name must be unique per policy.
|
||||
```
|
||||
|
||||
By default, only `builtin.*` packages will be evaluated.
|
||||
If you define custom packages, you have to specify the package prefix via `--namespaces` option.
|
||||
If you define custom packages, you have to specify the package prefix via `--namespaces` option. By default, Trivy only runs in its own namespace, unless specified by the user. Note that the custom namespace does not have to be `user` as in this example. It could be anything user-defined.
|
||||
|
||||
``` bash
|
||||
trivy conf --policy /path/to/custom_policies --namespaces user /path/to/config_dir
|
||||
@@ -101,9 +100,8 @@ In this case, `user.*` will be evaluated.
|
||||
Any package prefixes such as `main` and `user` are allowed.
|
||||
|
||||
### Metadata
|
||||
Metadata helps enrich Trivy's scan results with useful information.
|
||||
|
||||
The annotation format is described in the [OPA documentation](https://www.openpolicyagent.org/docs/latest/annotations/).
|
||||
The check must contain a [Rego Metadata](https://www.openpolicyagent.org/docs/latest/policy-language/#metadata) section. Trivy uses standard rego metadata to define the new policy and general information about it.
|
||||
|
||||
Trivy supports extra fields in the `custom` section as described below.
|
||||
|
||||
@@ -120,8 +118,7 @@ Trivy supports extra fields in the `custom` section as described below.
|
||||
# - type: kubernetes
|
||||
```
|
||||
|
||||
All fields are optional. The `schemas` field should be used to enable policy validation using a built-in schema. The
|
||||
schema that will be used is based on the input document type. It is recommended to use this to ensure your policies are
|
||||
If you are creating checks for your Trivy misconfiguration scans, some fields are optional as referenced in the table below. The `schemas` field should be used to enable policy validation using a built-in schema. It is recommended to use this to ensure your checks are
|
||||
correct and do not reference incorrect properties/values.
|
||||
|
||||
| Field name | Allowed values | Default value | In table | In JSON |
|
||||
@@ -132,9 +129,33 @@ correct and do not reference incorrect properties/values.
|
||||
| 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.deprecated | `true`, `false` | `false` | :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: |
|
||||
|
||||
#### custom.avd_id and custom.id
|
||||
|
||||
The AVD_ID can be used to link the check to the Aqua Vulnerability Database (AVD) entry. For example, the `avd_id` `AVD-AWS-0176` is the ID of the check in the [AWS Vulnerability Database](https://avd.aquasec.com/). If you are [contributing your check to trivy-policies](../../../../community/contribute/checks/overview.md), you need to generate an ID using `make id` in the [trivy-checks](https://github.com/aquasecurity/trivy-checks) repository. The output of the command will provide you the next free IDs for the different providers in Trivy.
|
||||
|
||||
The ID is based on the AVD_ID. For instance if the `avd_id` is `AVD-AWS-0176`, the ID is `ID0176`.
|
||||
|
||||
#### custom.provider
|
||||
|
||||
The `provider` field references the [provider](https://github.com/aquasecurity/trivy/tree/main/pkg/iac/providers) available in Trivy. This should be the same as the provider name in the `pkg/iac/providers` directory, e.g. `aws`.
|
||||
|
||||
#### custom.service
|
||||
|
||||
Services are defined within a provider. For instance, RDS is a service and AWS is a provider. This should be the same as the service name in one of the provider directories. ([Link](https://github.com/aquasecurity/trivy/tree/main/pkg/iac/providers)), e.g. `aws/rds`.
|
||||
|
||||
#### custom.input
|
||||
|
||||
The `input` tells Trivy what inputs this check should be applied to. Cloud provider checks should always use the `selector` input, and should always use the `type` selector with `cloud`. Check targeting Kubernetes yaml can use `kubenetes`, RBAC can use `rbac`, and so on.
|
||||
|
||||
#### Subtypes in the custom data
|
||||
|
||||
Subtypes currently only need to be defined for cloud providers [as detailed in the documentation.](./selectors.md/#enabling-selectors-and-subtypes)
|
||||
|
||||
#### Scan Result
|
||||
|
||||
Some fields are displayed in scan results.
|
||||
|
||||
@@ -182,7 +203,7 @@ You can specify input format via the `custom.input` annotation.
|
||||
- `dockerfile` (Dockerfile)
|
||||
- `kubernetes` (Kubernetes YAML/JSON)
|
||||
- `rbac` (Kubernetes RBAC YAML/JSON)
|
||||
- `cloud` (Cloud format, as defined by defsec - this is used for Terraform, CloudFormation, and Cloud/AWS scanning)
|
||||
- `cloud` (Cloud format, as defined by Trivy - this is used for Terraform, CloudFormation, and Cloud/AWS scanning)
|
||||
- `yaml` (Generic YAML)
|
||||
- `json` (Generic JSON)
|
||||
- `toml` (Generic TOML)
|
||||
@@ -201,4 +222,4 @@ 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
|
||||
[source-types]: https://github.com/aquasecurity/defsec/blob/418759b4dc97af25f30f32e0bd365be7984003a1/pkg/types/sources.go
|
||||
[source-types]: https://github.com/aquasecurity/trivy/blob/9361cdb7e28fd304d6fd2a1091feac64a6786672/pkg/iac/types/sources.go#L4
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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/trivy-iac/blob/main/pkg/rego/schemas/dockerfile.json)
|
||||
In Trivy we have been able to define a schema for a [Dockerfile](https://github.com/aquasecurity/trivy/tree/main/pkg/iac/rego/schemas)
|
||||
Without input schemas, a policy would be as follows:
|
||||
|
||||
!!! example
|
||||
@@ -36,7 +36,7 @@ schema as such
|
||||
```
|
||||
|
||||
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)
|
||||
can be found [here](https://github.com/aquasecurity/trivy/blob/main/pkg/iac/rego/schemas/dockerfile.json).
|
||||
|
||||
Now if this policy is evaluated against, a more descriptive error will be available to help fix the problem.
|
||||
|
||||
@@ -50,12 +50,12 @@ Now if this policy is evaluated against, a more descriptive error will be availa
|
||||
|
||||
Currently, out of the box the following schemas are supported natively:
|
||||
|
||||
1. [Docker](https://github.com/aquasecurity/trivy-iac/blob/main/pkg/rego/schemas/dockerfile.json)
|
||||
2. [Kubernetes](https://github.com/aquasecurity/trivy-iac/blob/main/pkg/rego/schemas/kubernetes.json)
|
||||
3. [Cloud](https://github.com/aquasecurity/trivy-iac/blob/main/pkg/rego/schemas/cloud.json)
|
||||
1. [Docker](https://github.com/aquasecurity/trivy/blob/main/pkg/iac/rego/schemas/dockerfile.json)
|
||||
2. [Kubernetes](https://github.com/aquasecurity/trivy/blob/main/pkg/iac/rego/schemas/kubernetes.json)
|
||||
3. [Cloud](https://github.com/aquasecurity/trivy/blob/main/pkg/iac/rego/schemas/cloud.json)
|
||||
|
||||
|
||||
## Custom Policies with Custom Schemas
|
||||
## Custom Checks with Custom Schemas
|
||||
|
||||
You can also bring a custom policy that defines one or more custom schema.
|
||||
|
||||
@@ -72,21 +72,21 @@ You can also bring a custom policy that defines one or more custom schema.
|
||||
}
|
||||
```
|
||||
|
||||
The policies can be placed in a structure as follows
|
||||
The checks can be placed in a structure as follows
|
||||
|
||||
!!! example
|
||||
```
|
||||
/Users/user/my-custom-policies
|
||||
/Users/user/my-custom-checks
|
||||
├── my_policy.rego
|
||||
└── schemas
|
||||
└── fooschema.json
|
||||
└── barschema.json
|
||||
```
|
||||
|
||||
To use such a policy with Trivy, use the `--config-policy` flag that points to the policy file or to the directory where the schemas and policies are contained.
|
||||
To use such a policy with Trivy, use the `--config-policy` flag that points to the policy file or to the directory where the schemas and checks are contained.
|
||||
|
||||
```bash
|
||||
$ trivy --config-policy=/Users/user/my-custom-policies <path/to/iac>
|
||||
$ trivy --config-policy=/Users/user/my-custom-checks <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.
|
||||
For more details on how to define schemas within Rego checks, please see the [OPA guide](https://www.openpolicyagent.org/docs/latest/policy-language/#schema-annotations) that describes it in more detail.
|
||||
@@ -1,9 +1,9 @@
|
||||
# Testing
|
||||
It is highly recommended to write tests for your custom policies.
|
||||
It is highly recommended to write tests for your custom checks.
|
||||
|
||||
## Rego testing
|
||||
To help you verify the correctness of your custom policies, OPA gives you a framework that you can use to write tests for your policies.
|
||||
By writing tests for your custom policies you can speed up the development process of new rules and reduce the amount of time it takes to modify rules as requirements evolve.
|
||||
To help you verify the correctness of your custom checks, OPA gives you a framework that you can use to write tests for your checks.
|
||||
By writing tests for your custom checks you can speed up the development process of new rules and reduce the amount of time it takes to modify rules as requirements evolve.
|
||||
|
||||
For more details, see [Policy Testing][opa-testing].
|
||||
|
||||
@@ -22,12 +22,12 @@ For more details, see [Policy Testing][opa-testing].
|
||||
}
|
||||
```
|
||||
|
||||
To write tests for custom policies, you can refer to existing tests under [trivy-policies][trivy-policies].
|
||||
To write tests for custom checks, you can refer to existing tests under [trivy-checks][trivy-checks].
|
||||
|
||||
## Go testing
|
||||
[Fanal][fanal] which is a core library of Trivy can be imported as a Go library.
|
||||
You can scan config files in Go and test your custom policies using Go's testing methods, such as [table-driven tests][table].
|
||||
This allows you to use the actual configuration file as input, making it easy to prepare test data and ensure that your custom policies work in practice.
|
||||
You can scan config files in Go and test your custom checks using Go's testing methods, such as [table-driven tests][table].
|
||||
This allows you to use the actual configuration file as input, making it easy to prepare test data and ensure that your custom checks work in practice.
|
||||
|
||||
In particular, Dockerfile and HCL need to be converted to structural data as input, which may be different from the expected input format.
|
||||
|
||||
@@ -85,6 +85,6 @@ The following example stores allowed and denied configuration files in a directo
|
||||
`Dockerfile.allowed` has one successful result in `Successes`, while `Dockerfile.denied` has one failure result in `Failures`.
|
||||
|
||||
[opa-testing]: https://www.openpolicyagent.org/docs/latest/policy-testing/
|
||||
[defsec]: https://github.com/aquasecurity/trivy-policies/tree/main
|
||||
[defsec]: https://github.com/aquasecurity/trivy-checks/tree/main
|
||||
[table]: https://github.com/golang/go/wiki/TableDrivenTests
|
||||
[fanal]: https://github.com/aquasecurity/fanal
|
||||
@@ -1,12 +1,12 @@
|
||||
# Misconfiguration Scanning
|
||||
Trivy provides built-in policies to detect configuration issues in popular Infrastructure as Code files, such as: Docker, Kubernetes, Terraform, CloudFormation, and more.
|
||||
In addition to built-in policies, you can write your own custom policies, as you can see [here][custom].
|
||||
Trivy provides built-in checks to detect configuration issues in popular Infrastructure as Code files, such as: Docker, Kubernetes, Terraform, CloudFormation, and more.
|
||||
In addition to built-in checks, you can write your own custom checks, as you can see [here][custom].
|
||||
|
||||
## Quick start
|
||||
|
||||
Simply specify a directory containing IaC files such as Terraform, CloudFormation, Azure ARM templates, Helm Charts and Dockerfile.
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ trivy config [YOUR_IaC_DIRECTORY]
|
||||
```
|
||||
|
||||
@@ -94,7 +94,7 @@ In the above example, Trivy detected vulnerabilities of Python dependencies and
|
||||
|
||||
## Type detection
|
||||
The specified directory can contain mixed types of IaC files.
|
||||
Trivy automatically detects config types and applies relevant policies.
|
||||
Trivy automatically detects config types and applies relevant checks.
|
||||
|
||||
For example, the following example holds IaC files for Terraform, CloudFormation, Kubernetes, Helm Charts, and Dockerfile in the same directory.
|
||||
|
||||
@@ -316,16 +316,18 @@ This section describes misconfiguration-specific configuration.
|
||||
Other common options are documented [here](../../configuration/index.md).
|
||||
|
||||
### Enabling a subset of misconfiguration scanners
|
||||
It's possible to only enable certain misconfiguration scanners if you prefer. You can do so by passing the `--misconfig-scanners` option.
|
||||
It's possible to only enable certain misconfiguration scanners if you prefer.
|
||||
You can do so by passing the `--misconfig-scanners` option.
|
||||
This flag takes a comma-separated list of configuration scanner types.
|
||||
|
||||
```bash
|
||||
trivy config --misconfig-scanners=terraform,dockerfile .
|
||||
```
|
||||
|
||||
Will only scan for misconfigurations that pertain to Terraform and Dockerfiles.
|
||||
|
||||
### Pass custom policies
|
||||
You can pass policy files or directories including your custom policies through `--policy` option.
|
||||
### Passing custom checks
|
||||
You can pass policy files or directories including your custom checks through `--policy` option.
|
||||
This can be repeated for specifying multiple files or directories.
|
||||
|
||||
```bash
|
||||
@@ -333,12 +335,12 @@ cd examplex/misconf/
|
||||
trivy conf --policy custom-policy/policy --policy combine/policy --policy policy.rego --namespaces user misconf/mixed
|
||||
```
|
||||
|
||||
For more details, see [Custom Policies](./custom/index.md).
|
||||
For more details, see [Custom Checks](./custom/index.md).
|
||||
|
||||
!!! tip
|
||||
You also need to specify `--namespaces` option.
|
||||
|
||||
### Pass custom data
|
||||
### Passing custom data
|
||||
You can pass directories including your custom data through `--data` option.
|
||||
This can be repeated for specifying multiple directories.
|
||||
|
||||
@@ -349,13 +351,211 @@ trivy conf --policy ./policy --data ./data --namespaces user ./configs
|
||||
|
||||
For more details, see [Custom Data](./custom/data.md).
|
||||
|
||||
### Pass namespaces
|
||||
By default, Trivy evaluates policies defined in `builtin.*`.
|
||||
If you want to evaluate custom policies in other packages, you have to specify package prefixes through `--namespaces` option.
|
||||
### Passing namespaces
|
||||
By default, Trivy evaluates checks defined in `builtin.*`.
|
||||
If you want to evaluate custom checks in other packages, you have to specify package prefixes through `--namespaces` option.
|
||||
This can be repeated for specifying multiple packages.
|
||||
|
||||
``` bash
|
||||
trivy conf --policy ./policy --namespaces main --namespaces user ./configs
|
||||
```
|
||||
|
||||
[custom]: custom/index.md
|
||||
### Private terraform registries
|
||||
Trivy can download terraform code from private registries.
|
||||
To pass credentials you must use the `TF_TOKEN_` environment variables.
|
||||
You cannot use a `.terraformrc` or `terraform.rc` file, these are not supported by trivy yet.
|
||||
|
||||
From the terraform [docs](https://developer.hashicorp.com/terraform/cli/config/config-file#environment-variable-credentials):
|
||||
|
||||
> Environment variable names should have the prefix TF_TOKEN_ added to the domain name, with periods encoded as underscores.
|
||||
> For example, the value of a variable named `TF_TOKEN_app_terraform_io` will be used as a bearer authorization token when the CLI makes service requests to the hostname `app.terraform.io`.
|
||||
>
|
||||
> You must convert domain names containing non-ASCII characters to their punycode equivalent with an ACE prefix.
|
||||
> For example, token credentials for `例えば.com` must be set in a variable called `TF_TOKEN_xn--r8j3dr99h_com`.
|
||||
>
|
||||
> Hyphens are also valid within host names but usually invalid as variable names and may be encoded as double underscores.
|
||||
> For example, you can set a token for the domain name café.fr as TF_TOKEN_xn--caf-dma_fr or TF_TOKEN_xn____caf__dma_fr.
|
||||
|
||||
If multiple variables evaluate to the same hostname, Trivy will choose the environment variable name where the dashes have not been encoded as double underscores.
|
||||
|
||||
|
||||
### Skipping resources by inline comments
|
||||
|
||||
Trivy supports ignoring misconfigured resources by inline comments for Terraform and CloudFormation configuration files only.
|
||||
|
||||
In cases where Trivy can detect comments of a specific format immediately adjacent to resource definitions, it is possible to ignore findings from a single source of resource definition (in contrast to `.trivyignore`, which has a directory-wide scope on all of the files scanned). The format for these comments is `trivy:ignore:<rule>` immediately following the format-specific line-comment [token](https://developer.hashicorp.com/terraform/language/syntax/configuration#comments).
|
||||
|
||||
The ignore rule must contain one of the possible check IDs that can be found in its metadata: ID, short code or alias. The `id` from the metadata is not case-sensitive, so you can specify, for example, `AVD-AWS-0089` or `avd-aws-0089`.
|
||||
|
||||
For example, to ignore a misconfiguration ID `AVD-GCP-0051` in a Terraform HCL file:
|
||||
|
||||
```terraform
|
||||
#trivy:ignore:AVD-GCP-0051
|
||||
resource "google_container_cluster" "example" {
|
||||
name = var.cluster_name
|
||||
location = var.region
|
||||
}
|
||||
```
|
||||
|
||||
You can add multiple ignores on the same comment line:
|
||||
```terraform
|
||||
#trivy:ignore:AVD-GCP-0051 trivy:ignore:AVD-GCP-0053
|
||||
resource "google_container_cluster" "example" {
|
||||
name = var.cluster_name
|
||||
location = var.region
|
||||
}
|
||||
```
|
||||
|
||||
You can also specify a long ID, which is formed as follows: `<provider>-<service>-<short-code>`.
|
||||
|
||||
As an example, consider the following check metadata:
|
||||
|
||||
```yaml
|
||||
# custom:
|
||||
# id: AVD-AWS-0089
|
||||
# avd_id: AVD-AWS-0089
|
||||
# provider: aws
|
||||
# service: s3
|
||||
# severity: LOW
|
||||
# short_code: enable-logging
|
||||
```
|
||||
|
||||
Long ID would look like the following: `aws-s3-enable-logging`.
|
||||
|
||||
Example for CloudFromation:
|
||||
```yaml
|
||||
AWSTemplateFormatVersion: "2010-09-09"
|
||||
Resources:
|
||||
#trivy:ignore:*
|
||||
S3Bucket:
|
||||
Type: 'AWS::S3::Bucket'
|
||||
Properties:
|
||||
BucketName: test-bucket
|
||||
```
|
||||
|
||||
#### Expiration Date
|
||||
|
||||
You can specify the expiration date of the ignore rule in `yyyy-mm-dd` format. This is a useful feature when you want to make sure that an ignored issue is not forgotten and worth revisiting in the future. For example:
|
||||
```tf
|
||||
#trivy:ignore:aws-s3-enable-logging:exp:2024-03-10
|
||||
resource "aws_s3_bucket" "example" {
|
||||
bucket = "test"
|
||||
}
|
||||
```
|
||||
|
||||
The `aws-s3-enable-logging` check will be ignored until `2024-03-10` until the ignore rule expires.
|
||||
|
||||
#### Ignoring by attributes
|
||||
|
||||
You can ignore a resource by its attribute value. This is useful when using the `for-each` meta-argument. For example:
|
||||
|
||||
```tf
|
||||
locals {
|
||||
ports = ["3306", "5432"]
|
||||
}
|
||||
|
||||
#trivy:ignore:aws-ec2-no-public-ingress-sgr[from_port=3306]
|
||||
resource "aws_security_group_rule" "example" {
|
||||
for_each = toset(local.ports)
|
||||
type = "ingress"
|
||||
from_port = each.key
|
||||
to_port = each.key
|
||||
protocol = "TCP"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
security_group_id = aws_security_group.example.id
|
||||
source_security_group_id = aws_security_group.example.id
|
||||
}
|
||||
```
|
||||
|
||||
The `aws-ec2-no-public-ingress-sgr` check will be ignored only for the `aws_security_group_rule` resource with port number `5432`. It is important to note that the ignore rule should not enclose the attribute value in quotes, despite the fact that the port is represented as a string.
|
||||
|
||||
If you want to ignore multiple resources on different attributes, you can specify multiple ignore rules:
|
||||
|
||||
```tf
|
||||
#trivy:ignore:aws-ec2-no-public-ingress-sgr[from_port=3306]
|
||||
#trivy:ignore:aws-ec2-no-public-ingress-sgr[from_port=5432]
|
||||
```
|
||||
|
||||
You can also ignore a resource on multiple attributes:
|
||||
```tf
|
||||
locals {
|
||||
rules = {
|
||||
first = {
|
||||
port = 1000
|
||||
type = "ingress"
|
||||
},
|
||||
second = {
|
||||
port = 1000
|
||||
type = "egress"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#trivy:ignore:aws-ec2-no-public-ingress-sgr[from_port=1000,type=egress]
|
||||
resource "aws_security_group_rule" "example" {
|
||||
for_each = { for k, v in local.rules : k => v }
|
||||
|
||||
type = each.value.type
|
||||
from_port = each.value.port
|
||||
to_port = each.value.port
|
||||
protocol = "TCP"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
security_group_id = aws_security_group.example.id
|
||||
source_security_group_id = aws_security_group.example.id
|
||||
}
|
||||
```
|
||||
|
||||
Checks can also be ignored by nested attributes, but certain restrictions apply:
|
||||
|
||||
- You cannot access an individual block using indexes, for example when working with dynamic blocks.
|
||||
- Special variables like [each](https://developer.hashicorp.com/terraform/language/meta-arguments/for_each#the-each-object) and [count](https://developer.hashicorp.com/terraform/language/meta-arguments/count#the-count-object) cannot be accessed.
|
||||
|
||||
```tf
|
||||
#trivy:ignore:*[logging_config.prefix=myprefix]
|
||||
resource "aws_cloudfront_distribution" "example" {
|
||||
logging_config {
|
||||
include_cookies = false
|
||||
bucket = "mylogs.s3.amazonaws.com"
|
||||
prefix = "myprefix"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Ignoring module issues
|
||||
|
||||
Issues in third-party modules cannot be ignored using the method described above, because you may not have access to modify the module source code. In such a situation you can add ignore rules above the module block, for example:
|
||||
|
||||
```tf
|
||||
#trivy:ignore:aws-s3-enable-logging
|
||||
module "s3_bucket" {
|
||||
source = "terraform-aws-modules/s3-bucket/aws"
|
||||
|
||||
bucket = "my-s3-bucket"
|
||||
}
|
||||
```
|
||||
|
||||
An example of ignoring checks for a specific bucket in a module:
|
||||
```tf
|
||||
locals {
|
||||
bucket = ["test1", "test2"]
|
||||
}
|
||||
|
||||
#trivy:ignore:*[bucket=test1]
|
||||
module "s3_bucket" {
|
||||
for_each = toset(local.bucket)
|
||||
source = "terraform-aws-modules/s3-bucket/aws"
|
||||
bucket = each.value
|
||||
}
|
||||
```
|
||||
|
||||
#### Support for Wildcards
|
||||
|
||||
You can use wildcards in the `ws` (workspace) and `ignore` sections of the ignore rules.
|
||||
|
||||
```tf
|
||||
# trivy:ignore:aws-s3-*:ws:dev-*
|
||||
```
|
||||
|
||||
This example ignores all checks starting with `aws-s3-` for workspaces matching the pattern `dev-*`.
|
||||
|
||||
[custom]: custom/index.md
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
# Built-in Policies
|
||||
|
||||
## Policy Sources
|
||||
Built-in policies are mainly written in [Rego][rego] and Go.
|
||||
Those policies are managed under [trivy-policies repository][trivy-policies].
|
||||
See [here](../../../coverage/iac/index.md) for the list of supported config types.
|
||||
|
||||
For suggestions or issues regarding policy content, please open an issue under the [trivy-policies][trivy-policies] repository.
|
||||
|
||||
## Policy Distribution
|
||||
Trivy 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.
|
||||
|
||||
## 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/
|
||||
|
||||
[kubernetes-policies]: https://github.com/aquasecurity/trivy-policies/tree/main/rules/kubernetes/policies
|
||||
[docker-policies]: https://github.com/aquasecurity/trivy-policies/tree/main/rules/docker/policies
|
||||
[trivy-policies]: https://github.com/aquasecurity/trivy-policies
|
||||
[ghcr]: https://github.com/aquasecurity/trivy-policies/pkgs/container/trivy-policies
|
||||
@@ -91,6 +91,7 @@ See [here](../coverage/language/index.md#supported-languages) for the supported
|
||||
| | [GitHub Advisory Database (npm)][nodejs-ghsa] | ✅ | - |
|
||||
| Java | [GitHub Advisory Database (Maven)][java-ghsa] | ✅ | - |
|
||||
| Go | [GitHub Advisory Database (Go)][go-ghsa] | ✅ | - |
|
||||
| | [Go Vulnerability Database][go-vulndb] | ✅ | - |
|
||||
| Rust | [Open Source Vulnerabilities (crates.io)][rust-osv] | ✅ | - |
|
||||
| .NET | [GitHub Advisory Database (NuGet)][dotnet-ghsa] | ✅ | - |
|
||||
| C/C++ | [GitLab Advisories Community][gitlab] | ✅ | 1 month |
|
||||
@@ -152,6 +153,76 @@ The default is `ghcr.io/aquasecurity/trivy-java-db`.
|
||||
If authentication is required, you need to run `docker login YOUR_REGISTRY`.
|
||||
Currently, specifying a username and password is not supported.
|
||||
|
||||
## Configuration
|
||||
This section describes vulnerability-specific configuration.
|
||||
Other common options are documented [here](../configuration/index.md).
|
||||
|
||||
### Enabling a subset of package types
|
||||
It's possible to only enable certain package types if you prefer.
|
||||
You can do so by passing the `--vuln-type` option.
|
||||
This flag takes a comma-separated list of package types.
|
||||
|
||||
Available values:
|
||||
|
||||
- os
|
||||
- Scan OS packages managed by the OS package manager (e.g. `dpkg`, `yum`, `apk`).
|
||||
- library
|
||||
- Scan language-specific packages (e.g. packages installed by `pip`, `npm`, or `gem`).
|
||||
|
||||
```bash
|
||||
$ trivy image --vuln-type os ruby:2.4.0
|
||||
```
|
||||
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
```bash
|
||||
2019-05-22T19:36:50.530+0200 [34mINFO[0m Updating vulnerability database...
|
||||
2019-05-22T19:36:51.681+0200 [34mINFO[0m Detecting Alpine vulnerabilities...
|
||||
2019-05-22T19:36:51.685+0200 [34mINFO[0m Updating npm Security DB...
|
||||
2019-05-22T19:36:52.389+0200 [34mINFO[0m Detecting npm vulnerabilities...
|
||||
2019-05-22T19:36:52.390+0200 [34mINFO[0m Updating pipenv Security DB...
|
||||
2019-05-22T19:36:53.406+0200 [34mINFO[0m Detecting pipenv vulnerabilities...
|
||||
|
||||
ruby:2.4.0 (debian 8.7)
|
||||
=======================
|
||||
Total: 7 (UNKNOWN: 0, LOW: 1, MEDIUM: 1, HIGH: 3, CRITICAL: 2)
|
||||
|
||||
+---------+------------------+----------+-------------------+---------------+----------------------------------+
|
||||
| LIBRARY | VULNERABILITY ID | 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 |
|
||||
+ +------------------+----------+ +---------------+----------------------------------+
|
||||
| | CVE-2018-16839 | HIGH | | 7.61.1-r1 | curl: Integer overflow leading |
|
||||
| | | | | | to heap-based buffer overflow in |
|
||||
| | | | | | Curl_sasl_create_plain_message() |
|
||||
+---------+------------------+----------+-------------------+---------------+----------------------------------+
|
||||
| git | CVE-2018-17456 | HIGH | 2.15.2-r0 | 2.15.3-r0 | git: arbitrary code execution |
|
||||
| | | | | | via .gitmodules |
|
||||
+ +------------------+ + + +----------------------------------+
|
||||
| | CVE-2018-19486 | | | | git: Improper handling of |
|
||||
| | | | | | PATH allows for commands to be |
|
||||
| | | | | | executed from... |
|
||||
+---------+------------------+----------+-------------------+---------------+----------------------------------+
|
||||
| libssh2 | CVE-2019-3855 | CRITICAL | 1.8.0-r2 | 1.8.1-r0 | libssh2: Integer overflow in |
|
||||
| | | | | | transport read resulting in |
|
||||
| | | | | | out of bounds write... |
|
||||
+---------+------------------+----------+-------------------+---------------+----------------------------------+
|
||||
| sqlite | CVE-2018-20346 | MEDIUM | 3.21.0-r1 | 3.25.3-r0 | CVE-2018-20505 CVE-2018-20506 |
|
||||
| | | | | | sqlite: Multiple flaws in |
|
||||
| | | | | | sqlite which can be triggered |
|
||||
| | | | | | via... |
|
||||
+---------+------------------+----------+-------------------+---------------+----------------------------------+
|
||||
| tar | CVE-2018-20482 | LOW | 1.29-r1 | 1.31-r0 | tar: Infinite read loop in |
|
||||
| | | | | | sparse_dump_region function in |
|
||||
| | | | | | sparse.c |
|
||||
+---------+------------------+----------+-------------------+---------------+----------------------------------+
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
[^1]: https://github.com/GoogleContainerTools/distroless
|
||||
|
||||
[nvd-CVE-2023-0464]: https://nvd.nist.gov/vuln/detail/CVE-2023-0464
|
||||
@@ -185,6 +256,7 @@ Currently, specifying a username and password is not supported.
|
||||
[go-ghsa]: https://github.com/advisories?query=ecosystem%3Ago
|
||||
[swift-ghsa]: https://github.com/advisories?query=ecosystem%3Aswift
|
||||
|
||||
[go-vulndb]: https://pkg.go.dev/vuln/
|
||||
[php]: https://github.com/FriendsOfPHP/security-advisories
|
||||
[ruby]: https://github.com/rubysec/ruby-advisory-db
|
||||
[nodejs]: https://github.com/nodejs/security-wg
|
||||
|
||||
@@ -11,8 +11,6 @@ Currently, Trivy supports the following three formats:
|
||||
- [OpenVEX](https://github.com/openvex/spec)
|
||||
- [CSAF](https://oasis-open.github.io/csaf-documentation/specification.html)
|
||||
|
||||
This is still an experimental implementation, with only minimal functionality added.
|
||||
|
||||
## CycloneDX
|
||||
| Target | Supported |
|
||||
|:---------------:|:---------:|
|
||||
@@ -40,7 +38,7 @@ The following steps are required:
|
||||
### Generate the SBOM
|
||||
You can generate a CycloneDX SBOM with Trivy as follows:
|
||||
|
||||
```shell
|
||||
```bash
|
||||
$ trivy image --format cyclonedx --output debian11.sbom.cdx debian:11
|
||||
```
|
||||
|
||||
@@ -49,7 +47,7 @@ Next, create a VEX based on the generated SBOM.
|
||||
Multiple vulnerability statuses can be defined under `vulnerabilities`.
|
||||
Take a look at the example below.
|
||||
|
||||
```
|
||||
```bash
|
||||
$ cat <<EOF > trivy.vex.cdx
|
||||
{
|
||||
"bomFormat": "CycloneDX",
|
||||
@@ -105,7 +103,7 @@ For more details on CycloneDX VEX and BOM-Link, please refer to the following li
|
||||
### Scan SBOM with VEX
|
||||
Provide the VEX when scanning the CycloneDX SBOM.
|
||||
|
||||
```
|
||||
```bash
|
||||
$ trivy sbom trivy.sbom.cdx --vex trivy.vex.cdx
|
||||
...
|
||||
2023-04-13T12:55:44.838+0300 INFO Filtered out the detected vulnerability {"VEX format": "CycloneDX", "vulnerability-id": "CVE-2020-8911", "status": "not_affected", "justification": "code_not_reachable"}
|
||||
@@ -145,10 +143,10 @@ The following steps are required:
|
||||
|
||||
### Create the VEX document
|
||||
Please see also [the example](https://github.com/openvex/examples).
|
||||
In Trivy, [the Package URL (PURL)][purl] is used as the product identifier.
|
||||
Trivy requires [the Package URL (PURL)][purl] as the product identifier.
|
||||
|
||||
```
|
||||
$ cat <<EOF > debian11.openvex
|
||||
```bash
|
||||
$ cat <<EOF > debian11.openvex.json
|
||||
{
|
||||
"@context": "https://openvex.dev/ns/v0.2.0",
|
||||
"@id": "https://openvex.dev/docs/public/vex-2e67563e128250cbcb3e98930df948dd053e43271d70dc50cfa22d57e03fe96f",
|
||||
@@ -169,19 +167,109 @@ $ cat <<EOF > debian11.openvex
|
||||
EOF
|
||||
```
|
||||
|
||||
In the above example, PURLs, located in `packages.externalRefs.referenceLocator` in SPDX are used for the product identifier.
|
||||
In the above example, PURLs, `pkg:deb/debian/libdb5.3@5.3.28+dfsg1-0.8` are used for the product identifier.
|
||||
You can find PURLs in the JSON report generated by Trivy.
|
||||
This VEX statement is applied if the PURL specified in the VEX matches the PURL found during the scan.
|
||||
See [here](#purl-matching) for more details of PURL matching.
|
||||
|
||||
!!! note
|
||||
If a qualifier is specified in the PURL used as the product id in the VEX, the qualifier is compared.
|
||||
Other qualifiers are ignored in the comparison.
|
||||
`pkg:deb/debian/curl@7.50.3-1` in OpenVEX matches `pkg:deb/debian/curl@7.50.3-1?arch=i386`,
|
||||
while `pkg:deb/debian/curl@7.50.3-1?arch=amd64` does not match `pkg:deb/debian/curl@7.50.3-1?arch=i386`.
|
||||
Trivy also supports [OpenVEX subcomponents][openvex-subcomponent], which allow for more precise specification of the scope of a VEX statement, reducing the risk of incorrect filtering.
|
||||
Let's say you want to suppress vulnerabilities within a container image.
|
||||
If you only specify the PURL of the container image as the product, the resulting VEX would look like this:
|
||||
|
||||
<details>
|
||||
<summary>OpenVEX products only</summary>
|
||||
|
||||
```json
|
||||
"statements": [
|
||||
{
|
||||
"vulnerability": {"name": "CVE-2024-32002"},
|
||||
"products": [
|
||||
{"@id": "pkg:oci/trivy?repository_url=ghcr.io%2Faquasecurity%2Ftrivy"}
|
||||
],
|
||||
"status": "not_affected",
|
||||
"justification": "vulnerable_code_not_in_execute_path"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
However, this approach would suppress all instances of CVE-2024-32002 within the container image.
|
||||
If the intention is to declare that the `git` package distributed by Alpine Linux within this image is not affected, subcomponents can be utilized as follows:
|
||||
|
||||
<details>
|
||||
<summary>OpenVEX subcomponents</summary>
|
||||
|
||||
```json
|
||||
"statements": [
|
||||
{
|
||||
"vulnerability": {"name": "CVE-2024-32002"},
|
||||
"products": [
|
||||
{
|
||||
"@id": "pkg:oci/trivy?repository_url=ghcr.io%2Faquasecurity%2Ftrivy",
|
||||
"subcomponents": [
|
||||
{"@id": "pkg:apk/alpine/git"}
|
||||
]
|
||||
}
|
||||
],
|
||||
"status": "not_affected",
|
||||
"justification": "vulnerable_code_not_in_execute_path"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
By declaring the subcomponent in this manner, Trivy will filter the results, considering only the `git` package within the `ghcr.io/aquasecurity/trivy` container image as not affected.
|
||||
Omitting the version in the PURL applies the statement to all versions of the package.
|
||||
More details about PURL matching can be found [here](#purl-matching).
|
||||
|
||||
Furthermore, the product specified in a VEX statement does not necessarily need to be the target of the scan.
|
||||
It is possible to specify a component that is included in the scan target as the product.
|
||||
For example, you can designate a specific Go project as the product and its dependent modules as subcomponents.
|
||||
|
||||
In the following example, the VEX statement declares that the `github.com/docker/docker` module, which is a dependency of the `github.com/aquasecurity/trivy` Go project, is not affected by CVE-2024-29018.
|
||||
|
||||
<details>
|
||||
<summary>OpenVEX intermediate components</summary>
|
||||
|
||||
```json
|
||||
"statements": [
|
||||
{
|
||||
"vulnerability": {"name": "CVE-2024-29018"},
|
||||
"products": [
|
||||
{
|
||||
"@id": "pkg:golang/github.com/aquasecurity/trivy",
|
||||
"subcomponents": [
|
||||
{ "@id": "pkg:golang/github.com/docker/docker" }
|
||||
]
|
||||
}
|
||||
],
|
||||
"status": "not_affected",
|
||||
"justification": "vulnerable_code_not_in_execute_path"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
This VEX document can be used when scanning a container image as well as other targets.
|
||||
The VEX statement will be applied when Trivy finds the Go binary within the container image.
|
||||
|
||||
```bash
|
||||
$ trivy image ghcr.io/aquasecurity/trivy:0.50.0 --vex trivy.openvex.json
|
||||
```
|
||||
|
||||
VEX documents can indeed be reused across different container images, eliminating the need to issue separate VEX documents for each image.
|
||||
This is particularly useful when there is a common component or library that is used across multiple projects or container images.
|
||||
|
||||
You can see [the appendix](#applying-vex-to-dependency-trees) for more details on how VEX is applied in Trivy.
|
||||
|
||||
### Scan with VEX
|
||||
Provide the VEX when scanning your target.
|
||||
|
||||
```
|
||||
$ trivy image debian:11 --vex debian11.openvex
|
||||
```bash
|
||||
$ trivy image debian:11 --vex debian11.openvex.json
|
||||
...
|
||||
2023-04-26T17:56:05.358+0300 INFO Filtered out the detected vulnerability {"VEX format": "OpenVEX", "vulnerability-id": "CVE-2019-8457", "status": "not_affected", "justification": "vulnerable_code_not_in_execute_path"}
|
||||
|
||||
@@ -215,7 +303,10 @@ The following steps are required:
|
||||
### Create the CSAF document
|
||||
Create a CSAF document in JSON format as follows:
|
||||
|
||||
```
|
||||
<details>
|
||||
<summary>CSAF VEX</summary>
|
||||
|
||||
```bash
|
||||
$ cat <<EOF > debian11.vex.csaf
|
||||
{
|
||||
"document": {
|
||||
@@ -313,10 +404,22 @@ $ cat <<EOF > debian11.vex.csaf
|
||||
EOF
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
Trivy also supports [CSAF relationships][csaf-relationship], reducing the risk of incorrect filtering.
|
||||
It works in the same way as OpenVEX subcomponents.
|
||||
At present, the specified relationship category is not taken into account and all the following categories are treated internally as "depends_on".
|
||||
|
||||
- default_component_of
|
||||
- installed_on
|
||||
- installed_with
|
||||
|
||||
You can see [the appendix](#applying-vex-to-dependency-trees) for more details on how VEX is applied in Trivy.
|
||||
|
||||
### Scan with CSAF VEX
|
||||
Provide the CSAF document when scanning your target.
|
||||
|
||||
```console
|
||||
```bash
|
||||
$ trivy image debian:11 --vex debian11.vex.csaf
|
||||
...
|
||||
2024-01-02T10:28:26.704+0100 INFO Filtered out the detected vulnerability {"VEX format": "CSAF", "vulnerability-id": "CVE-2019-8457", "status": "not_affected"}
|
||||
@@ -371,8 +474,108 @@ does not match:
|
||||
- `pkg:maven/com.google.guava/guava@24.1.1?classifier=sources`
|
||||
- `classifier` must have the same value.
|
||||
|
||||
### Applying VEX to Dependency Trees
|
||||
|
||||
Trivy internally generates a dependency tree and applies VEX statements to this graph.
|
||||
Let's consider a project with the following dependency tree, where `Module C v2.0.0` is assumed to have a vulnerability CVE-XXXX-YYYY:
|
||||
|
||||
```mermaid
|
||||
graph TD;
|
||||
modRootA(Module Root A v1.0.0)
|
||||
modB(Module B v1.0.0)
|
||||
modC(Module C v2.0.0)
|
||||
|
||||
modRootA-->modB
|
||||
modB-->modC
|
||||
```
|
||||
|
||||
Now, suppose a VEX statement is issued for `Module B` as follows:
|
||||
|
||||
```json
|
||||
"statements": [
|
||||
{
|
||||
"vulnerability": {"name": "CVE-XXXX-YYYY"},
|
||||
"products": [
|
||||
{
|
||||
"@id": "pkg:golang/module-b@1.0.0",
|
||||
"subcomponents": [
|
||||
{ "@id": "pkg:golang/module-c@2.0.0" }
|
||||
]
|
||||
}
|
||||
],
|
||||
"status": "not_affected",
|
||||
"justification": "vulnerable_code_not_in_execute_path"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
It declares that `Module B` is not affected by CVE-XXXX-YYYY on `Module C`.
|
||||
|
||||
!!! note
|
||||
The VEX in this example defines the relationship between `Module B` and `Module C`.
|
||||
However, as Trivy traverses all parents from vulnerable packages, it is also possible to define a VEX for the relationship between a vulnerable package and any parent, such as `Module A` and `Module C`, etc.
|
||||
|
||||
Mapping this VEX onto the dependency tree would look like this:
|
||||
|
||||
```mermaid
|
||||
graph TD;
|
||||
modRootA(Module Root A v1.0.0)
|
||||
|
||||
subgraph "VEX (Not Affected)"
|
||||
modB(Module B v1.0.0)
|
||||
modC(Module C v2.0.0)
|
||||
end
|
||||
|
||||
modRootA-->modB
|
||||
modB-->modC
|
||||
```
|
||||
|
||||
In this case, it's clear that `Module Root A` is also not affected by CVE-XXXX-YYYY, so this vulnerability is suppressed.
|
||||
|
||||
Now, let's consider another project:
|
||||
|
||||
```mermaid
|
||||
graph TD;
|
||||
modRootZ(Module Root Z v1.0.0)
|
||||
modB'(Module B v1.0.0)
|
||||
modC'(Module C v2.0.0)
|
||||
modD'(Module D v3.0.0)
|
||||
|
||||
modRootZ-->modB'
|
||||
modRootZ-->modD'
|
||||
modB'-->modC'
|
||||
modD'-->modC'
|
||||
```
|
||||
|
||||
Assuming the same VEX as before, applying it to this dependency tree would look like:
|
||||
|
||||
```mermaid
|
||||
graph TD;
|
||||
modRootZ(Module Root Z v1.0.0)
|
||||
|
||||
subgraph "VEX (Not Affected)"
|
||||
modB'(Module B v1.0.0)
|
||||
modC'(Module C v2.0.0)
|
||||
end
|
||||
|
||||
modD'(Module D v3.0.0)
|
||||
|
||||
modRootZ-->modB'
|
||||
modRootZ-->modD'
|
||||
modB'-->modC'
|
||||
modD'-->modC'
|
||||
```
|
||||
|
||||
`Module Root Z` depends on `Module C` via multiple paths.
|
||||
While the VEX tells us that `Module B` is not affected by the vulnerability, `Module D` might be.
|
||||
In the absence of a VEX, the default assumption is that it is affected.
|
||||
Taking all of this into account, Trivy determines that `Module Root Z` is affected by this vulnerability.
|
||||
|
||||
|
||||
[csaf]: https://oasis-open.github.io/csaf-documentation/specification.html
|
||||
[openvex]: https://github.com/openvex/spec
|
||||
[purl]: https://github.com/package-url/purl-spec
|
||||
[purl-matching]: https://github.com/openvex/spec/issues/27
|
||||
|
||||
[openvex-subcomponent]: https://github.com/openvex/spec/blob/main/OPENVEX-SPEC.md#subcomponent
|
||||
[csaf-relationship]: https://docs.oasis-open.org/csaf/csaf/v2.0/os/csaf-v2.0-os.html#3224-product-tree-property---relationships
|
||||
@@ -99,11 +99,11 @@ If you want to force the cache to be refreshed with the latest data, you can use
|
||||
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
|
||||
## Custom Checks
|
||||
|
||||
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](../scanner/misconfiguration/custom/index.md) page for more information on how to write custom policies.
|
||||
You can write custom checks for Trivy to evaluate against your AWS account.
|
||||
These checks 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 Checks](../scanner/misconfiguration/custom/index.md) page for more information on how to write custom checks.
|
||||
|
||||
Custom policies in cloud scanning also support passing in custom data. This can be useful when you want to selectively enable/disable certain aspects of your cloud policies.
|
||||
See the [Custom Data](../scanner/misconfiguration/custom/data.md) page for more information on how to provide custom data to custom policies.
|
||||
Custom checks in cloud scanning also support passing in custom data. This can be useful when you want to selectively enable/disable certain aspects of your cloud checks.
|
||||
See the [Custom Data](../scanner/misconfiguration/custom/data.md) page for more information on how to provide custom data to custom checks.
|
||||
|
||||
@@ -107,10 +107,10 @@ The image config is converted into Dockerfile and Trivy handles it as Dockerfile
|
||||
See [here](../scanner/misconfiguration/index.md) for the detail of Dockerfile scanning.
|
||||
|
||||
It is disabled by default.
|
||||
You can enable it with `--image-config-scanners config`.
|
||||
You can enable it with `--image-config-scanners misconfig`.
|
||||
|
||||
```
|
||||
$ trivy image --image-config-scanners config [YOUR_IMAGE_NAME]
|
||||
$ trivy image --image-config-scanners misconfig [YOUR_IMAGE_NAME]
|
||||
```
|
||||
|
||||
<details>
|
||||
@@ -500,3 +500,10 @@ You can configure Docker daemon socket with `DOCKER_HOST` or `--docker-host`.
|
||||
```shell
|
||||
$ trivy image --docker-host tcp://127.0.0.1:2375 YOUR_IMAGE
|
||||
```
|
||||
|
||||
### Configure Podman daemon socket to connect to.
|
||||
You can configure Podman daemon socket with `--podman-host`.
|
||||
|
||||
```shell
|
||||
$ trivy image --podman-host /run/user/1000/podman/podman.sock YOUR_IMAGE
|
||||
```
|
||||
|
||||
@@ -9,7 +9,7 @@ Trivy can also be installed *inside* your cluster as a Kubernetes Operator, and
|
||||
When scanning a Kubernetes cluster, Trivy differentiates between the following:
|
||||
|
||||
1. Cluster infrastructure (e.g api-server, kubelet, addons)
|
||||
1. Cluster configuration (e.g Roles, ClusterRoles).
|
||||
1. Cluster configuration (e.g Roles, ClusterRoles).
|
||||
1. Application workloads (e.g nginx, postgresql).
|
||||
|
||||
When scanning any of the above, the container image is scanned separately to the Kubernetes resource definition (the YAML manifest) that defines the resource.
|
||||
@@ -28,60 +28,79 @@ Kubernetes resource definition is scanned for:
|
||||
|
||||
## Kubernetes target configurations
|
||||
|
||||
Trivy follows the behavior of the `kubectl` tool as much as possible.
|
||||
|
||||
### Scope
|
||||
|
||||
The command expects an argument that selects the scope of the scan (similarly to how `kubectl` expects an argument after `kubectl get`). This argument can be:
|
||||
1. A Kubernetes Kind. e.g `pod`, `deployment`, etc.
|
||||
2. A Kubernetes Resource. e.g `pods/mypod`, etc.
|
||||
3. `all`. Scan common workload kinds, as listed [here](https://github.com/aquasecurity/trivy-kubernetes/blob/bf8cc2a00d9772e0aa271f06d375b936152b54b1/pkg/k8s/k8s.go#L296:L314)
|
||||
4. `cluster` scan the entire cluster including all namespaced resources and cluster level resources.
|
||||
|
||||
Examples:
|
||||
|
||||
```
|
||||
trivy k8s all
|
||||
trivy k8s pods
|
||||
trivy k8s deploy myapp
|
||||
trivy k8s pod/mypod
|
||||
trivy k8s pods,deploy
|
||||
trivy k8s cluster
|
||||
```sh
|
||||
trivy k8s [flags] [CONTEXT] - if the target name [CONTEXT] is not specified, the default will be used.
|
||||
```
|
||||
|
||||
Note that the scope argument must appear last in the command line, after any other flag.
|
||||
for example:
|
||||
|
||||
### Cluster
|
||||
```sh
|
||||
trivy k8s --report summary
|
||||
```
|
||||
|
||||
By default Trivy will look for a [`kubeconfig` configuration file in the default location](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/), and use the default cluster that is specified.
|
||||
You can also specify a `kubeconfig` using the `--kubeconfig` flag:
|
||||
|
||||
```
|
||||
```sh
|
||||
trivy k8s --kubeconfig ~/.kube/config2
|
||||
```
|
||||
|
||||
### Namespace
|
||||
By default, all cluster resource images will be downloaded and scanned.
|
||||
|
||||
By default Trivy will scan all namespaces (following `kubectl` behavior). To specify a namespace use the `--namespace` flag:
|
||||
### Skip-images
|
||||
|
||||
You can control whether Trivy will scan and download the cluster resource images. To disable this feature, add the --skip-images flag.
|
||||
|
||||
- `--skip-images` flag will prevent the downloading and scanning of images (including vulnerabilities and secrets) in the cluster resources.
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
trivy k8s --report summary --skip-images
|
||||
```
|
||||
trivy k8s --kubeconfig ~/.kube/config2 --namespace default
|
||||
```
|
||||
### Node
|
||||
|
||||
You can exclude specific nodes from the scan using the `--exclude-nodes` flag, which takes a label in the format `label-name:label-value` and excludes all matching nodes:
|
||||
### Include/Exclude Kinds
|
||||
|
||||
You can control which kinds of resources will be discovered using the `--include-kinds` or `--exclude-kinds` comma-separated flags:
|
||||
|
||||
***Note:*** Both flags (`--include-kinds` or `--exclude-kinds`) cannot be set in conjunction.
|
||||
|
||||
- `--include-kinds` will include the listed kinds in cluster scanning.
|
||||
- `--exclude-kinds` will exclude the listed kinds from cluster scanning.
|
||||
|
||||
By default, all kinds will be included in cluster scanning.
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
trivy k8s --report summary --exclude-kinds node,pod
|
||||
```
|
||||
trivy k8s cluster --report summary --exclude-nodes kubernetes.io/arch:arm6
|
||||
|
||||
### Include/Exclude Namespaces
|
||||
|
||||
You can control which namespaces will be discovered using the `--include-namespaces` or `--exclude-namespaces` comma-separated flags:
|
||||
|
||||
***Note:*** Both flags (`--include-namespaces` or `--exclude-namespaces`) cannot be set in conjunction.
|
||||
|
||||
- `--include-namespaces` will include the listed namespaces in cluster scanning.
|
||||
- `--exclude-namespaces` will exclude the listed namespaces from cluster scanning.
|
||||
|
||||
By default, all namespaces will be included in cluster scanning.
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
trivy k8s --report summary --exclude-namespace dev-system,staging-system
|
||||
```
|
||||
|
||||
## Control Plane and Node Components Vulnerability Scanning
|
||||
|
||||
Trivy is capable of discovering Kubernetes control plane (apiserver, controller-manager and etc) and node components(kubelet, kube-proxy and etc), matching them against the [official Kubernetes vulnerability database feed](https://github.com/aquasecurity/vuln-list-k8s), and reporting any vulnerabilities it finds
|
||||
Trivy is capable of discovering Kubernetes control plane (apiserver, controller-manager and etc) and node components(kubelet, kube-proxy and etc), matching them against the [official Kubernetes vulnerability database feed](https://github.com/aquasecurity/vuln-list-k8s), and reporting any vulnerabilities it finds.
|
||||
|
||||
To read more about KBOM, see the [documentation for Kubernetes scanning](./sbom.md#kbom).
|
||||
|
||||
```
|
||||
trivy k8s cluster --scanners vuln --report all
|
||||
```sh
|
||||
trivy k8s --scanners vuln --report all
|
||||
|
||||
NodeComponents/kind-control-plane (kubernetes)
|
||||
|
||||
@@ -101,13 +120,43 @@ Total: 3 (UNKNOWN: 0, LOW: 1, MEDIUM: 0, HIGH: 2, CRITICAL: 0)
|
||||
└────────────────┴────────────────┴──────────┴────────┴───────────────────┴──────────────────────────────────┴───────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Node-Collector
|
||||
|
||||
### Components types
|
||||
Node-collector is a scan job that collects node configuration parameters and permission information. This information will be evaluated against Kubernetes hardening (e.g. CIS benchmark) and best practices values. The scan results will be output in infrastructure assessment and CIS benchmark compliance reports.
|
||||
|
||||
You can control what kinds of components are discovered using the `--components` flag:
|
||||
- `--components infra` will discover only cluster infrastructure components.
|
||||
- `--components workloads` will discover only application workloads.
|
||||
- If the flag is omitted: infra, workloads, and RBAC are discovered.
|
||||
### Disable Node Collector
|
||||
|
||||
You can control whether the node scan-job (`node-collector`) will run in the cluster. To disable it, add the `--disable-node-collector` flag
|
||||
|
||||
- `--disable-node-collector` This flag will exclude findings related to Node (infra assessment) misconfigurations
|
||||
|
||||
By default, the node scan-job (`node-collector`) will run in the cluster.
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
trivy k8s --report summary --disable-node-collector
|
||||
```
|
||||
|
||||
### Taints and Tolerations
|
||||
|
||||
The node-collector scan-job will run on every node. In case the node has been tainted, it is possible to add toleration to the scan job for it to be scheduled on the tainted node. for more details [see k8s docs](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
|
||||
|
||||
- `--tolerations key1=value1:NoExecute,key2=value2:NoSchedule` this flag wil enable node-collector to be schedule on tainted Node
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
trivy k8s --report summary --tolerations key1=value1:NoExecute,key2=value2:NoSchedule
|
||||
```
|
||||
|
||||
### Exclude Nodes by Label
|
||||
|
||||
You can exclude specific nodes from the scan using the `--exclude-nodes` flag, which takes a label in the format `label-name:label-value` and excludes all matching nodes:
|
||||
|
||||
```sh
|
||||
trivy k8s --report summary --exclude-nodes kubernetes.io/arch:arm6
|
||||
```
|
||||
|
||||
## Reporting and filtering
|
||||
|
||||
@@ -117,8 +166,8 @@ You can always choose the report granularity using the `--report summary`/`--rep
|
||||
|
||||
Scan a full cluster and generate a simple summary report:
|
||||
|
||||
```
|
||||
$ trivy k8s --report=summary cluster
|
||||
```sh
|
||||
trivy k8s --report=summary
|
||||
```
|
||||
|
||||

|
||||
@@ -126,15 +175,15 @@ $ trivy k8s --report=summary cluster
|
||||
Filter by severity:
|
||||
|
||||
```
|
||||
trivy k8s --severity=CRITICAL --report=all cluster
|
||||
trivy k8s --severity=CRITICAL --report=all
|
||||
```
|
||||
|
||||
Filter by scanners (Vulnerabilities, Secrets or Misconfigurations):
|
||||
|
||||
```
|
||||
trivy k8s --scanners=secret --report=summary cluster
|
||||
trivy k8s --scanners=secret --report=summary
|
||||
# or
|
||||
trivy k8s --scanners=misconfig --report=summary cluster
|
||||
trivy k8s --scanners=misconfig --report=summary
|
||||
```
|
||||
|
||||
The supported output formats are `table`, which is the default, and `json`.
|
||||
@@ -300,6 +349,7 @@ trivy k8s --format json -o results.json cluster
|
||||
</details>
|
||||
|
||||
## 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).
|
||||
|
||||
@@ -318,7 +368,7 @@ Scan the cluster for Kubernetes Pod Security Standards Baseline compliance:
|
||||
|
||||
```
|
||||
|
||||
$ trivy k8s cluster --compliance=k8s-pss-baseline --report summary
|
||||
trivy k8s --compliance=k8s-pss-baseline --report summary
|
||||
|
||||
```
|
||||
|
||||
@@ -326,7 +376,7 @@ Get the detailed report for checks:
|
||||
|
||||
```
|
||||
|
||||
$ trivy k8s cluster --compliance=k8s-cis --report all
|
||||
trivy k8s --compliance=k8s-cis --report all
|
||||
|
||||
```
|
||||
|
||||
@@ -334,7 +384,7 @@ Get summary report in JSON format:
|
||||
|
||||
```
|
||||
|
||||
$ trivy k8s cluster --compliance=k8s-cis --report summary --format json
|
||||
trivy k8s --compliance=k8s-cis --report summary --format json
|
||||
|
||||
```
|
||||
|
||||
@@ -342,7 +392,7 @@ Get detailed report in JSON format:
|
||||
|
||||
```
|
||||
|
||||
$ trivy k8s cluster --compliance=k8s-cis --report all --format json
|
||||
trivy k8s --compliance=k8s-cis --report all --format json
|
||||
|
||||
```
|
||||
|
||||
@@ -355,7 +405,7 @@ Trivy can generate KBOM in CycloneDX format:
|
||||
|
||||
```sh
|
||||
|
||||
$ trivy k8s cluster --format cyclonedx --output mykbom.cdx.json
|
||||
trivy k8s --format cyclonedx --output mykbom.cdx.json
|
||||
|
||||
```
|
||||
|
||||
@@ -363,7 +413,7 @@ Trivy can also scan that generated KBOM (or any SBOM) for vulnerabilities:
|
||||
|
||||
```sh
|
||||
|
||||
$ trivy sbom mykbom.cdx.json
|
||||
trivy sbom mykbom.cdx.json
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# SBOM scanning
|
||||
|
||||
Trivy can take the following SBOM formats as an input and scan for vulnerabilities.
|
||||
Trivy can take the following SBOM formats as an input and scan for vulnerabilities and licenses.
|
||||
|
||||
- CycloneDX
|
||||
- SPDX
|
||||
@@ -17,6 +17,9 @@ $ trivy sbom /path/to/sbom_file
|
||||
|
||||
```
|
||||
|
||||
By default, vulnerability scan in SBOM is executed. You can use `--scanners vuln,license`
|
||||
command property to select also license scan, or `--scanners license` alone.
|
||||
|
||||
!!! 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.
|
||||
@@ -117,6 +120,11 @@ Total: 2 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 2)
|
||||
|
||||
To read more about KBOM, see the [documentation for Kubernetes scanning](./kubernetes.md#KBOM).
|
||||
|
||||
The supported Kubernetes distributions for core components vulnerability scanning are:
|
||||
|
||||
- [Kubernetes upstream](https://github.com/kubernetes/kubernetes)
|
||||
- [Rancher rke2](https://github.com/rancher/rke2)
|
||||
|
||||
```sh
|
||||
|
||||
$ trivy k8s --format cyclonedx cluster -o kbom.json
|
||||
|
||||
@@ -79,3 +79,11 @@ You can use Trivy Resource in Concourse for scanning containers and introducing
|
||||
It has capabilities to fail the pipeline, create issues, alert communication channels (using respective resources) based on Trivy scan output.
|
||||
|
||||
👉 Get it at: <https://github.com/Comcast/trivy-resource/>
|
||||
|
||||
|
||||
## SecObserve GitHub actions and GitLab templates (Community)
|
||||
[SecObserve GitHub actions and GitLab templates](https://github.com/MaibornWolff/secobserve_actions_templates) run various vulnerability scanners, providing uniform methods and parameters for launching the tools.
|
||||
|
||||
The Trivy integration supports scanning Docker images and local filesystems for vulnerabilities as well as scanning IaC files for misconfigurations.
|
||||
|
||||
👉 Get it at: <https://github.com/MaibornWolff/secobserve_actions_templates>
|
||||
|
||||
@@ -1,21 +1,32 @@
|
||||
# Reporting
|
||||
|
||||
## 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>
|
||||
|
||||
## DefectDojo (Community)
|
||||
DefectDojo can parse Trivy JSON reports. The parser supports deduplication and auto-close features.
|
||||
|
||||
👉 Get it at: <https://github.com/DefectDojo/django-DefectDojo>
|
||||
|
||||
## SecObserve (Community)
|
||||
SecObserve can parse Trivy results as CycloneDX reports and provides an unified overview of vulnerabilities from different sources. Vulnerabilities can be evaluated with manual and rule based assessments.
|
||||
|
||||
👉 Get it at: <https://github.com/MaibornWolff/SecObserve>
|
||||
|
||||
## Scan2html (Community)
|
||||
A Trivy plugin that scans and outputs the results to an interactive html file.
|
||||
|
||||
👉 Get it at: <https://github.com/fatihtokus/scan2html>
|
||||
|
||||
## 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>
|
||||
|
||||
## Trivy-Streamlit (Community)
|
||||
Trivy-Streamlit is a Streamlit application that allows you to quickly parse the results from a Trivy JSON report.
|
||||
|
||||
👉 Get it at: <https://github.com/mfreeman451/trivy-streamlit>
|
||||
|
||||
## Trivy-Vulnerability-Explorer (Community)
|
||||
|
||||
This project is a web application that allows to load a Trivy report in json format and displays the vulnerabilities of a single target in an interactive data table.
|
||||
|
||||
👉 Get it at: <https://github.com/dbsystel/trivy-vulnerability-explorer>
|
||||
|
||||
@@ -10,11 +10,10 @@ In this section you will find an aggregation of the different ways to install Tr
|
||||
Add repository setting to `/etc/yum.repos.d`.
|
||||
|
||||
``` bash
|
||||
RELEASE_VERSION=$(grep -Po '(?<=VERSION_ID=")[0-9]' /etc/os-release)
|
||||
cat << EOF | sudo tee -a /etc/yum.repos.d/trivy.repo
|
||||
[trivy]
|
||||
name=Trivy repository
|
||||
baseurl=https://aquasecurity.github.io/trivy-repo/rpm/releases/$RELEASE_VERSION/\$basearch/
|
||||
baseurl=https://aquasecurity.github.io/trivy-repo/rpm/releases/\$basearch/
|
||||
gpgcheck=1
|
||||
enabled=1
|
||||
gpgkey=https://aquasecurity.github.io/trivy-repo/rpm/public.key
|
||||
@@ -35,9 +34,9 @@ In this section you will find an aggregation of the different ways to install Tr
|
||||
Add repository setting to `/etc/apt/sources.list.d`.
|
||||
|
||||
``` bash
|
||||
sudo apt-get install wget apt-transport-https gnupg lsb-release
|
||||
sudo apt-get install wget apt-transport-https gnupg
|
||||
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | gpg --dearmor | sudo tee /usr/share/keyrings/trivy.gpg > /dev/null
|
||||
echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
|
||||
echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb generic main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
|
||||
sudo apt-get update
|
||||
sudo apt-get install trivy
|
||||
```
|
||||
@@ -86,31 +85,79 @@ References:
|
||||
Nix package manager for Linux and MacOS.
|
||||
|
||||
=== "Command line"
|
||||
|
||||
`nix-env --install -A nixpkgs.trivy`
|
||||
`nix-env --install -A nixpkgs.trivy`
|
||||
|
||||
=== "Configuration"
|
||||
|
||||
```nix
|
||||
# your other config ...
|
||||
environment.systemPackages = with pkgs; [
|
||||
# your other packages ...
|
||||
trivy
|
||||
];
|
||||
```
|
||||
```nix
|
||||
# your other config ...
|
||||
environment.systemPackages = with pkgs; [
|
||||
# your other packages ...
|
||||
trivy
|
||||
];
|
||||
```
|
||||
|
||||
=== "Home Manager"
|
||||
|
||||
```nix
|
||||
# your other config ...
|
||||
home.packages = with pkgs; [
|
||||
# your other packages ...
|
||||
trivy
|
||||
];
|
||||
```
|
||||
```nix
|
||||
# your other config ...
|
||||
home.packages = with pkgs; [
|
||||
# your other packages ...
|
||||
trivy
|
||||
];
|
||||
```
|
||||
|
||||
References:
|
||||
- <https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/admin/trivy/default.nix>
|
||||
|
||||
- https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/admin/trivy/default.nix
|
||||
|
||||
### FreeBSD (Official)
|
||||
|
||||
[Pkg](https://freebsd.org) for FreeBSD.
|
||||
|
||||
```bash
|
||||
pkg install trivy
|
||||
```
|
||||
|
||||
### asdf/mise (Community)
|
||||
|
||||
[asdf](https://github.com/asdf-vm/asdf) and [mise](https://github.com/jdx/mise) are quite similar tools you can use to install trivy.
|
||||
See their respective documentation for more information of how to install them and use them:
|
||||
|
||||
- [asdf](https://asdf-vm.com/guide/getting-started.html)
|
||||
- [mise](https://mise.jdx.dev/getting-started.html)
|
||||
|
||||
The plugin used by both tools is developped [here](https://github.com/zufardhiyaulhaq/asdf-trivy)
|
||||
|
||||
|
||||
=== "asdf"
|
||||
A basic global installation is shown below, for specific version or/and local version to a directory see "asdf" documentation.
|
||||
|
||||
```shell
|
||||
# Install plugin
|
||||
asdf plugin add trivy https://github.com/zufardhiyaulhaq/asdf-trivy.git
|
||||
|
||||
# Install latest version
|
||||
asdf install trivy latest
|
||||
|
||||
# Set a version globally (on your ~/.tool-versions file)
|
||||
asdf global trivy latest
|
||||
|
||||
# Now trivy commands are available
|
||||
trivy --version
|
||||
```
|
||||
|
||||
=== "mise"
|
||||
A basic global installation is shown below, for specific version or/and local version to a directory see "mise" documentation.
|
||||
|
||||
``` shell
|
||||
# Install plugin and install latest version
|
||||
mise install trivy@latest
|
||||
|
||||
# Set a version globally (on your ~/.tool-versions file)
|
||||
mise use -g trivy@latest
|
||||
|
||||
# Now trivy commands are available
|
||||
trivy --version
|
||||
```
|
||||
|
||||
## Install from GitHub Release (Official)
|
||||
|
||||
|
||||
BIN
docs/imgs/eks-benchmarks.png
Normal file
BIN
docs/imgs/eks-benchmarks.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 84 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 397 KiB After Width: | Height: | Size: 330 KiB |
@@ -16,7 +16,7 @@ Below is a list of additional resources from the community.
|
||||
## Misconfiguration Scanning
|
||||
|
||||
- [Identifying Misconfigurations in your Terraform](https://youtu.be/cps1V5fOHtE)
|
||||
- [How to write custom policies for Trivy](https://blog.ediri.io/how-to-write-custom-policies-for-trivy)
|
||||
- [How to write custom checks for Trivy](https://blog.ediri.io/how-to-write-custom-policies-for-trivy)
|
||||
|
||||
## SBOM, Attestation & related
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ trivy:
|
||||
# Build image
|
||||
- docker build -t $IMAGE .
|
||||
# Build report
|
||||
- ./trivy image --exit-code 0 --format template --template "@contrib/gitlab.tpl" -o gl-container-scanning-report.json $IMAGE
|
||||
- ./trivy image --exit-code 0 --format template --template "@/contrib/gitlab.tpl" -o gl-container-scanning-report.json $IMAGE
|
||||
# Print report
|
||||
- ./trivy image --exit-code 0 --severity HIGH $IMAGE
|
||||
# Fail on severe vulnerabilities
|
||||
@@ -49,7 +49,7 @@ trivy:
|
||||
cache:
|
||||
paths:
|
||||
- .trivycache/
|
||||
# Enables https://docs.gitlab.com/ee/user/application_security/container_scanning/ (Container Scanning report is available on GitLab EE Ultimate or GitLab.com Gold)
|
||||
# Enables https://docs.gitlab.com/ee/user/application_security/container_scanning/ (Container Scanning report is available on GitLab Ultimate)
|
||||
artifacts:
|
||||
reports:
|
||||
container_scanning: gl-container-scanning-report.json
|
||||
@@ -148,9 +148,9 @@ trivy:
|
||||
# Build image
|
||||
- docker build -t $IMAGE .
|
||||
# Image report
|
||||
- ./trivy image --exit-code 0 --format template --template "@contrib/gitlab-codequality.tpl" -o gl-codeclimate-image.json $IMAGE
|
||||
- ./trivy image --exit-code 0 --format template --template "@/contrib/gitlab-codequality.tpl" -o gl-codeclimate-image.json $IMAGE
|
||||
# Filesystem report
|
||||
- ./trivy filesystem --scanners misconfig,vuln --exit-code 0 --format template --template "@contrib/gitlab-codequality.tpl" -o gl-codeclimate-fs.json .
|
||||
- ./trivy filesystem --scanners misconfig,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
|
||||
|
||||
@@ -1,58 +1,51 @@
|
||||
# Kubernetes Scanning Tutorial
|
||||
|
||||
## Prerequisites
|
||||
## Prerequisites
|
||||
|
||||
To test the following commands yourself, make sure that you’re connected to a Kubernetes cluster. A simple kind, a Docker-Desktop or microk8s cluster will do. In our case, we’ll use a one-node kind cluster.
|
||||
|
||||
Pro tip: The output of the commands will be even more interesting if you have some workloads running in your cluster.
|
||||
Pro tip: The output of the commands will be even more interesting if you have some workloads running in your cluster.
|
||||
|
||||
## Cluster Scanning
|
||||
|
||||
Trivy K8s is great to get an overview of all the vulnerabilities and misconfiguration issues or to scan specific workloads that are running in your cluster. You would want to use the Trivy K8s command either on your own local cluster or in your CI/CD pipeline post deployments.
|
||||
|
||||
The `trivy k8s` command is part of the Trivy CLI.
|
||||
The `trivy k8s` command is part of the Trivy CLI.
|
||||
|
||||
With the following command, we can scan our entire Kubernetes cluster for vulnerabilities and get a summary of the scan:
|
||||
With the following command, we can scan our entire Kubernetes cluster for vulnerabilities and get a summary of the scan:
|
||||
|
||||
```
|
||||
trivy k8s --report=summary cluster
|
||||
```sh
|
||||
trivy k8s --report=summary
|
||||
```
|
||||
|
||||
To get detailed information for all your resources, just replace ‘summary’ with ‘all’:
|
||||
|
||||
```
|
||||
trivy k8s --report=all cluster
|
||||
```sh
|
||||
trivy k8s --report=all
|
||||
```
|
||||
|
||||
However, we recommend displaying all information only in case you scan a specific namespace or resource since you can get overwhelmed with additional details.
|
||||
|
||||
Furthermore, we can specify the namespace that Trivy is supposed to scan to focus on specific resources in the scan result:
|
||||
|
||||
```
|
||||
trivy k8s -n kube-system --report=summary cluster
|
||||
```sh
|
||||
trivy k8s --include-namespaces kube-system --report summary
|
||||
```
|
||||
|
||||
Again, if you’d like to receive additional details, use the ‘--report=all’ flag:
|
||||
|
||||
```
|
||||
trivy k8s -n kube-system --report=all cluster
|
||||
```sh
|
||||
trivy k8s --include-namespaces kube-system --report all
|
||||
```
|
||||
|
||||
Like with scanning for vulnerabilities, we can also filter in-cluster security issues by severity of the vulnerabilities:
|
||||
|
||||
```
|
||||
trivy k8s --severity=CRITICAL --report=summary cluster
|
||||
```sh
|
||||
trivy k8s --severity=CRITICAL --report=summary
|
||||
```
|
||||
|
||||
Note that you can use any of the Trivy flags on the Trivy K8s command.
|
||||
|
||||
With the Trivy K8s command, you can also scan specific workloads that are running within your cluster, such as our deployment:
|
||||
|
||||
```
|
||||
trivy k8s --namespace app --report=summary deployments/react-application
|
||||
```
|
||||
|
||||
## Trivy Operator
|
||||
## Trivy Operator
|
||||
|
||||
The Trivy K8s command is an imperative model to scan resources. We wouldn’t want to manually scan each resource across different environments. The larger the cluster and the more workloads are running in it, the more error-prone this process would become. With the Trivy Operator, we can automate the scanning process after the deployment.
|
||||
|
||||
@@ -66,15 +59,9 @@ 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, we’re going to use the Helm installation based on the [following documentation.](../../docs/target/kubernetes.md#trivy-operator)
|
||||
|
||||
Please follow the Trivy Operator documentation for further information on:
|
||||
|
||||
- [Installation of the Trivy Operator](https://aquasecurity.github.io/trivy-operator/latest/getting-started/installation/)
|
||||
- [Getting started guide](https://aquasecurity.github.io/trivy-operator/latest/getting-started/quick-start/)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
- [Getting started guide](https://aquasecurity.github.io/trivy-operator/latest/getting-started/quick-start/)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user