Compare commits

...

232 Commits

Author SHA1 Message Date
dependabot[bot]
55f29b8fb2 chore(deps): bump github.com/CycloneDX/cyclonedx-go from 0.5.0 to 0.5.1 (#1926)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-04-26 19:39:38 +03:00
Oran Moshai
b6baa65ff2 refactor(fs): scanner options (#2050)
To allow Trivy plugins create InitializeScanner signature scanner options need to be public

Co-authored-by: oranmoshai <oran.moshai@aquasec.com>
2022-04-26 16:05:27 +03:00
Teppei Fukuda
4b8e0ec2ea feat(secret): truncate long line (#2052) 2022-04-26 15:56:25 +03:00
Teppei Fukuda
cf78a436d2 docs: fix a broken bullets (#2042) 2022-04-26 10:42:09 +03:00
jeffalder
f8c2ced302 feat(ubuntu): add 22.04 approx eol date (#2044)
Add support for Ubuntu 22.04 LTS, Jammy Jellyfish: https://lists.ubuntu.com/archives/ubuntu-announce/2022-April/000279.html
2022-04-26 10:35:26 +03:00
tomthetommy
84c199428f docs: update installation.md (#2027) 2022-04-26 10:20:47 +03:00
nishipy
bdf55e16db docs: add Containerfile (#2032) 2022-04-26 10:17:24 +03:00
DmitriyLewen
9fd86da367 fix(go): fixed panic to scan gomod without version (#2038) 2022-04-25 16:04:44 +03:00
Teppei Fukuda
fbc9030db6 docs(mariner): confirm it works with Mariner 2.0 VM (#2036) 2022-04-25 10:17:51 +03:00
Teppei Fukuda
e2a31abd19 feat(secret): support enable rules (#2035)
Co-authored-by: VaismanLior <97836016+VaismanLior@users.noreply.github.com>
2022-04-24 19:04:30 +03:00
Carol Valencia
708a7a7175 chore: app version 26.0 (#2030)
Co-authored-by: carolina valencia <krol3@users.noreply.github.com>
2022-04-24 15:27:36 +03:00
Teppei Fukuda
e000329ec4 docs(secret): add a demo movie (#2031) 2022-04-24 11:56:27 +03:00
Teppei Fukuda
e127334664 feat: support cache TTL in Redis (#2021) 2022-04-22 23:19:01 +03:00
Teppei Fukuda
3870515a81 fix(go): skip system installed binaries (#2028) 2022-04-22 19:20:31 +03:00
Teppei Fukuda
4e6389af27 fix(go): check if go.sum is nil (#2029) 2022-04-22 18:50:01 +03:00
Teppei Fukuda
5f047f97db feat: add secret scanning (#1901)
Co-authored-by: VaismanLior <97836016+VaismanLior@users.noreply.github.com>
Co-authored-by: AMF <work@afdesk.com>
2022-04-22 17:08:18 +03:00
Carol Valencia
0700586483 chore: gh publish only with push the tag release (#2025)
Co-authored-by: carolina valencia <krol3@users.noreply.github.com>
2022-04-22 16:58:04 +03:00
Teppei Fukuda
1f393c12d5 fix(fs): ignore permission errors (#2022) 2022-04-22 11:47:56 +03:00
afdesk
110c534015 test(mod): using correct module inside test go.mod (#2020) 2022-04-21 16:48:33 +03:00
bgoareguer
525e2685ce feat(server): re-add proxy support for client/server communications (#1995) 2022-04-21 12:32:46 +03:00
afdesk
9898ac9251 fix(report): truncate a description before escaping in ASFF template (#2004) 2022-04-18 18:10:47 +03:00
afdesk
453a1edfd2 fix(cloudformation): correct margin removal for empty lines (#2002) 2022-04-17 21:46:01 +03:00
afdesk
407f3b668b fix(template): correct check of old sarif template files (#2003) 2022-04-16 13:10:48 +03:00
Teppei Fukuda
a0047a7983 feat(alpine): warn mixing versions (#2000) 2022-04-16 00:03:04 +03:00
Ben Harvey
d786655a18 Update ASFF template (#1914) 2022-04-15 14:04:07 +03:00
afdesk
a02cf65196 chore(deps): replace containerd/containerd version to fix CVE-2022-23648 (#1994) 2022-04-14 16:29:00 +03:00
DmitriyLewen
613e38ccf6 chore(deps): bump alpine from 3.15.3 to 3.15.4 (#1993) 2022-04-14 14:33:08 +03:00
afdesk
3b6d65beb8 test(go): add integration tests for gomod (#1989) 2022-04-14 13:38:54 +03:00
DmitriyLewen
22f5b938f9 fix(python): fixed panic when scan .egg archive (#1992) 2022-04-14 13:13:40 +03:00
afdesk
485637c28a fix(go): set correct go modules type (#1990) 2022-04-14 09:55:37 +03:00
Teppei Fukuda
6fdb554a0d feat(alpine): support apk repositories (#1987) 2022-04-14 09:52:51 +03:00
Teppei Fukuda
d9bddb90fe docs: add CBL-Mariner (#1982)
* docs: add CBL-Mariner

* docs: put it into a single page
2022-04-13 20:13:37 +03:00
Teppei Fukuda
1cf1873f21 docs(go): fix version (#1986) 2022-04-13 17:57:40 +03:00
Teppei Fukuda
d77dbe8a55 feat(go): support go.mod in Go 1.17+ (#1985) 2022-04-13 16:02:16 +03:00
Teppei Fukuda
32bd1e484a ci: fix URLs in the PR template (#1972) 2022-04-12 13:54:58 +03:00
DmitriyLewen
94a5a1808f ci: add semantic pull requests check (#1968) 2022-04-12 09:59:06 +03:00
afdesk
72d94b21cf docs(issue): added docs for wrong detection issues (#1961)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-04-12 09:57:27 +03:00
Teppei Fukuda
b4a7d6a861 docs: move CONTRIBUTING.md to docs (#1971) 2022-04-11 18:53:26 +03:00
DmitriyLewen
0127c1d39e refactor(table): use file name instead package path (#1966) 2022-04-11 12:15:15 +03:00
Teppei Fukuda
a92da72263 fix(sbom): add --db-repository (#1964) 2022-04-07 17:57:20 +03:00
DmitriyLewen
b0f3864e46 feat(table): add PkgPath in table result (#1960) 2022-04-06 15:52:13 +03:00
Jan-Otto Kröpke
0b1d32c182 fix(pom): merge multiple pom imports in a good manner (#1959) 2022-04-06 12:34:21 +03:00
DmitriyLewen
d4e3df81e8 fix(downloadDB): add dbRepositoryFlag to repository and rootfs commands (#1956) 2022-04-06 08:51:45 +03:00
afdesk
7e48cc1f4d fix(misconf): update BurntSushi/toml for fix runtime error (#1948) 2022-04-05 21:13:33 +03:00
Liam Galvin
c9efa8c479 fix(misconf): Update fanal/defsec to resolve missing metadata issues (#1947)
Signed-off-by: Liam Galvin <liam.galvin@aquasec.com>
2022-04-05 20:40:04 +03:00
Kobus van Schoor
52b715421e feat(jar): allow setting Maven Central URL using environment variable (#1939)
* chore(deps): update fanal/go-dep-parser to allow setting maven central url

* docs(troubleshooting): Add documentation for MAVEN_CENTRAL_URL option
2022-04-05 19:02:39 +03:00
Dennis Irsigler
21f7a41b27 chore(chart): update Trivy version in HelmChart to 0.25.0 (#1931)
Signed-off-by: Dennis Irsigler <dennis.irsigler@metro-markets.de>
2022-04-05 16:36:51 +03:00
Teppei Fukuda
ff2b3d176d chore(chart): remove version comments (#1933)
Co-authored-by: Carol Valencia <8355621+krol3@users.noreply.github.com>
2022-04-05 16:22:19 +03:00
DmitriyLewen
9c19298f5f fix(downloadDB): add flag to server command (#1942) 2022-04-05 11:43:42 +03:00
Liam Galvin
aa3d696625 fix(misconf): update defsec to resolve panics (#1935) 2022-04-04 21:35:30 +03:00
dependabot[bot]
31e76699da chore(deps): bump github.com/docker/docker (#1924) 2022-04-04 17:58:34 +03:00
Anais Urlichs
4ca35b26a7 docs: restructure the documentation (#1887)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-04-04 17:20:22 +03:00
dependabot[bot]
8da4548073 chore(deps): bump github.com/urfave/cli/v2 from 2.3.0 to 2.4.0 (#1923) 2022-04-04 17:03:06 +03:00
dependabot[bot]
76e9d7eb27 chore(deps): bump actions/cache from 2 to 3.0.1 (#1920) 2022-04-04 15:43:14 +03:00
dependabot[bot]
2b217a3b2a chore(deps): bump actions/checkout from 2 to 3 (#1916) 2022-04-04 15:04:29 +03:00
dependabot[bot]
902aa8ceb9 chore(deps): bump github.com/open-policy-agent/opa from 0.37.2 to 0.39.0 (#1921) 2022-04-04 13:40:33 +03:00
dependabot[bot]
60b19e5e60 chore(deps): bump sigstore/cosign-installer from 2.0.0 to 2.1.0 (#1919) 2022-04-04 13:38:13 +03:00
dependabot[bot]
58aab67928 chore(deps): bump helm/chart-testing-action from 2.2.0 to 2.2.1 (#1918) 2022-04-04 13:15:02 +03:00
dependabot[bot]
209b9cc25a chore(deps): bump golang from 1.17 to 1.18.0 (#1915) 2022-04-04 13:10:28 +03:00
Itay Shakury
bfb931d454 Add trivy horizontal logo (#1932) 2022-04-04 13:09:54 +03:00
dependabot[bot]
ae86a5b171 chore(deps): bump alpine from 3.15.0 to 3.15.3 (#1917) 2022-04-04 11:37:42 +03:00
dependabot[bot]
1a23039e31 chore(deps): bump github.com/go-redis/redis/v8 from 8.11.4 to 8.11.5 (#1925) 2022-04-04 11:06:49 +03:00
dependabot[bot]
56498ca1df chore(deps): bump github.com/stretchr/testify from 1.7.0 to 1.7.1 (#1927) 2022-04-04 09:57:10 +03:00
Sashi Kumar
02105678ed feat(db): Add dbRepository flag to get advisory database from OCI registry (#1873)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-03-31 16:09:01 +03:00
DmitriyLewen
4470a181e2 docs(filter vulnerabilities): fix link (#1880)
fixed link to helper functions
2022-03-30 17:56:16 +03:00
Nate Fear
cb171ead72 feat(template) Add misconfigurations to gitlab codequality report (#1756) 2022-03-30 17:55:14 +03:00
afdesk
36e24b1858 fix(rpc): add PkgPath field to client / server mode (#1643) 2022-03-30 14:43:29 +03:00
DmitriyLewen
88311745ba fix(vulnerabilities): fixed trivy-db vulns (#1883) 2022-03-28 11:30:20 +03:00
afdesk
9154b819ac feat(cache): remove temporary cache after filesystem scanning (#1868) 2022-03-27 11:31:54 +03:00
Tamir Kiviti
f36d9b6f90 feat(sbom): add a dedicated sbom command (#1799)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-03-23 23:42:22 +02:00
Masahiro331
7a148089ec feat(cyclonedx): add vulnerabilities (#1832)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-03-22 20:22:55 +02:00
afdesk
df80fd31a0 fix(option): hide false warning about remote options (#1865) 2022-03-22 16:33:03 +02:00
Teppei Fukuda
88ebc07504 chore: bump up Go to 1.18 (#1862) 2022-03-21 16:38:54 +02:00
afdesk
d6418cf0de feat(filesystem): scan in client/server mode (#1829)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-03-21 15:51:18 +02:00
Teppei Fukuda
12d0317a67 refactor(template): remove unused test (#1861) 2022-03-21 14:50:36 +02:00
DmitriyLewen
c3aca1524c fix(cli): json format for trivy version (#1854)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-03-21 14:41:41 +02:00
Rory McCune
b2b68951f2 docs: change URL for tfsec-checks (#1857)
The current URL for the tfsec-checks is 404, so changing it in-line with what we've got for cfsec, which is just the base site URL.
2022-03-20 10:16:51 +02:00
afdesk
06659f1509 fix(docker): Getting images without a tag (#1852) 2022-03-17 21:05:41 +02:00
SIPR
a91cc50df7 docs(gitlab-ci): Use environment variables TRIVY_CACHE_DIR and TRIVY_NO_PROGRESS (#1801) 2022-03-17 19:16:06 +02:00
DmitriyLewen
4b8bf874d8 chore(issue labels): added new labels (#1839)
Co-authored-by: Teppei Fukuda <knqyf263@gmail.com>
2022-03-16 14:38:47 +02:00
Furkan Türkal
5040caefc8 refactor: clarify db update warning messages (#1808)
Signed-off-by: Furkan <furkan.turkal@trendyol.com>

Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-03-16 14:35:40 +02:00
DmitriyLewen
28cd5a5537 chore(ci): change trivy vulnerability scan for every day (#1838) 2022-03-16 13:00:12 +02:00
Zach Stone
b2f554eb2a feat(helm): make Trivy service name configurable (#1825) 2022-03-16 10:38:45 +02:00
DmitriyLewen
7a44a7a344 chore(deps): updated sprig to version v3.2.2. (#1814) 2022-03-14 14:40:52 +02:00
DmitriyLewen
18842fbe04 chore(deps): updated testcontainers-go to version v0.12.0 (#1822) 2022-03-14 14:13:29 +02:00
MaineK00n
12ca3ca6da docs: add packages.config for .NET (#1823) 2022-03-14 13:57:53 +02:00
Batuhan Apaydın
728a3db6c6 build: sign container image (#1668)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-03-13 15:35:43 +02:00
dependabot[bot]
4e7b5ca365 chore(deps): bump github.com/CycloneDX/cyclonedx-go from 0.4.0 to 0.5.0 (#1778)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: masahiro331 <m_fujimura@r.recruit.co.jp>
2022-03-13 14:10:36 +02:00
Ricardo
0fca2cda91 docs: fix Installation documentation (#1804)
* Add missing `image` argument in the Installation docs->Docker section for MacOS.
2022-03-13 11:59:01 +02:00
Cyrille Pontvieux
e50839bb40 fix(report): ensure json report got a final new line (#1797) 2022-03-13 11:58:21 +02:00
Owen Rumney
f95a0f0d52 fix(terraform): resolve panics in defsec (#1811) 2022-03-09 18:37:02 +02:00
Malte Swart
e5bf3d1e30 feat(docker): Label images based on OCI image spec (#1793)
The Label Schema Convention has been deprecated in favor of the OCI
image spec.

Update the gorelease config to use the new replacement fields.

This is not considered a breaking change, as it only touches metadata
and the Label Schema Convention is deprecated for over two years (March
2019).

Most fields only need to be renamed. `org.label-schema.schema-version`
could be removed without replacement.
`org.opencontainers.image.documentation` was added to link to the
Github page documentation in the exact version.
`org.opencontainers.image.url` was added pointing to the Aqua Security
product page of trivy.
Further labels were considered but not added (unclear purpose or value).
2022-03-06 20:00:24 +02:00
Will Dowling
2193fb3c44 fix(helm): indentation for ServiceAccount annotations (#1795) 2022-03-06 09:34:38 +02:00
bestgopher
bbccb5a69d fix(hcl): fix panic in hcl2json (#1791) 2022-03-03 18:21:18 +02:00
Kaito Ii
a625455f1c chore(helm): remove psp from helm manifest (#1315) 2022-03-03 15:38:53 +02:00
Yuval Goldberg
7e69f4820e build: Replace make protoc with for loop to return an error (#1655)
Find the `*.proto` files and run in a `for loop` to run `protoc`
for each file in a separated command. If fail, `|| exit` will exit
with the returned error.

The POSIX standard specifies that the return status of `find` is 0
unless an error occurred while traversing the directories;
the return status of executed commands doesn't enter into it.

To overcome this limitation, the `-exec ... +` pattern could be used
From the docs (https://man7.org/linux/man-pages/man1/find.1.html):
"If any invocation with the `+' form returns a non-zero
value as exit status, then find returns a non-zero exit
status."

But as well, "This variant of the -exec action runs the specified command
on the selected files, but the command line is built by appending each selected
file name at the end;"

Unfortunately, at the moment `protoc-gen-twirp` plugin doesn't
support multiple files from different packages when the `go_package` option
is explicitly mentioned.
https://github.com/twitchtv/twirp/blob/main/protoc-gen-twirp/generator.go#L181-L185

Signed-off-by: Yuval Goldberg <yuvigoldi@gmail.com>
2022-03-03 15:35:51 +02:00
Amndeep Singh Mann
f6c986b6c0 fix: ASFF template to match ASFF schema (#1685)
Signed-off-by: Amndeep Singh Mann <amann@mitre.org>
2022-03-03 15:28:20 +02:00
Eric Bailey
aab6f0bf20 feat(helm): Add support for server token (#1734) 2022-03-03 14:38:20 +02:00
Teppei Fukuda
eebf9c8f58 fix(pom): keep an order of dependencies (#1784) 2022-03-03 12:36:21 +02:00
Teppei Fukuda
971092b847 chore: bump up Go to 1.17 (#1781) 2022-03-03 10:30:36 +02:00
dependabot[bot]
2f2d8222e4 chore(deps): bump actions/setup-python from 2 to 3 (#1776)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-03-02 14:11:29 +02:00
dependabot[bot]
a2afd6e683 chore(deps): bump golangci/golangci-lint-action from 2 to 3.1.0 (#1777) 2022-03-02 10:43:16 +02:00
afdesk
a423b99312 fix(python): correct handling pip package names with a hyphen (#1771) 2022-02-27 17:47:53 +02:00
benterris
a069ad7818 doc(docker): fix command to run trivy with docker on linux (#1761) 2022-02-25 10:56:47 +02:00
Edvin N
015055e1f5 feat(helm): Add support for custom labels (#1767)
Solves #1766
2022-02-25 09:07:25 +02:00
Edvin N
cbaa363990 chore(helm): bump chart to trivy 0.24.0 (#1762)
Signed-off-by: Edvin Norling <edvin.norling@xenit.se>
2022-02-25 09:06:56 +02:00
Owen Rumney
bec02f098d docs: remove erroneous command (#1763) 2022-02-24 14:21:10 +02:00
dependabot[bot]
d7f8b92a27 chore(deps): bump github.com/spf13/afero from 1.6.0 to 1.8.1 (#1708) 2022-02-22 22:49:01 +02:00
Teppei Fukuda
59ea0d5781 fix(option): warn list-all-pkgs only with the table format (#1755) 2022-02-22 22:48:39 +02:00
DmitriyLewen
c788676f87 feat(option): warn "--list-all-pkgs" with "--format table" (#1632)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-02-22 18:41:25 +02:00
Masahiro331
58ade462b4 feat(report): add support for CycloneDX (#1081)
Co-authored-by: tspearconquest <81998567+tspearconquest@users.noreply.github.com>
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-02-22 18:01:15 +02:00
Owen Rumney
77cab6e0b9 chore(deps): update the defsec and tfsec versions (#1747) 2022-02-22 16:42:24 +02:00
AndreyLevchenko
2ede15d358 fix(scanner): fix skip of language-specific files when scanning rootf… (#1751) 2022-02-22 08:48:25 +02:00
dependabot[bot]
d266c74941 chore(deps): bump github.com/google/wire from 0.4.0 to 0.5.0 (#1712) 2022-02-21 18:46:55 +02:00
Guy Ben-Aharon
4423396bcc feat(report): considering App.Writer when printing results (#1722)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-02-21 16:47:42 +02:00
afdesk
356ae30c7e chore(deps): replace satori version and skipping examples folder (#1745)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-02-21 15:58:45 +02:00
skuethe
477dc7d5f9 build: add s390x container images (#1726)
Signed-off-by: skuethe <56306041+skuethe@users.noreply.github.com>
2022-02-21 11:31:07 +02:00
Oran Moshai
89b8d7ff30 feat(template) Add misconfigurations to junit report (#1724)
Co-authored-by: oranmoshai <oran.moshai@aquasec.com>
2022-02-20 11:54:24 +02:00
dependabot[bot]
219b71b4fd chore(deps): bump github.com/twitchtv/twirp (#1709) 2022-02-14 10:25:28 +02:00
Christian Zunker
aa6e1eb6f9 feat(client): configure TLS InsecureSkipVerify for server connection (#1287)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-02-13 11:34:34 +02:00
Ankush K
de6c3cbb6c fix(rpc): Supports RPC calls for new identifier CustomResource (#1605) 2022-02-13 11:20:51 +02:00
dependabot[bot]
b7d4d1ead4 chore(deps): bump go.uber.org/zap from 1.20.0 to 1.21.0 (#1705) 2022-02-13 11:18:07 +02:00
dependabot[bot]
e6c029d08a chore(deps): bump github.com/caarlos0/env/v6 from 6.0.0 to 6.9.1 (#1707) 2022-02-13 10:13:06 +02:00
Will Dowling
ec6cb1a642 feat(helm): Parameterise ServiceAccount annotations (#1677) 2022-02-13 09:48:01 +02:00
dependabot[bot]
7dfc16cf21 chore(deps): bump github.com/hashicorp/go-getter from 1.5.2 to 1.5.11 (#1710) 2022-02-13 09:47:11 +02:00
dependabot[bot]
42d8fd6638 chore(deps): bump github.com/cheggaaa/pb/v3 from 3.0.3 to 3.0.8 (#1704) 2022-02-11 20:09:23 +02:00
dependabot[bot]
c3ef2035b5 chore(deps): bump github.com/open-policy-agent/opa from 0.36.1 to 0.37.2 (#1711) 2022-02-11 18:04:44 +02:00
Teppei Fukuda
274103e883 chore(dependabot): enable gomod monthly (#1699) 2022-02-11 14:24:25 +02:00
Konstantinos Koukopoulos
e618d83dae fix(gitlab tpl): escape double quote (#1635) 2022-02-10 17:29:10 +02:00
Yuval Goldberg
3b0b2ed4ce build: Make make protoc be consistent (#1682)
Signed-off-by: Yuval Goldberg <yuvigoldi@gmail.com>
2022-02-10 11:07:30 +02:00
Masahiro331
5c8d098324 feat(purl): add generate purl package utilities (#1574) 2022-02-09 20:35:36 +02:00
Teppei Fukuda
11f4f81123 refactor: move result structs under types (#1696) 2022-02-09 19:31:12 +02:00
Teppei Fukuda
6db2092c72 feat(mariner): add support for CBL-Mariner 2.0 (#1694) 2022-02-09 14:45:39 +02:00
Sven Haardiek
8898bb0937 docs(gitlab-ci): fix Script in GitLab CI Example #1688
This patch changes the command line order to still work with the latest version
of trivy.

Signed-off-by: Sven Haardiek <sven.haardiek@uni-muenster.de>
2022-02-08 13:31:10 +02:00
Carol Valencia
33d0833717 chore: Upgrade helm chart version (#1683)
Co-authored-by: carolina valencia <krol3@users.noreply.github.com>
2022-02-08 12:45:11 +02:00
tspearconquest
13874d866c chore(mod): update Go dependencies (#1681)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-02-07 14:12:45 +02:00
Greg Myers
f26a06b980 docs: fix typos in markdown docs (#1674) 2022-02-04 22:05:30 +02:00
Rory McCune
e2821a4fba docs: update documentation for image scanning of tar files to use a tag present on Docker Hub (#1671) 2022-02-04 22:04:53 +02:00
Teppei Fukuda
ef8a1afcdb fix(repo): --no-progress suppresses git output (#1669) 2022-02-03 09:02:39 +02:00
Teppei Fukuda
449add24af docs: add ACR navigator (#1651) 2022-01-31 16:19:19 +02:00
John A Stevenson
cb9afc8441 fix: update example Rego files and docs (#1628) 2022-01-31 16:18:24 +02:00
Teppei Fukuda
78b2b899a0 feat(option): show a link to GitHub Discussions for --light deprecation (#1650) 2022-01-31 15:26:43 +02:00
afdesk
52fd3c2e0a fix(sarif): fix the warning message (#1647) 2022-01-31 10:11:27 +02:00
Teppei Fukuda
8d5882be03 refactor: migrate to prefixed buckets (#1644) 2022-01-31 10:05:38 +02:00
Masahiro331
84dd33f7e9 feat(mariner): add support for CBL-Mariner (#1640)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-01-29 22:53:07 +02:00
Teppei Fukuda
9e903a1d88 docs: commercial use available (#1641) 2022-01-29 21:26:16 +02:00
Christian Groschupp
f4c746a2d2 feat: support azure acr (#1611)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-01-28 22:50:28 +02:00
afdesk
420f8ab13e feat(os-pkg): add data sources (#1636) 2022-01-28 20:41:40 +02:00
Teppei Fukuda
d2827cba06 feat(redhat): support build info in RHEL (#807) 2022-01-28 18:35:00 +02:00
DmitriyLewen
ce703ce4a5 fix: change links in pull_request_template to static URLs (#1634) 2022-01-27 15:47:37 +02:00
Teppei Fukuda
50bb938a21 feat(lang-pkg): add data sources (#1625) 2022-01-27 14:22:06 +02:00
Teppei Fukuda
a31ddbe971 feat(detector): support custom detector (#1615) 2022-01-25 09:06:28 +02:00
AndreyLevchenko
3a4e18ac82 docs(contribution): change role who should resolve comments (#1618) 2022-01-24 15:11:03 +02:00
DmitriyLewen
8ba68361bd docs: add PR template (#1602)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-01-23 10:36:03 +02:00
MaineK00n
f5c5573936 feat(rocky): support Rocky Linux (#1570)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-01-20 11:43:43 +02:00
MarkusTeufelberger
eab2b425db Add the ability to set dockerhub credentials in the helm chart (#1569) 2022-01-20 07:51:07 +02:00
Taufik Mulyana
cabd18daae feat(cache): redis TLS support (#1297) 2022-01-18 15:16:00 +02:00
DmitriyLewen
02c3c3659d feat(java): add support for PAR files (#1599) 2022-01-18 13:26:46 +02:00
DmitriyLewen
4f7b768369 refactor(rust): move rust-advisory-db to OSV (#1591) 2022-01-17 15:38:35 +02:00
rethab
d754cb8c6f feat: log ignored vulnerabilities on debug (#1378)
* feat: log ignored vulnerabilities

* feat: show IDs in an ignore file

Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-01-17 08:38:08 +02:00
AndreyLevchenko
a936e675c9 chore(mod): hcl2json deps update (#1585)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-01-16 21:09:04 +02:00
DmitriyLewen
af116d3c9e fix(rpm): do not ignore installed files via third-party rpm (#1594) 2022-01-16 20:34:19 +02:00
jerbob92
b507360075 feat(fs): allow scanning a single file (#1578)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-01-16 16:32:31 +02:00
Teppei Fukuda
7fcbf44bb8 refactor(python): drop Safety DB (#1580) 2022-01-16 15:23:49 +02:00
DmitriyLewen
478d279919 feat: added insecure tls skip to scan git repo (#1528)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-01-14 11:25:45 +02:00
Yuval Goldberg
33bd41b40f Supress git clone output (#1590) 2022-01-14 08:59:49 +02:00
MaineK00n
39a10089fc fix(alma): skip modular package because MODULARITYLABEL is not set (#1588) 2022-01-13 17:30:20 +02:00
DmitriyLewen
37abd612aa feat(photon os): added EOL dates check (#1587)
Co-authored-by: Teppei Fukuda <knqyf263@gmail.com>
2022-01-13 16:20:32 +02:00
DmitriyLewen
78de33e8ea docs: update supported os (#1586) 2022-01-13 13:53:13 +02:00
Teppei Fukuda
22054626f3 BREAKING: remove root command (#1579) 2022-01-12 16:13:13 +02:00
MaineK00n
28ddcf1ae8 docs: add Rust to Language-specific Packages Table (#1577) 2022-01-12 15:42:48 +02:00
rizwan-kh
df134c73f8 docs: update int doc for gitlab ci (#1575) 2022-01-12 11:17:29 +02:00
afdesk
8da20c8c92 BREAKING: migrate the sarif template to Go code (#1437)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
2022-01-12 08:49:47 +02:00
Teppei Fukuda
714b5ca246 refactor: remove unused field (#1567) 2022-01-11 19:47:52 +02:00
dependabot[bot]
51e152b01c chore(deps): bump helm/chart-testing-action from 2.1.0 to 2.2.0 (#1554)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com
2022-01-11 14:58:23 +02:00
Stan0304
884daff429 docs: gitlab integration (#1381) 2022-01-10 15:38:32 +02:00
MaineK00n
2a8336b9aa feat(alma): support AlmaLinux (#1238)
Co-authored-by: Teppei Fukuda <knqyf263@gmail.com>
2022-01-06 22:26:09 +02:00
Sourabh Gupta
1e171af165 docs: added note about default template path when Trivy installed using rpm (#1551) 2022-01-06 20:36:39 +02:00
Teppei Fukuda
e65274e0ef BREAKING: Trivy DB from GHCR (#1539) 2022-01-06 20:08:40 +02:00
Liam Galvin
db35450bbb feat(cli): Do not set default commands when a plugin is being run (#1549) 2022-01-06 19:10:16 +02:00
Maria Kotlyarevskaya
24254d19f6 fix: add fingerprint field to codequality template (#1541)
Signed-off-by: Jasstkn <mariia.kotliarevskaia@gmail.com>
2022-01-06 15:12:24 +02:00
afdesk
2ee074568c fix(image): correct handling of uncompressed layers (#1544)
Fixes #1527
2022-01-05 20:38:08 +02:00
Carol Valencia
0aef82c58e chore: helm chart app version 0.22.0 (#1535)
Co-authored-by: carolina valencia <krol3@users.noreply.github.com>
2022-01-04 22:24:39 +02:00
Teppei Fukuda
8b2a799721 test(integration): use fixtures (#1532) 2021-12-30 20:53:03 +02:00
Teppei Fukuda
42f795fa34 fix(java/pom): ignore unsupported requirements (#1514) 2021-12-24 23:37:28 +02:00
Teppei Fukuda
8f737cc6eb feat(cli): warning for root command (#1516) 2021-12-24 23:02:19 +02:00
Teppei Fukuda
76249bdcf0 BREAKING: disable JAR detection in fs/repo scanning (#1512)
Co-authored-by: Andrey Levchenko <levchenko.andrey@gmail.com>
2021-12-24 16:14:50 +02:00
Teppei Fukuda
59957d4c6b feat(scan): support --offline-scan option (#1511) 2021-12-24 12:20:21 +02:00
Teppei Fukuda
da8b72d2e7 fix: improve memory usage (#1509) 2021-12-24 08:33:43 +02:00
Teppei Fukuda
b713ad0fd3 feat(java): support pom.xml (#1501) 2021-12-23 16:45:38 +02:00
yuriShafet
56115e9d4f docs: fixing rust link to security advisory (#1504) 2021-12-22 17:52:35 +02:00
Owen Rumney
7f859afacb Add missing IacMetdata (#1505)
- Provider and Service added to IacMetadata on misconfiguration
2021-12-22 17:06:25 +02:00
Teppei Fukuda
628a7964d5 feat(jar): add file path (#1498) 2021-12-21 08:52:33 +02:00
Teppei Fukuda
82fba77141 feat(rpm): support NDB (#1497) 2021-12-21 07:57:06 +02:00
DmitriyLewen
d5269da5ee feat: added misconfiguration field for html.tpl (#1444)
* feat: added misconfiguration field for html.tpl

* feat: added message field for html.tpl

* fix: fixed integration test error
2021-12-20 17:14:00 +02:00
Chetan Goti
8e57dee86b fix(docs): typo (#1488) 2021-12-19 11:24:22 +02:00
Owen Rumney
8bfbc84a41 feat(plugin): Add option to update plugin (#1462)
* Add option to update plugin

- add plugin update [pluginName] to update
- add supporting test

* refactor: wrap errors
2021-12-16 13:30:19 +02:00
DmitriyLewen
1e811de263 fix: fixed skipFiles/skipDirs flags for relative path (#1482) 2021-12-16 13:21:22 +02:00
Owen Rumney
8b5796f770 feat (plugin): add list and info command for plugin (#1452)
Co-authored-by: Teppei Fukuda <knqyf263@gmail.com>
2021-12-15 22:36:08 +02:00
afdesk
a2199bb417 fix: set up a vulnerability severity (#1458) 2021-12-15 21:28:29 +02:00
geyingqi
279e76f704 chore: add arm64 deb package (#1480) 2021-12-15 20:08:05 +02:00
Tomas Fernandez
5262590831 Link to trivy tutorial on Semaphore (#1449)
* Link to trivy tutorial on Semaphore

* Move tutorial to Advanced > Community > Tools
2021-12-12 05:33:00 +02:00
abdennour
c275a841fd refactor(helm): externalize env vars to configMap (#1345)
\#1343

Signed-off-by: abdennour <mail@abdennoor.com>
2021-12-08 08:37:05 +02:00
nobletrout
7beed30170 docs: provide more information on scanning Google's GCR (#1426)
Co-authored-by: Teppei Fukuda <knqyf263@gmail.com>
2021-12-07 03:28:46 +02:00
DmitriyLewen
f50e1f42a1 docs(misconfiguration): added instruction for misconfiguration detection (#1428)
Co-authored-by: Teppei Fukuda <knqyf263@gmail.com>
2021-12-06 13:56:41 +02:00
Guilherme Macedo
3ae4de5869 Update git-repository.md (#1430)
Update instructions on how to scan private git repositories, as according to https://github.com/aquasecurity/fanal/pull/253 .
2021-12-06 13:04:03 +02:00
AndreyLevchenko
6e35b8f53c fix(hooks): exclude unrelated lib types from system files filtering (#1431) 2021-12-06 10:53:34 +02:00
afdesk
beb60b05f3 chore: run go fmt (#1429) 2021-12-02 17:52:57 +09:00
afdesk
582e7fd1ba fix(sarif): change help field in the sarif template. (#1423) 2021-12-02 14:23:26 +09:00
Owen Rumney
11bc290111 Update fanal with cfsec version update (#1425)
- new version of cfsec brought in with latest fanal
  - fixes issue where cfsec treats files as CloudFormation when they
    arent
  - fixes issuee where invalid content errors are surfaced to Trivy
- Gets addition of service and provider on the IaC results - this is not
  visible to others
2021-12-01 04:15:26 +02:00
Nilushan Costa
392f68926c Replace deprecated option in goreleaser (#1406)
* Replace deprecated docker.use_buildx with docker.use

* Bump goreleaser GitHub action to v0.183.0
2021-11-29 05:31:16 +02:00
Huang Huang
101d576025 feat(alpine): support 3.15 (#1422) 2021-11-29 05:30:44 +02:00
Carol Valencia
bd3ba68cce chore: test the helm chart in the PR and used the commit hash (#1414)
Co-authored-by: carolina valencia <krol3@users.noreply.github.com>
2021-11-29 05:29:01 +02:00
dependabot[bot]
3860d6e4e9 chore(deps): bump alpine from 3.14 to 3.15.0 (#1417)
Bumps alpine from 3.14 to 3.15.0.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-28 09:48:31 +02:00
afdesk
4f82673a61 chore(release): add ubuntu older versions to deploy script (#1416)
* chore(release): add ubuntu older versions to deploy script

`ubuntu-distro-info --supported` returns only versions: `bionic`, `focal`, `hirsute`, `impish` and `jammy`.

`ubuntu-distro-info --supported-esm` returns another versions: `trusty`, `xenial`, `bionic`, `focal` and `jammy`.

for the release script we should use the union of these sets.

Fixes #1194

* change `uniq` command to `-u` parameter
2021-11-28 09:43:07 +02:00
Teppei Fukuda
b9a51de862 chore(mod): tidy (#1415) 2021-11-26 06:36:55 +02:00
AndreyLevchenko
7f248341cc fix(rpc): fix nil layer transmit (#1410)
* fix(rpc): fix nil layer transmit

Closes #1400

* added tests
2021-11-24 10:29:13 +02:00
Naimuddin Shaik
af3eaefdb2 Lang advisory order (#1409)
* chore(advisory reorder)

Reorder language advisory.

* fixed integration tests.
2021-11-24 10:27:12 +02:00
Raul Cabello Martin
07c9200eb7 chore: add support for s390x arch (#1304) 2021-11-21 11:38:47 +02:00
Carol Valencia
8bc8a4ad60 fix(chart): ingress helm manifest-update trivy image (#1323)
* fix: ingress helm manifest-update trivy image

* chore: helm ingress Capabilities.apiVersion

* feat: helm chart test gh

Co-authored-by: carolina valencia <krol3@users.noreply.github.com>
2021-11-21 09:57:30 +02:00
Owen Rumney
9076a49b0f docs: Add comparison for cfsec (#1388)
* Add cfsec comparison

* Add to mkdocs.yml
2021-11-17 16:42:17 +02:00
naoyukis
bb316d93ca remove: delete unused functions in utils package (#1379) 2021-11-16 14:12:18 +02:00
AndreyLevchenko
efdb29d0d4 fix(sarif): fix validation errors (#1376) 2021-11-15 16:36:51 +02:00
Teppei Fukuda
9bcf9e72f5 docs: add Bitbucket Pipelines (#1374) 2021-11-14 11:31:21 +02:00
Teppei Fukuda
3147097daf docs: add community integrations (#1361)
Co-authored-by: Carsten Hoffmann <choffmann87@googlemail.com>
2021-11-14 10:28:26 +02:00
Simon Engledew
33f74b3acb Use a stable SARIF identifier (#1230) 2021-11-11 20:02:40 +02:00
rahul2393
5915ffb42b fix(python): fix parsing of requirements.txt with hash checking mode available in pip since version 8.0 2021-11-11 13:18:31 +02:00
Owen Rumney
ae4c42b975 feat(iac): Add line information (#1366)
* feat(iac): Adding resource and Line data

- adding line in file information to the misconfiguration result
- updating tfsec and cfsec versions to provide this additional info

* Add usage of IaC metadata

* update the fanal version
2021-11-11 08:00:13 +02:00
Owen Rumney
19747d0535 feat(cloudformation): Adding support for cfsec IaC scanning (#1360) 2021-11-09 17:42:44 +02:00
Jamie
da45061f4d chore: send debug and info logs to stdout in install.sh, not stderr. (#1264)
The current install.sh script logs all messages to stderr via ```echoerr()``` function. Since godownloader is no longer maintained, it seems reasonable to update install.sh here.
2021-11-09 16:54:42 +02:00
tspearconquest
cb1a4ed3a1 Update containerd to v1.5.7 and docker-cli to v20.10.9 (#1356)
Signed-off-by: Thomas Spear <tspear@conquestcyber.com>
2021-11-09 16:00:41 +02:00
Vinod Anandan
69dae54aa1 chore: update SBOM generation (#1349) 2021-11-01 16:44:14 +02:00
443 changed files with 20951 additions and 137630 deletions

View File

@@ -0,0 +1,33 @@
---
name: Wrong Detection
labels: ["kind/bug"]
about: If Trivy doesn't detect something, or shows false positive detection
---
## Checklist
- [ ] I've read [the documentation regarding wrong detection](https://aquasecurity.github.io/trivy/latest/community/contribute/issue/#wrong-detection).
- [ ] I've confirmed that a security advisory in data sources was correct.
- Run Trivy with `-f json` that shows data sources and make sure that the security advisory is correct.
## Description
<!--
Briefly describe the CVE that aren't detected and information about artifacts with this CVE.
-->
## JSON Output of run with `-debug`:
```
(paste your output here)
```
## Output of `trivy -v`:
```
(paste your output here)
```
## Additional details (base image name, container registry info...):

View File

@@ -1,10 +1,15 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
- package-ecosystem: docker
directory: /
schedule:
interval: daily
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
- package-ecosystem: docker
directory: /
schedule:
interval: monthly
- package-ecosystem: gomod
open-pull-requests-limit: 10
directory: /
schedule:
interval: monthly

18
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,18 @@
## Description
## Related issues
- Close #XXX
## Related PRs
- [ ] #XXX
- [ ] #YYY
Remove this section if you don't have related PRs.
## Checklist
- [ ] I've read the [guidelines for contributing](https://aquasecurity.github.io/trivy/latest/community/contribute/pr/) to this repository.
- [ ] I've followed the [conventions](https://aquasecurity.github.io/trivy/latest/community/contribute/pr/#title) in the PR title.
- [ ] I've added tests that prove my fix is effective or that my feature works.
- [ ] I've updated the [documentation](https://github.com/aquasecurity/trivy/blob/main/docs) with the relevant information (if needed).
- [ ] I've added usage information (if the PR introduces new options)
- [ ] I've included a "before" and "after" example to the description (if the PR is a user interface change).

View File

@@ -12,18 +12,17 @@ jobs:
runs-on: ubuntu-18.04
steps:
- name: Checkout main
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: true
- uses: actions/setup-python@v2
- uses: actions/setup-python@v3
with:
python-version: 3.x
- name: Install dependencies
run: |
pip install git+https://${GH_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git
pip install mike
pip install mkdocs-macros-plugin
pip install -r docs/build/requirements.txt
env:
GH_TOKEN: ${{ secrets.MKDOCS_AQUA_BOT }}
- name: Configure the git user

View File

@@ -14,18 +14,17 @@ jobs:
runs-on: ubuntu-18.04
steps:
- name: Checkout main
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: true
- uses: actions/setup-python@v2
- uses: actions/setup-python@v3
with:
python-version: 3.x
- name: Install dependencies
run: |
pip install git+https://${GH_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git
pip install mike
pip install mkdocs-macros-plugin
pip install -r docs/build/requirements.txt
env:
GH_TOKEN: ${{ secrets.MKDOCS_AQUA_BOT }}
- name: Configure the git user

View File

@@ -1,45 +1,81 @@
name: Publish Chart Helm
name: Publish Helm chart
on:
push:
branches: [main]
workflow_dispatch:
pull_request:
branches:
- main
paths:
- 'helm/trivy/**'
workflow_dispatch:
push:
tags:
- "v*"
env:
HELM_REP: helm-charts
GH_OWNER: aquasecurity
CHART_DIR: helm/trivy
KIND_VERSION: "v0.11.1"
KIND_IMAGE: "kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6"
jobs:
release:
test-chart:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
with:
fetch-depth: 0
- name: Install Helm
uses: azure/setup-helm@v1
uses: azure/setup-helm@18bc76811624f360dbd7f18c2d4ecb32c7b87bab
with:
version: v3.5.0
- name: Set up python
uses: actions/setup-python@v3
with:
python-version: 3.7
- name: Setup Chart Linting
id: lint
uses: helm/chart-testing-action@dae259e86a35ff09145c0805e2d7dd3f7207064a
- name: Setup Kubernetes cluster (KIND)
uses: helm/kind-action@94729529f85113b88f4f819c17ce61382e6d8478
with:
version: ${{ env.KIND_VERSION }}
image: ${{ env.KIND_IMAGE }}
- name: Run chart-testing
run: ct lint-and-install --validate-maintainers=false --charts helm/trivy
- name: Run chart-testing (Ingress enabled)
run: |
sed -i -e '117s,false,'true',g' ./helm/trivy/values.yaml
ct lint-and-install --validate-maintainers=false --charts helm/trivy
publish-chart:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
needs:
- test-chart
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
with:
fetch-depth: 0
- name: Install chart-releaser
run: |
wget https://github.com/helm/chart-releaser/releases/download/v1.1.1/chart-releaser_1.1.1_linux_amd64.tar.gz
tar xzvf chart-releaser_1.1.1_linux_amd64.tar.gz cr
wget https://github.com/helm/chart-releaser/releases/download/v1.3.0/chart-releaser_1.3.0_linux_amd64.tar.gz
echo "baed2315a9bb799efb71d512c5198a2a3b8dcd139d7f22f878777cffcd649a37 chart-releaser_1.3.0_linux_amd64.tar.gz" | sha256sum -c -
tar xzvf chart-releaser_1.3.0_linux_amd64.tar.gz cr
- name: Package helm chart
run: |
./cr package ${{ env.CHART_DIR }}
- name: Upload helm chart
# Failed with upload the same version: https://github.com/helm/chart-releaser/issues/101
continue-on-error: true
## Upload the tar in the Releases repository
run: |
./cr upload -o ${{ env.GH_OWNER }} -r ${{ env.HELM_REP }} --token ${{ secrets.ORG_REPO_TOKEN }} -p .cr-release-packages
- name: Index helm chart
run: |
./cr index -o ${{ env.GH_OWNER }} -r ${{ env.HELM_REP }} -c https://${{ env.GH_OWNER }}.github.io/${{ env.HELM_REP }}/ -i index.yaml
- name: Push index file
uses: dmnemec/copy_file_to_another_repo_action@v1.1.1
uses: dmnemec/copy_file_to_another_repo_action@c93037aa10fa8893de271f19978c980d0c1a9b37 #v1.1.1
env:
API_TOKEN_GITHUB: ${{ secrets.ORG_REPO_TOKEN }}
with:

View File

@@ -4,7 +4,7 @@ on:
tags:
- "v*"
env:
GO_VERSION: "1.17"
GO_VERSION: "1.18"
GH_USER: "aqua-bot"
jobs:
release:
@@ -12,11 +12,16 @@ jobs:
runs-on: ubuntu-18.04 # 20.04 doesn't provide createrepo for now
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
permissions:
id-token: write # For cosign
packages: write # For GHCR
contents: read # Not required for public repositories, but for clarity
steps:
- name: Install dependencies
run: |
sudo apt-get -y update
sudo apt-get -y install rpm reprepro createrepo distro-info
- uses: sigstore/cosign-installer@51f8e5c6fce54e46006ae97d73b2b6315f518752
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
@@ -29,11 +34,11 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache Go modules
uses: actions/cache@v2
uses: actions/cache@v3.0.1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
@@ -57,20 +62,19 @@ jobs:
username: ${{ secrets.ECR_ACCESS_KEY_ID }}
password: ${{ secrets.ECR_SECRET_ACCESS_KEY }}
- name: Generate SBOM
uses: CycloneDX/gh-gomod-generate-sbom@v0.3.0
uses: CycloneDX/gh-gomod-generate-sbom@v1
with:
json: true
output: bom.json
version: ^v0
args: mod -licenses -json -output bom.json
version: ^v1
- name: Release
uses: goreleaser/goreleaser-action@v2
with:
version: v0.183.0
version: v1.4.1
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.ORG_REPO_TOKEN }}
- name: Checkout trivy-repo
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: ${{ github.repository_owner }}/trivy-repo
path: trivy-repo

View File

@@ -1,25 +1,23 @@
name: Scan
on: [push, pull_request]
name: Scan vulnerabilities
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
build:
name: Scan Go vulnerabilities
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Run Trivy vulnerability scanner to scan for Critical Vulnerabilities
uses: aquasecurity/trivy-action@master
- name: Run Trivy vulnerability scanner and create GitHub issues
uses: knqyf263/trivy-issue-action@v0.0.3
with:
scan-type: 'fs'
exit-code: '1'
severity: 'CRITICAL'
skip-dirs: integration
- name: Run Trivy vulnerability scanner to scan for Medium and High Vulnerabilities
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
exit-code: '0'
severity: 'HIGH,MEDIUM'
skip-dirs: integration
assignee: knqyf263
severity: CRITICAL
skip-dirs: integration,examples
label: vulnerability
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

85
.github/workflows/semantic-pr.yaml vendored Normal file
View File

@@ -0,0 +1,85 @@
name: "Lint PR title"
on:
pull_request_target:
types:
- opened
- edited
- synchronize
jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types:
feat
fix
docs
style
refactor
perf
test
build
ci
chore
revert
BREAKING
scopes:
vuln
misconf
secret
image
fs
repo
sbom
server
alpine
redhat
alma
rocky
mariner
oracle
debian
ubuntu
amazon
suse
photon
distroless
ruby
php
python
nodejs
rust
dotnet
java
go
os
lang
kubernetes
dockerfile
terraform
cloudformation
docker
podman
containerd
oci
cli
flag
helm
report
db
deps

View File

@@ -10,13 +10,13 @@ on:
- 'LICENSE'
pull_request:
env:
GO_VERSION: "1.17"
GO_VERSION: "1.18"
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
@@ -24,9 +24,9 @@ jobs:
go-version: ${{ env.GO_VERSION }}
- name: Lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3.1.0
with:
version: v1.41
version: v1.45
args: --deadline=30m
- name: Run unit tests
@@ -43,7 +43,7 @@ jobs:
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Run integration tests
run: make test-integration
@@ -65,7 +65,7 @@ jobs:
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
@@ -75,7 +75,7 @@ jobs:
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: v0.164.0
version: v1.4.1
args: release --snapshot --rm-dist --skip-publish
build-documents:
@@ -83,18 +83,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: true
- uses: actions/setup-python@v2
- uses: actions/setup-python@v3
with:
python-version: 3.x
- name: Install dependencies
run: |
pip install mkdocs-material
pip install mike
pip install mkdocs-macros-plugin
pip install -r docs/build/requirements.txt
- name: Configure the git user
run: |
git config user.name "knqyf263"

5
.gitignore vendored
View File

@@ -4,7 +4,7 @@
*.dll
*.so
*.dylib
trivy
/trivy
## chart release
.cr-release-packages
@@ -27,3 +27,6 @@ integration/testdata/fixtures/images
# SBOMs generated during CI
/bom.json
# goreleaser output
dist

View File

@@ -9,7 +9,7 @@ linters-settings:
revive:
ignore-generated-header: true
gocyclo:
min-complexity: 10
min-complexity: 20
dupl:
threshold: 100
goconst:
@@ -19,6 +19,10 @@ linters-settings:
locale: US
goimports:
local-prefixes: github.com/aquasecurity
gosec:
excludes:
- G204
- G402
linters:
disable-all: true
@@ -40,6 +44,7 @@ linters:
- misspell
run:
go: 1.18
skip-files:
- ".*._mock.go$"
- ".*._test.go$"
@@ -53,9 +58,6 @@ issues:
- linters:
- gosec
text: "Deferring unsafe method"
- linters:
- gosec
text: "G204: Subprocess launched with variable"
- linters:
- errcheck
text: "Close` is not checked"

View File

@@ -1,28 +1 @@
Thank you for taking interest in contributing to Trivy!
## Issues
- Feel free to open issues for any reason. When you open a new issue, you'll have to select an issue kind: bug/feature/support and fill the required information based on the selected template.
- Please spend a small amount of time giving due diligence to the issue tracker. Your issue might be a duplicate. If it is, please add your comment to the existing issue.
- Remember that users might search for your issue in the future, so please give it a meaningful title to help others.
- The issue should clearly explain the reason for opening, the proposal if you have any, and any relevant technical information.
## Pull Requests
1. Every Pull Request should have an associated bug or feature issue unless you are fixing a trivial documentation issue.
1. Your PR is more likely to be accepted if it focuses on just one change.
1. Describe what the PR does. There's no convention enforced, but please try to be concise and descriptive. Treat the PR description as a commit message. Titles that starts with "fix"/"add"/"improve"/"remove" are good examples.
1. Please add the associated Issue in the PR description.
1. There's no need to add or tag reviewers.
1. If a reviewer commented on your code or asked for changes, please remember to mark the discussion as resolved after you address it. PRs with unresolved issues should not be merged (even if the comment is unclear or requires no action from your side).
1. Please include a comment with the results before and after your change.
1. Your PR is more likely to be accepted if it includes tests (We have not historically been very strict about tests, but we would like to improve this!).
1. If your PR affects the user experience in some way, please update the Readme and the CLI help accordingly.
## Understand where your pull request belongs
Trivy is composed of several different repositories that work together:
- [Trivy](https://github.com/aquasecurity/trivy) is the client-side, user-facing, command line tool.
- [vuln-list](https://github.com/aquasecurity/vuln-list) is a vulnerabilities database, aggregated from different sources, and normalized for easy consumption. Think of this as the "server" side of the trivy command line tool. **There should be no pull requests to this repo**
- [vuln-list-update](https://github.com/aquasecurity/vuln-list-update) is the code that maintains the vuln-list database.
- [fanal](https://github.com/aquasecurity/fanal) is a library for extracting system information from containers. It is being used by Trivy to find testable subjects in the container image.
See [Issues](https://aquasecurity.github.io/trivy/latest/community/contribute/issue/) and [Pull Requests](https://aquasecurity.github.io/trivy/latest/community/contribute/pr/)

View File

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

12
Dockerfile.protoc Normal file
View File

@@ -0,0 +1,12 @@
FROM golang:1.18.0
# Install protoc (cf. http://google.github.io/proto-lens/installing-protoc.html)
ENV PROTOC_ZIP=protoc-3.19.4-linux-x86_64.zip
RUN apt-get update && apt-get install -y unzip
RUN curl --retry 5 -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/$PROTOC_ZIP \
&& unzip -o $PROTOC_ZIP -d /usr/local bin/protoc \
&& unzip -o $PROTOC_ZIP -d /usr/local 'include/*' \
&& rm -f $PROTOC_ZIP
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

View File

@@ -54,7 +54,13 @@ build:
.PHONY: protoc
protoc:
find ./rpc/ -name "*.proto" -type f -exec protoc --proto_path=$(GOSRC):. --twirp_out=. --twirp_opt=paths=source_relative --go_out=. --go_opt=paths=source_relative {} \;
docker build -t trivy-protoc - < Dockerfile.protoc
docker run --rm -it -v ${PWD}:/app -w /app trivy-protoc make _$@
_protoc:
for path in `find ./rpc/ -name "*.proto" -type f`; do \
protoc --twirp_out=. --twirp_opt=paths=source_relative --go_out=. --go_opt=paths=source_relative $${path} || exit; \
done
.PHONY: install
install:

View File

@@ -22,24 +22,31 @@ Scanner for vulnerabilities in container images, file systems, and Git repositor
`Trivy` (`tri` pronounced like **tri**gger, `vy` pronounced like en**vy**) is a simple and comprehensive scanner for vulnerabilities in container images, file systems, and Git repositories, as well as for configuration issues.
`Trivy` detects vulnerabilities of OS packages (Alpine, RHEL, CentOS, etc.) and language-specific packages (Bundler, Composer, npm, yarn, etc.).
In addition, `Trivy` scans Infrastructure as Code (IaC) files such as Terraform, Dockerfile and Kubernetes, to detect potential configuration issues that expose your deployments to the risk of attack.
`Trivy` also scans hardcoded secrets like passwords, API keys and tokens.
`Trivy` is easy to use. Just install the binary and you're ready to scan.
<p align="center">
<figure style="text-aligh: center">
<img src="docs/imgs/overview.png" width="800" alt="Trivy Overview">
</p>
</figure>
### Demo: Vulnerability Detection (Container Image)
<p align="center">
<figure style="text-aligh: center">
<img src="docs/imgs/vuln-demo.gif" width="1000" alt="Vulnerability Detection">
</p>
</figure>
### Demo: Misconfiguration Detection (IaC Files)
<p align="center">
<figure style="text-aligh: center">
<img src="docs/imgs/misconf-demo.gif" width="1000" alt="Misconfiguration Detection">
</p>
</figure>
### Demo: Secret Detection
<figure style="text-aligh: center">
<img src="docs/imgs/secret-demo.gif" width="1000">
</figure>
# Quick Start
## Scan Image for Vulnerabilities
## Scan Image for Vulnerabilities and Secrets
Simply specify an image name (and a tag).
```
@@ -72,17 +79,17 @@ Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 1, HIGH: 0, CRITICAL: 0)
```
</details>
## Scan Filesystem for Vulnerabilities and Misconfigurations
## Scan Filesystem for Vulnerabilities, Secrets and Misconfigurations
Simply specify a directory to scan.
```bash
$ trivy fs --security-checks vuln,config [YOUR_PROJECT_DIR]
$ trivy fs --security-checks vuln,secret,config [YOUR_PROJECT_DIR]
```
For example:
```bash
$ trivy fs --security-checks vuln,config myproject/
$ trivy fs --security-checks vuln,secret,config myproject/
```
<details>
@@ -165,12 +172,16 @@ Failures: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0)
# Features
- Comprehensive vulnerability detection
- OS packages (Alpine Linux, Red Hat Universal Base Image, Red Hat Enterprise Linux, CentOS, Oracle Linux, Debian, Ubuntu, Amazon Linux, openSUSE Leap, SUSE Enterprise Linux, Photon OS and Distroless)
- OS packages (Alpine Linux, Red Hat Universal Base Image, Red Hat Enterprise Linux, CentOS, AlmaLinux, Rocky Linux, CBL-Mariner, Oracle Linux, Debian, Ubuntu, Amazon Linux, openSUSE Leap, SUSE Enterprise Linux, Photon OS and Distroless)
- **Language-specific packages** (Bundler, Composer, Pipenv, Poetry, npm, yarn, Cargo, NuGet, Maven, and Go)
- Misconfiguration detection (IaC scanning)
- A wide variety of built-in policies are provided **out of the box**
- Kubernetes, Docker, Terraform, and more coming soon
- Support custom policies
- Secret detection
- A wide variety of built-in rules are provided **out of the box**
- Support custom rules
- Scan container images at high speed
- Simple
- Specify only an image name, a path to config files, or an artifact name
- Fast
@@ -185,6 +196,8 @@ Failures: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0)
- **Suitable for CI** such as GitHub Actions, Jenkins, GitLab CI, etc.
- Support multiple targets
- container image, local filesystem and remote git repository
- Supply chain security (SBOM support)
- Support CycloneDX
# Integrations
- [GitHub Actions][action]

View File

@@ -1,7 +1,7 @@
#!/bin/bash
DEBIAN_RELEASES=$(debian-distro-info --supported)
UBUNTU_RELEASES=$(ubuntu-distro-info --supported-esm)
UBUNTU_RELEASES=$(sort -u <(ubuntu-distro-info --supported-esm) <(ubuntu-distro-info --supported))
cd trivy-repo/deb
@@ -9,12 +9,14 @@ for release in ${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
echo "Adding deb package to $release"
reprepro includedeb $release ../../dist/*Linux-64bit.deb
reprepro includedeb $release ../../dist/*Linux-32bit.deb
reprepro includedeb $release ../../dist/*Linux-ARM64.deb
done
git add .

View File

@@ -1,66 +1,72 @@
[
{{- $t_first := true -}}
{{- range . -}}
{{- $target := .Target -}}
{{- range .Vulnerabilities -}}
{{- if $t_first -}}
{{- $t_first = false -}}
{{- else -}}
,
{{- end -}}
{{- $severity := .Severity -}}
{{- if eq $severity "UNKNOWN" -}}
{{- $severity = "INFORMATIONAL" -}}
{{- end -}}
{{- $description := .Description -}}
{{- if gt (len $description ) 1021 -}}
{{- $description = (substr 0 1021 $description) | printf "%v .." -}}
{{- end}}
{
"SchemaVersion": "2018-10-08",
"Id": "{{ $target }}/{{ .VulnerabilityID }}",
"ProductArn": "arn:aws:securityhub:{{ getEnv "AWS_REGION" }}::product/aquasecurity/aquasecurity",
"GeneratorId": "Trivy",
"AwsAccountId": "{{ getEnv "AWS_ACCOUNT_ID" }}",
"Types": [ "Software and Configuration Checks/Vulnerabilities/CVE" ],
"CreatedAt": "{{ getCurrentTime }}",
"UpdatedAt": "{{ getCurrentTime }}",
"Severity": {
"Label": "{{ $severity }}"
},
"Title": "Trivy found a vulnerability to {{ .VulnerabilityID }} in container {{ $target }}",
"Description": {{ escapeString $description | printf "%q" }},
"Remediation": {
"Recommendation": {
"Text": "More information on this vulnerability is provided in the hyperlink",
"Url": "{{ .PrimaryURL }}"
}
},
"ProductFields": { "Product Name": "Trivy" },
"Resources": [
{
"Type": "Container",
"Id": "{{ $target }}",
"Partition": "aws",
"Region": "{{ getEnv "AWS_REGION" }}",
"Details": {
"Container": { "ImageName": "{{ $target }}" },
"Other": {
"CVE ID": "{{ .VulnerabilityID }}",
"CVE Title": {{ .Title | printf "%q" }},
"PkgName": "{{ .PkgName }}",
"Installed Package": "{{ .InstalledVersion }}",
"Patched Package": "{{ .FixedVersion }}",
"NvdCvssScoreV3": "{{ (index .CVSS "nvd").V3Score }}",
"NvdCvssVectorV3": "{{ (index .CVSS "nvd").V3Vector }}",
"NvdCvssScoreV2": "{{ (index .CVSS "nvd").V2Score }}",
"NvdCvssVectorV2": "{{ (index .CVSS "nvd").V2Vector }}"
{
"Findings": [
{{- $t_first := true -}}
{{- range . -}}
{{- $target := .Target -}}
{{- $image := .Target -}}
{{- if gt (len $image) 127 -}}
{{- $image = $image | regexFind ".{124}$" | printf "...%v" -}}
{{- end}}
{{- range .Vulnerabilities -}}
{{- if $t_first -}}
{{- $t_first = false -}}
{{- else -}}
,
{{- end -}}
{{- $severity := .Severity -}}
{{- if eq $severity "UNKNOWN" -}}
{{- $severity = "INFORMATIONAL" -}}
{{- end -}}
{{- $description := .Description -}}
{{- if gt (len $description ) 512 -}}
{{- $description = (substr 0 512 $description) | printf "%v .." -}}
{{- end}}
{
"SchemaVersion": "2018-10-08",
"Id": "{{ $target }}/{{ .VulnerabilityID }}",
"ProductArn": "arn:aws:securityhub:{{ env "AWS_REGION" }}::product/aquasecurity/aquasecurity",
"GeneratorId": "Trivy/{{ .VulnerabilityID }}",
"AwsAccountId": "{{ env "AWS_ACCOUNT_ID" }}",
"Types": [ "Software and Configuration Checks/Vulnerabilities/CVE" ],
"CreatedAt": "{{ now | date "2006-01-02T15:04:05.999999999Z07:00" }}",
"UpdatedAt": "{{ now | date "2006-01-02T15:04:05.999999999Z07:00" }}",
"Severity": {
"Label": "{{ $severity }}"
},
"Title": "Trivy found a vulnerability to {{ .VulnerabilityID }} in container {{ $target }}",
"Description": {{ escapeString $description | printf "%q" }},
"Remediation": {
"Recommendation": {
"Text": "More information on this vulnerability is provided in the hyperlink",
"Url": "{{ .PrimaryURL }}"
}
},
"ProductFields": { "Product Name": "Trivy" },
"Resources": [
{
"Type": "Container",
"Id": "{{ $target }}",
"Partition": "aws",
"Region": "{{ env "AWS_REGION" }}",
"Details": {
"Container": { "ImageName": "{{ $image }}" },
"Other": {
"CVE ID": "{{ .VulnerabilityID }}",
"CVE Title": {{ .Title | printf "%q" }},
"PkgName": "{{ .PkgName }}",
"Installed Package": "{{ .InstalledVersion }}",
"Patched Package": "{{ .FixedVersion }}",
"NvdCvssScoreV3": "{{ (index .CVSS (sourceID "nvd")).V3Score }}",
"NvdCvssVectorV3": "{{ (index .CVSS (sourceID "nvd")).V3Vector }}",
"NvdCvssScoreV2": "{{ (index .CVSS (sourceID "nvd")).V2Score }}",
"NvdCvssVectorV2": "{{ (index .CVSS (sourceID "nvd")).V2Vector }}"
}
}
}
}
],
"RecordState": "ACTIVE"
}
{{- end -}}
{{- end }}
]
],
"RecordState": "ACTIVE"
}
{{- end -}}
{{- end }}
]
}

View File

@@ -5,30 +5,42 @@ import data.lib.trivy
default ignore = false
nvd_v3_vector = v {
v := input.CVSS.nvd.v3
v := input.CVSS.nvd.V3Vector
}
redhat_v3_vector = v {
v := input.CVSS.redhat.V3Vector
}
# Ignore a vulnerability which requires high privilege
ignore {
cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
cvss_vector.PrivilegesRequired == "High"
nvd_cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
nvd_cvss_vector.PrivilegesRequired == "High"
# Check against RedHat scores as well as NVD
redhat_cvss_vector := trivy.parse_cvss_vector_v3(redhat_v3_vector)
redhat_cvss_vector.PrivilegesRequired == "High"
}
# Ignore a vulnerability which requires user interaction
ignore {
cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
cvss_vector.UserInteraction == "Required"
nvd_cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
nvd_cvss_vector.UserInteraction == "Required"
# Check against RedHat scores as well as NVD
redhat_cvss_vector := trivy.parse_cvss_vector_v3(redhat_v3_vector)
redhat_cvss_vector.UserInteraction == "Required"
}
ignore {
input.PkgName == "openssl"
# Split CVSSv3 vector
cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
nvd_cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
# Evaluate Attack Vector
ignore_attack_vectors := {"Physical", "Local"}
cvss_vector.AttackVector == ignore_attack_vectors[_]
nvd_cvss_vector.AttackVector == ignore_attack_vectors[_]
}
ignore {
@@ -50,11 +62,11 @@ ignore {
input.PkgName == "bash"
# Split CVSSv3 vector
cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
nvd_cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
# Evaluate Attack Vector
ignore_attack_vectors := {"Physical", "Local", "Adjacent"}
cvss_vector.AttackVector == ignore_attack_vectors[_]
nvd_cvss_vector.AttackVector == ignore_attack_vectors[_]
# Evaluate severity
input.Severity == {"LOW", "MEDIUM", "HIGH"}[_]
@@ -64,11 +76,11 @@ ignore {
input.PkgName == "django"
# Split CVSSv3 vector
cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
nvd_cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
# Evaluate Attack Vector
ignore_attack_vectors := {"Physical", "Local"}
cvss_vector.AttackVector == ignore_attack_vectors[_]
nvd_cvss_vector.AttackVector == ignore_attack_vectors[_]
# Evaluate severity
input.Severity == {"LOW", "MEDIUM"}[_]
@@ -86,7 +98,7 @@ ignore {
input.PkgName == "jquery"
# Split CVSSv3 vector
cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
nvd_cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
# Evaluate CWE-ID
deny_cwe_ids := {"CWE-79"} # XSS

View File

@@ -9,7 +9,11 @@ ignore_pkgs := {"bash", "bind-license", "rpm", "vim", "vim-minimal"}
ignore_severities := {"LOW", "MEDIUM"}
nvd_v3_vector = v {
v := input.CVSS.nvd.v3
v := input.CVSS.nvd.V3Vector
}
redhat_v3_vector = v {
v := input.CVSS.redhat.V3Vector
}
ignore {
@@ -22,20 +26,29 @@ ignore {
# Ignore a vulnerability which is not remotely exploitable
ignore {
cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
cvss_vector.AttackVector != "Network"
nvd_cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
nvd_cvss_vector.AttackVector != "Network"
redhat_cvss_vector := trivy.parse_cvss_vector_v3(redhat_v3_vector)
redhat_cvss_vector.AttackVector != "Network"
}
# Ignore a vulnerability which requires high privilege
ignore {
cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
cvss_vector.PrivilegesRequired == "High"
nvd_cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
nvd_cvss_vector.PrivilegesRequired == "High"
redhat_cvss_vector := trivy.parse_cvss_vector_v3(redhat_v3_vector)
redhat_cvss_vector.PrivilegesRequired == "High"
}
# Ignore a vulnerability which requires user interaction
ignore {
cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
cvss_vector.UserInteraction == "Required"
nvd_cvss_vector := trivy.parse_cvss_vector_v3(nvd_v3_vector)
nvd_cvss_vector.UserInteraction == "Required"
redhat_cvss_vector := trivy.parse_cvss_vector_v3(redhat_v3_vector)
redhat_cvss_vector.UserInteraction == "Required"
}
# Ignore CSRF

View File

@@ -13,7 +13,8 @@
"type": "issue",
"check_name": "container_scanning",
"categories": [ "Security" ],
"description": "{{ .VulnerabilityID }}: {{ .Title }}",
"description": {{ list .VulnerabilityID .PkgName .InstalledVersion .Title | join " - " | printf "%q" }},
"fingerprint": "{{ list .VulnerabilityID .PkgName .InstalledVersion $target | join "" | sha1sum }}",
"content": {{ .Description | printf "%q" }},
"severity": {{ if eq .Severity "LOW" -}}
"info"
@@ -27,12 +28,44 @@
"info"
{{- end }},
"location": {
"path": "{{ .PkgName }}-{{ .InstalledVersion }}",
"path": "{{ $target }}",
"lines": {
"begin": 1
"begin": 0
}
}
}
{{- end -}}
{{- range .Misconfigurations -}}
{{- if $t_first -}}
{{- $t_first = false -}}
{{ else -}}
,
{{- end }}
{
"type": "issue",
"check_name": "container_scanning",
"categories": [ "Security" ],
"description": {{ list .ID .Title | join ": " | printf "%q" }},
"fingerprint": "{{ list .ID .Title $target | join "" | sha1sum }}",
"content": {{ .Description | printf "%q" }},
"severity": {{ if eq .Severity "LOW" -}}
"info"
{{- else if eq .Severity "MEDIUM" -}}
"minor"
{{- else if eq .Severity "HIGH" -}}
"major"
{{- else if eq .Severity "CRITICAL" -}}
"critical"
{{- else -}}
"info"
{{- end }},
"location": {
"path": "{{ $target }}",
"lines": {
"begin": {{ .IacMetadata.StartLine }}
}
}
}
{{- end -}}
{{- end }}
]
]

View File

@@ -52,7 +52,7 @@
}
a.toggle-more-links { cursor: pointer; }
</style>
<title>{{- escapeXML ( index . 0 ).Target }} - Trivy Report - {{ getCurrentTime }}</title>
<title>{{- escapeXML ( index . 0 ).Target }} - Trivy Report - {{ now }} </title>
<script>
window.onload = function() {
document.querySelectorAll('td.links').forEach(function(linkCell) {
@@ -82,7 +82,7 @@
</script>
</head>
<body>
<h1>{{- escapeXML ( index . 0 ).Target }} - Trivy Report - {{ getCurrentTime }}</h1>
<h1>{{- escapeXML ( index . 0 ).Target }} - Trivy Report - {{ now }}</h1>
<table>
{{- range . }}
<tr class="group-header"><th colspan="6">{{ escapeXML .Type }}</th></tr>
@@ -112,6 +112,31 @@
</tr>
{{- end }}
{{- end }}
{{- if (eq (len .Misconfigurations ) 0) }}
<tr><th colspan="6">No Misconfigurations found</th></tr>
{{- else }}
<tr class="sub-header">
<th>Type</th>
<th>Misconf ID</th>
<th>Check</th>
<th>Severity</th>
<th>Message</th>
</tr>
{{- range .Misconfigurations }}
<tr class="severity-{{ escapeXML .Severity }}">
<td class="misconf-type">{{ escapeXML .Type }}</td>
<td>{{ escapeXML .ID }}</td>
<td class="misconf-check">{{ escapeXML .Title }}</td>
<td class="severity">{{ escapeXML .Severity }}</td>
<td class="link" data-more-links="off" style="white-space:normal;"">
{{ escapeXML .Message }}
<br>
<a href={{ escapeXML .PrimaryURL | printf "%q" }}>{{ escapeXML .PrimaryURL }}</a>
</br>
</td>
</tr>
{{- end }}
{{- end }}
{{- end }}
</table>
{{- else }}

View File

@@ -182,11 +182,11 @@ log_tag() {
}
log_debug() {
log_priority 7 || return 0
echoerr "$(log_prefix)" "$(log_tag 7)" "$@"
echo "$(log_prefix)" "$(log_tag 7)" "$@"
}
log_info() {
log_priority 6 || return 0
echoerr "$(log_prefix)" "$(log_tag 6)" "$@"
echo "$(log_prefix)" "$(log_tag 6)" "$@"
}
log_err() {
log_priority 3 || return 0

View File

@@ -14,5 +14,18 @@
</testcase>
{{- end }}
</testsuite>
{{- $failures := len .Misconfigurations }}
<testsuite tests="{{ $failures }}" failures="{{ $failures }}" name="{{ .Target }}" errors="0" skipped="0" time="">
{{- if not (eq .Type "") }}
<properties>
<property name="type" value="{{ .Type }}"></property>
</properties>
{{- end -}}
{{ range .Misconfigurations }}
<testcase classname="{{ .Type }}" name="[{{ .Severity }}] {{ .ID }}" time="">
<failure message="{{ escapeXML .Title }}" type="description">{{ escapeXML .Description }}</failure>
</testcase>
{{- end }}
</testsuite>
{{- end }}
</testsuites>

View File

@@ -1,95 +0,0 @@
{
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"version": "2.1.0",
"runs": [
{
"tool": {
"driver": {
"name": "Trivy",
"informationUri": "https://github.com/aquasecurity/trivy",
"fullName": "Trivy Vulnerability Scanner",
"version": "0.15.0",
"rules": [
{{- $t_first := true }}
{{- range $result := . }}
{{- $vulnerabilityType := .Type }}
{{- range .Vulnerabilities -}}
{{- if $t_first -}}
{{- $t_first = false -}}
{{ else -}}
,
{{- end }}
{
"id": {{ printf "%s: %s-%s %s" $result.Target .PkgName .InstalledVersion .VulnerabilityID | toJson }},
"name": "{{ toSarifRuleName $vulnerabilityType }}",
"shortDescription": {
"text": {{ printf "%v Package: %v" .VulnerabilityID .PkgName | printf "%q" }}
},
"fullDescription": {
"text": {{ endWithPeriod (escapeString .Title) | printf "%q" }}
},
"defaultConfiguration": {
"level": "{{ toSarifErrorLevel .Vulnerability.Severity }}"
}
{{- with $help_uri := .PrimaryURL -}}
,
{{ $help_uri | printf "\"helpUri\": %q," -}}
{{- else -}}
,
{{- end }}
"help": {
"text": {{ printf "Vulnerability %v\nSeverity: %v\nPackage: %v\nInstalled Version: %v\nFixed Version: %v\nLink: [%v](%v)" .VulnerabilityID .Vulnerability.Severity .PkgName .InstalledVersion .FixedVersion .VulnerabilityID .PrimaryURL | printf "%q"}},
"markdown": {{ printf "**Vulnerability %v**\n| Severity | Package | Installed Version | Fixed Version | Link |\n| --- | --- | --- | --- | --- |\n|%v|%v|%v|%v|[%v](%v)|\n" .VulnerabilityID .Vulnerability.Severity .PkgName .InstalledVersion .FixedVersion .VulnerabilityID .PrimaryURL | printf "%q"}}
},
"properties": {
"tags": [
"vulnerability",
"{{ .Vulnerability.Severity }}",
{{ .PkgName | printf "%q" }}
],
"precision": "very-high"
}
}
{{- end -}}
{{- end -}}
]
}
},
"results": [
{{- $t_first := true }}
{{- range $result := . }}
{{- $filePath := .Target }}
{{- range $index, $vulnerability := .Vulnerabilities -}}
{{- if $t_first -}}
{{- $t_first = false -}}
{{ else -}}
,
{{- end }}
{
"ruleId": {{ printf "%s: %s-%s %s" $result.Target .PkgName .InstalledVersion .VulnerabilityID | toJson }},
"ruleIndex": {{ $index }},
"level": "{{ toSarifErrorLevel $vulnerability.Vulnerability.Severity }}",
"message": {
"text": {{ endWithPeriod (escapeString $vulnerability.Description) | printf "%q" }}
},
"locations": [{
"physicalLocation": {
"artifactLocation": {
"uri": "{{ toPathUri $filePath }}",
"uriBaseId": "ROOTPATH"
}
}
}]
}
{{- end -}}
{{- end -}}
],
"columnKind": "utf16CodeUnits",
"originalUriBaseIds": {
"ROOTPATH": {
"uri": "/"
}
}
}
]
}

View File

@@ -1,57 +0,0 @@
# Air-Gapped Environment
Trivy can be used in air-gapped environments.
## Download the vulnerability database
At first, you need to download the vulnerability database for use in air-gapped environments.
Go to [trivy-db][trivy-db] and download `trivy-offline.db.tgz` in the latest release.
If you download `trivy-light-offline.db.tgz`, you have to run Trivy with `--light` option.
```
$ wget https://github.com/aquasecurity/trivy-db/releases/latest/download/trivy-offline.db.tgz
```
## Transfer the DB file into the air-gapped environment
The way of transfer depends on the environment.
```
$ rsync -av -e ssh /path/to/trivy-offline.db.tgz [user]@[host]:dst
```
## Put the DB file in Trivy's cache directory
You have to know where to put the DB file. The following command shows the default cache directory.
```
$ ssh user@host
$ trivy -h | grep cache
--cache-dir value cache directory (default: "/home/myuser/.cache/trivy") [$TRIVY_CACHE_DIR]
```
Put the DB file in the cache directory + `/db`.
```
$ mkdir -p /home/myuser/.cache/trivy/db
$ cd /home/myuser/.cache/trivy/db
$ mv /path/to/trivy-offline.db.tgz .
```
Then, decompress it.
`trivy-offline.db.tgz` file includes two files, `trivy.db` and `metadata.json`.
```
$ tar xvf trivy-offline.db.tgz
x trivy.db
x metadata.json
$ rm trivy-offline.db.tgz
```
In an air-gapped environment it is your responsibility to update the Trivy database on a regular basis, so that the scanner can detect recently-identified vulnerabilities.
## Run Trivy with --skip-update option
In an air-gapped environment, specify `--skip-update` so that Trivy doesn't attempt to download the latest database file.
```
$ trivy image --skip-update alpine:3.12
```
[trivy-db]: https://github.com/aquasecurity/trivy-db/releases

View File

@@ -1,2 +0,0 @@
# Advanced
This section describes advanced features, integrations, etc.

View File

@@ -1,7 +0,0 @@
Trivy uses Google Cloud SDK. You don't need to install `gcloud` command.
If you want to use target project's repository, you can settle via `GOOGLE_APPLICATION_CREDENTIAL`.
```bash
# must set TRIVY_USERNAME empty char
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credential.json
```

View File

@@ -1,4 +1,4 @@
FROM squidfunk/mkdocs-material:7.0.6
FROM squidfunk/mkdocs-material:8.2.10
## If you want to see exactly the same version as is published to GitHub pages
## use a private image for insiders, which requires authentication.
@@ -6,4 +6,5 @@ FROM squidfunk/mkdocs-material:7.0.6
# docker login -u ${GITHUB_USERNAME} -p ${GITHUB_TOKEN} ghcr.io
# FROM ghcr.io/squidfunk/mkdocs-material-insiders
RUN pip install mike mkdocs-macros-plugin
COPY requirements.txt .
RUN pip install -r requirements.txt

30
docs/build/requirements.txt vendored Normal file
View File

@@ -0,0 +1,30 @@
click==8.1.2
csscompressor==0.9.5
ghp-import==2.0.2
htmlmin==0.1.12
importlib-metadata==4.11.3
Jinja2==3.1.1
jsmin==3.0.1
Markdown==3.3.6
MarkupSafe==2.1.1
mergedeep==1.3.4
mike==1.1.2
mkdocs==1.3.0
mkdocs-macros-plugin==0.7.0
mkdocs-material==8.2.10
mkdocs-material-extensions==1.0.3
mkdocs-minify-plugin==0.5.0
mkdocs-redirects==1.0.4
packaging==21.3
Pygments==2.11.2
pymdown-extensions==9.3
pyparsing==3.0.8
python-dateutil==2.8.2
PyYAML==6.0
pyyaml-env-tag==0.1
six==1.16.0
termcolor==1.1.0
verspec==0.1.0
watchdog==2.1.7
zipp==3.8.0

21
docs/community/cks.md Normal file
View File

@@ -0,0 +1,21 @@
# CKS preparation resources
Community Resources
- [Trivy Video overview (short)][overview]
- [Example questions from the exam][exam]
- [More example questions][questions]
Aqua Security Blog posts
- Supply chain security best [practices][supply-chain-best-practices]
- Supply chain [attacks][supply-chain-attacks]
-
If you know of interesting resources, please start a PR to add those to the list.
[overview]: https://youtu.be/2cjH6Zkieys
[exam]: https://jonathan18186.medium.com/certified-kubernetes-security-specialist-cks-preparation-part-7-supply-chain-security-9cf62c34cf6a
[questions]: https://github.com/kodekloudhub/certified-kubernetes-security-specialist-cks-course/blob/main/docs/06-Supply-Chain-Security/09-Scan-images-for-known-vulnerabilities-(Trivy).md
[supply-chain-best-practices]: https://blog.aquasec.com/supply-chain-security-best-practices
[supply-chain-attacks]: https://blog.aquasec.com/supply-chain-threats-using-container-images

View File

@@ -0,0 +1,31 @@
Thank you for taking interest in contributing to Trivy!
- Feel free to open issues for any reason. When you open a new issue, you'll have to select an issue kind: bug/feature/support and fill the required information based on the selected template.
- Please spend a small amount of time giving due diligence to the issue tracker. Your issue might be a duplicate. If it is, please add your comment to the existing issue.
- Remember that users might search for your issue in the future, so please give it a meaningful title to help others.
- The issue should clearly explain the reason for opening, the proposal if you have any, and any relevant technical information.
## Wrong detection
Trivy depends on [multiple data sources](https://aquasecurity.github.io/trivy/latest/docs/vulnerability/detection/data-source/).
Sometime these databases contain mistakes.
If Trivy can't detect any CVE-IDs or shows false positive result, at first please follow the next steps:
1. Run Trivy with `-f json` that shows data sources.
2. According to the shown data source, make sure that the security advisory in the data source is correct.
If the data source is correct and Trivy shows wrong results, please raise an issue on Trivy.
### GitHub Advisory Database
Visit [here](https://github.com/advisories) and search CVE-ID.
If you find a problem, it'll be nice to fix it: [How to contribute to a GitHub security advisory](https://github.blog/2022-02-22-github-advisory-database-now-open-to-community-contributions/)
### GitLab Advisory Database
Visit [here](https://advisories.gitlab.com/) and search CVE-ID.
If you find a problem, it'll be nice to fix it: [Create an issue to GitLab Advisory Database](https://gitlab.com/gitlab-org/security-products/gemnasium-db/-/issues/new)
### Red Hat CVE Database
Visit [here](https://access.redhat.com/security/security-updates/?cwe=476#/cve) and search CVE-ID.

View File

@@ -0,0 +1,164 @@
Thank you for taking interest in contributing to Trivy!
1. Every Pull Request should have an associated bug or feature issue unless you are fixing a trivial documentation issue.
1. Please add the associated Issue link in the PR description.
1. Your PR is more likely to be accepted if it focuses on just one change.
1. There's no need to add or tag reviewers.
1. If a reviewer commented on your code or asked for changes, please remember to respond with comment. Do not mark discussion as resolved. It's up to reviewer to mark it resolved (in case if suggested fix addresses problem properly). PRs with unresolved issues should not be merged (even if the comment is unclear or requires no action from your side).
1. Please include a comment with the results before and after your change.
1. Your PR is more likely to be accepted if it includes tests (We have not historically been very strict about tests, but we would like to improve this!).
1. If your PR affects the user experience in some way, please update the README.md and the CLI help accordingly.
### Title
It is not that strict, but we use the title conventions in this repository.
Each commit message doesn't have to follow the conventions as long as it is clear and descriptive since it will be squashed and merged.
#### Format of the title
```
<type>(<scope>): <subject>
```
The `type` and `scope` should always be lowercase as shown below.
**Allowed `<type>` values:**
- **feat** for a new feature for the user, not a new feature for build script. Such commit will trigger a release bumping a MINOR version.
- **fix** for a bug fix for the user, not a fix to a build script. Such commit will trigger a release bumping a PATCH version.
- **perf** for performance improvements. Such commit will trigger a release bumping a PATCH version.
- **docs** for changes to the documentation.
- **style** for formatting changes, missing semicolons, etc.
- **refactor** for refactoring production code, e.g. renaming a variable.
- **test** for adding missing tests, refactoring tests; no production code change.
- **build** for updating build configuration, development tools or other changes irrelevant to the user.
- **chore** for updates that do not apply to the above, such as dependency updates.
- **ci** for changes to CI configuration files and scripts
- **revert** for revert to a previous commit
**Allowed `<scope>` values:**
checks:
- vuln
- misconf
- secret
mode:
- image
- fs
- repo
- sbom
- server
os:
- alpine
- redhat
- alma
- rocky
- mariner
- oracle
- debian
- ubuntu
- amazon
- suse
- photon
- distroless
language:
- ruby
- php
- python
- nodejs
- rust
- dotnet
- java
- go
vuln:
- os
- lang
config:
- kubernetes
- dockerfile
- terraform
- cloudformation
container
- docker
- podman
- containerd
- oci
cli:
- cli
- flag
others:
- helm
- report
- db
- 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.
#### Example titles
```
feat(alma): add support for AlmaLinux
```
```
fix(oracle): handle advisories with ksplice versions
```
```
docs(misconf): add comparison with Conftest and TFsec
```
```
chore(deps): bump go.uber.org/zap from 1.19.1 to 1.20.0
```
**NOTE**: please do not use `chore(deps): update fanal` and something like that if you add new features or fix bugs in Trivy-related projects.
The PR title should describe what the PR adds or fixes even though it just updates the dependency in Trivy.
### Unit tests
Your PR must pass all the unit tests. You can test it as below.
```
$ make test
```
### Integration tests
Your PR must pass all the integration tests. You can test it as below.
```
$ make test-integration
```
### Documentation
You can build the documents as below and view it at http://localhost:8000.
```
$ make mkdocs-serve
```
## Understand where your pull request belongs
Trivy is composed of several repositories that work together:
- [Trivy](https://github.com/aquasecurity/trivy) is the client-side, user-facing, command line tool.
- [vuln-list](https://github.com/aquasecurity/vuln-list) is a vulnerabilities database, aggregated from different sources, and normalized for easy consumption. Think of this as the "server" side of the trivy command line tool. **There should be no pull requests to this repo**
- [vuln-list-update](https://github.com/aquasecurity/vuln-list-update) is the code that maintains the vuln-list database.
- [trivy-db](https://github.com/aquasecurity/trivy-db) maintains the vulnerability database pulled by Trivy CLI.
- [fanal](https://github.com/aquasecurity/fanal) is a library for extracting system information from containers. It is being used by Trivy to find testable subjects in the container image.
- [go-dep-parser](https://github.com/aquasecurity/go-dep-parser) is a library for parsing lock files such as package-lock.json and Gemfile.lock.

View File

@@ -1,7 +1,10 @@
# Triage
Triage is an important part of maintaining the health of the trivy repo.
A well organized repo allows maintainers to prioritize feature requests, fix bugs, and respond to users facing difficulty with the tool as quickly as possible.
Triage includes:
- Labeling issues
- Responding to issues
- Closing issues
@@ -185,7 +188,7 @@ We use two labels [help wanted](https://github.com/aquasecurity/trivy/issues?q=i
and [good first issue](https://github.com/aquasecurity/trivy/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
to identify issues that have been specially groomed for new contributors.
We have specific [guidelines](/docs/advanced/contribd/contrib/help-wanted.md)
We have specific [guidelines](/docs/docs/advanced/contribd/contrib/help-wanted.md)
for how to use these labels. If you see an issue that satisfies these
guidelines, you can add the `help wanted` label and the `good first issue` label.
Please note that adding the `good first issue` label must also

View File

@@ -0,0 +1,48 @@
# Additional References
There are external blogs and evaluations.
## Blogs
- [Trivy Vulnerability Scanner Joins the Aqua Open-source Family][join]
- [Trivy Image Vulnerability Scanner Now Under Apache 2.0 License][license]
- [DevSecOps with Trivy and GitHub Actions][actions]
- [Find Image Vulnerabilities Using GitHub and Aqua Security Trivy Action][actions2]
- [Using Trivy to Discover Vulnerabilities in VS Code Projects][vscode]
- [the vulnerability remediation lifecycle of Alpine containers][alpine]
- [Continuous Container Vulnerability Testing with Trivy][semaphore]
- [Open Source CVE Scanner Round-Up: Clair vs Anchore vs Trivy][round-up]
- [Docker Image Security: Static Analysis Tool Comparison Anchore Engine vs Clair vs Trivy][tool-comparison]
## Links
- [Research Spike: evaluate Trivy for scanning running containers][gitlab]
- [Istio evaluates scanners][istio]
## Presentations
- Aqua Security YouTube Channel
- [Trivy - container image scanning][intro]
- [Using Trivy in client server mode][server]
- [Tweaking Trivy output to fit your workflow][tweaking]
- [How does a vulnerability scanner identify packages?][identify]
- CNCF Webinar 2020
- [Trivy Open Source Scanner for Container Images Just Download and Run!][cncf]
- KubeCon + CloudNativeCon Europe 2020 Virtual
- [Handling Container Vulnerabilities with Open Policy Agent - Teppei Fukuda, Aqua Security][kubecon]
[alpine]: https://ariadne.space/2021/06/08/the-vulnerability-remediation-lifecycle-of-alpine-containers/
[semaphore]: https://semaphoreci.com/blog/continuous-container-vulnerability-testing-with-trivy
[round-up]: https://boxboat.com/2020/04/24/image-scanning-tech-compared/
[tool-comparison]: https://www.a10o.net/devsecops/docker-image-security-static-analysis-tool-comparison-anchore-engine-vs-clair-vs-trivy/
[gitlab]: https://gitlab.com/gitlab-org/gitlab/-/issues/270888
[istio]: https://github.com/istio/release-builder/pull/687#issuecomment-874938417
[intro]: https://www.youtube.com/watch?v=AzOBGm7XxOA
[cncf]: https://www.youtube.com/watch?v=XnYxX9uueoQ
[server]: https://www.youtube.com/watch?v=tNQ-VlahtYM
[kubecon]: https://www.youtube.com/watch?v=WKE2XNZ2zr4
[identify]: https://www.youtube.com/watch?v=PaMnzeHBa8M
[tweaking]: https://www.youtube.com/watch?v=wFIGUjcRLnU
[join]: https://blog.aquasec.com/trivy-vulnerability-scanner-joins-aqua-family
[license]: https://blog.aquasec.com/trivy-open-source-vulnerability-scanner-apache2.0-license
[actions]: https://blog.aquasec.com/devsecops-with-trivy-github-actions
[actions2]: https://blog.aquasec.com/github-vulnerability-scanner-trivy
[vscode]: https://blog.aquasec.com/trivy-open-source-vulnerability-scanner-vs-code

37
docs/community/tools.md Normal file
View File

@@ -0,0 +1,37 @@
# Community Tools
The open source community has been hard at work developing new tools for Trivy. You can check out some of them here.
Have you created a tool thats not listed? Add the name and description of your integration and open a pull request in the GitHub repository to get your change merged.
## GitHub Actions
| Actions | Description |
| ------------------------------------------ | -------------------------------------------------------------------------------- |
| [gitrivy][gitrivy] | GitHub Issue + Trivy |
| [trivy-github-issues][trivy-github-issues] | GitHub Actions for creating GitHub Issues according to the Trivy scanning result |
## Semaphore
| Name | Description |
| -------------------------------------------------------| ----------------------------------------- |
| [Continuous Vulnerability Testing with Trivy][semaphore-tutorial] | Tutorial on scanning code, containers, infrastructure, and Kubernetes with Semaphore CI/CD. |
## CircleCI
| Orb | Description |
| -----------------------------------------| ----------------------------------------- |
| [fifteen5/trivy-orb][fifteen5/trivy-orb] | Orb for running Trivy, a security scanner |
## Others
| Name | Description |
| -----------------------------------------| ----------------------------------------- |
| [Trivy Vulnerability Explorer][explorer] | Explore trivy vulnerability reports in your browser and create .trivyignore files interactively. Can be integrated in your CI/CD tooling with deep links. |
[trivy-github-issues]: https://github.com/marketplace/actions/trivy-github-issues
[fifteen5/trivy-orb]: https://circleci.com/developer/orbs/orb/fifteen5/trivy-orb
[gitrivy]: https://github.com/marketplace/actions/trivy-action
[explorer]: https://dbsystel.github.io/trivy-vulnerability-explorer/
[semaphore-tutorial]: https://semaphoreci.com/blog/continuous-container-vulnerability-testing-with-trivy

View File

@@ -0,0 +1,113 @@
# Air-Gapped Environment
Trivy can be used in air-gapped environments. Note that an allowlist is [here][allowlist].
## Air-Gapped Environment for vulnerabilities
### Download the vulnerability database
At first, you need to download the vulnerability database for use in air-gapped environments.
Please follow [oras installation instruction][oras].
Download `db.tar.gz`:
```
$ oras pull ghcr.io/aquasecurity/trivy-db:2 -a
```
### Transfer the DB file into the air-gapped environment
The way of transfer depends on the environment.
```
$ rsync -av -e ssh /path/to/db.tar.gz [user]@[host]:dst
```
### Put the DB file in Trivy's cache directory
You have to know where to put the DB file. The following command shows the default cache directory.
```
$ ssh user@host
$ trivy -h | grep cache
--cache-dir value cache directory (default: "/home/myuser/.cache/trivy") [$TRIVY_CACHE_DIR]
```
Put the DB file in the cache directory + `/db`.
```
$ mkdir -p /home/myuser/.cache/trivy/db
$ cd /home/myuser/.cache/trivy/db
$ tar xvf /path/to/db.tar.gz -C /home/myuser/.cache/trivy/db
x trivy.db
x metadata.json
$ rm /path/to/db.tar.gz
```
In an air-gapped environment it is your responsibility to update the Trivy database on a regular basis, so that the scanner can detect recently-identified vulnerabilities.
### Run Trivy with --skip-update and --offline-scan option
In an air-gapped environment, specify `--skip-update` so that Trivy doesn't attempt to download the latest database file.
In addition, if you want to scan Java dependencies such as JAR and pom.xml, you need to specify `--offline-scan` since Trivy tries to issue API requests for scanning Java applications by default.
```
$ trivy image --skip-update --offline-scan alpine:3.12
```
## Air-Gapped Environment for misconfigurations
### Download misconfiguration policies
At first, you need to download misconfiguration policies for use in air-gapped environments.
Please follow [oras installation instruction][oras].
Download `bundle.tar.gz`:
```
$ oras pull ghcr.io/aquasecurity/appshield:latest -a
```
### Transfer misconfiguration policies into the air-gapped environment
The way of transfer depends on the environment.
```
$ rsync -av -e ssh /path/to/bundle.tar.gz [user]@[host]:dst
```
### Put the misconfiguration policies in Trivy's cache directory
You have to know where to put the misconfiguration policies file. The following command shows the default cache directory.
```
$ ssh user@host
$ trivy -h | grep cache
--cache-dir value cache directory (default: "/home/myuser/.cache/trivy") [$TRIVY_CACHE_DIR]
```
Put the misconfiguration policies file in the cache directory + `/policy/content`.
```
$ mkdir -p /home/myuser/.cache/trivy/policy/content
$ cd /home/myuser/.cache/trivy/policy/content
$ mv /path/to/bundle.tar.gz .
```
Then, decompress it.
`bundle.tar.gz ` file includes two folders: `docker`, `kubernetes` and file: `.manifest`.
```
$ tar xvf bundle.tar.gz
x ./docker/
...
x ./kubernetes/
...
x ./.manifest
$ rm bundle.tar.gz
```
In an air-gapped environment it is your responsibility to update policies on a regular basis, so that the scanner can detect recently-identified misconfigurations.
### 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.
```
$ trivy conf --skip-policy-update /path/to/conf
```
[allowlist]: ../references/troubleshooting.md
[oras]: https://oras.land/cli/

View File

@@ -1,6 +1,6 @@
# Unpacked Filesystem
Scan aan unpacked container image filesystem.
Scan an unpacked container image filesystem.
In this case, Trivy works the same way when scanning containers

View File

@@ -0,0 +1,27 @@
# Requirements
None, Trivy uses Azure SDK for Go. You don't need to install `az` command.
# Privileges
Service principal must have the `AcrPull` permissions.
## Creation of a service principal
```bash
export SP_DATA=$(az ad sp create-for-rbac --name TrivyTest --role AcrPull --scope "/subscriptions/<subscription_id>/resourceGroups/<resource_group>/providers/Microsoft.ContainerRegistry/registries/<registry_name>")
```
# Usage
```bash
# must set TRIVY_USERNAME empty char
export AZURE_CLIENT_ID$(echo $SP_DATA | jq -r .appId)
export AZURE_CLIENT_SECRET$(echo $SP_DATA | jq -r .password)
export AZURE_TENANT_ID$(echo $SP_DATA | jq -r .tenant)
```
# Testing
You can test credentials in the following manner.
```bash
docker run -it --rm -v /tmp:/tmp\
-e AZURE_CLIENT_ID=${AZURE_CLIENT_ID} -e AZURE_CLIENT_SECRET=${AZURE_CLIENT_SECRET} \
-e AZURE_TENANT_ID=${AZURE_TENANT_ID} aquasec/trivy image your_special_project.azurecr.io/your_special_image:your_special_tag
```

View File

@@ -0,0 +1,40 @@
# Requirements
None, Trivy uses Google Cloud SDK. You don't need to install `gcloud` command.
# Privileges
Credential file must have the `roles/storage.objectViewer` permissions.
More information can be found in [Google's documentation](https://cloud.google.com/container-registry/docs/access-control)
## JSON File Format
The JSON file specified should have the following format provided by google's service account mechanisms:
```json
{
"type": "service_account",
"project_id": "your_special_project",
"private_key_id": "XXXXXXXXXXXXXXXXXXXXxx",
"private_key": "-----BEGIN PRIVATE KEY-----\nNONONONO\n-----END PRIVATE KEY-----\n",
"client_email": "somedude@your_special_project.iam.gserviceaccount.com",
"client_id": "1234567890",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/somedude%40your_special_project.iam.gserviceaccount.com"
}
```
# Usage
If you want to use target project's repository, you can set them via `GOOGLE_APPLICATION_CREDENTIALS`.
```bash
# must set TRIVY_USERNAME empty char
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credential.json
```
# Testing
You can test credentials in the following manner (assuming they are in `/tmp` on host machine).
```bash
docker run -it --rm -v /tmp:/tmp\
-e GOOGLE_APPLICATION_CREDENTIALS=/tmp/service_account.json\
aquasec/trivy image gcr.io/your_special_project/your_special_image:your_special_tag
```

85
docs/docs/index.md Normal file
View File

@@ -0,0 +1,85 @@
# Docs
Trivy detects two types of security issues:
- [Vulnerabilities][vuln]
- [Misconfigurations][misconf]
Trivy can scan three different artifacts:
- [Container Images][container]
- [Filesystem][filesystem] and [Rootfs][rootfs]
- [Git Repositories][repo]
Trivy can be run in two different modes:
- [Standalone][standalone]
- [Client/Server][client-server]
It is designed to be used in CI. Before pushing to a container registry or deploying your application, you can scan your local container image and other artifacts easily.
See [Integrations][integrations] for details.
## Features
- Comprehensive vulnerability detection
- [OS packages][os] (Alpine, Red Hat Universal Base Image, Red Hat Enterprise Linux, CentOS, AlmaLinux, Rocky Linux, CBL-Mariner, Oracle Linux, Debian, Ubuntu, Amazon Linux, openSUSE Leap, SUSE Enterprise Linux, Photon OS and Distroless)
- [**Language-specific packages**][lang] (Bundler, Composer, Pipenv, Poetry, npm, yarn, Cargo, NuGet, Maven, and Go)
- Detect IaC misconfigurations
- A wide variety of [built-in policies][builtin] are provided **out of the box**:
- Kubernetes
- Docker
- Terraform
- more coming soon
- Support custom policies
- Simple
- Specify only an image name, a directory containing IaC configs, or an artifact name
- See [Quick Start][quickstart]
- Fast
- The first scan will finish within 10 seconds (depending on your network). Consequent scans will finish in single seconds.
- Unlike other scanners that take long to fetch vulnerability information (~10 minutes) on the first run, and encourage you to maintain a durable vulnerability database, Trivy is stateless and requires no maintenance or preparation.
- Easy installation
- `apt-get install`, `yum install` and `brew install` is possible (See [Installation][installation])
- **No pre-requisites** such as installation of DB, libraries, etc.
- High accuracy
- **Especially Alpine Linux and RHEL/CentOS**
- Other OSes are also high
- DevSecOps
- **Suitable for CI** such as Travis CI, CircleCI, Jenkins, GitLab CI, etc.
- See [CI Example][integrations]
- Support multiple formats
- container image
- A local image in Docker Engine which is running as a daemon
- A local image in [Podman][podman] (>=2.0) which is exposing a socket
- A remote image in Docker Registry such as Docker Hub, ECR, GCR and ACR
- A tar archive stored in the `docker save` / `podman save` formatted file
- An image directory compliant with [OCI Image Format][oci]
- local filesystem and rootfs
- remote git repository
- [SBOM][sbom] (Software Bill of Materials) support
- CycloneDX
Please see [LICENSE][license] for Trivy licensing information.
[installation]: ../getting-started/installation.md
[vuln]: ../docs/vulnerability/scanning/index.md
[misconf]: ../docs/misconfiguration/index.md
[container]: ../docs/vulnerability/scanning/image.md
[rootfs]: ../docs/vulnerability/scanning/rootfs.md
[filesystem]: ../docs/vulnerability/scanning/filesystem.md
[repo]: ../docs/vulnerability/scanning/git-repository.md
[standalone]: ../docs/references/modes/standalone.md
[client-server]: ../docs/references/modes/client-server.md
[integrations]: ../docs/integrations/index.md
[os]: ../docs/vulnerability/detection/os.md
[lang]: ../docs/vulnerability/detection/language.md
[builtin]: ../docs/misconfiguration/policy/builtin.md
[quickstart]: ../getting-started/quickstart.md
[podman]: ../docs/advanced/container/podman.md
[sbom]: ../docs/sbom/index.md
[oci]: https://github.com/opencontainers/image-spec
[license]: https://github.com/aquasecurity/trivy/blob/main/LICENSE

View File

@@ -0,0 +1,5 @@
# Bitbucket Pipelines
See [trivy-pipe][trivy-pipe] for the details.
[trivy-pipe]: https://github.com/aquasecurity/trivy-pipe

View File

@@ -19,7 +19,7 @@ jobs:
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
- run:
name: Scan the local image with trivy
command: trivy --exit-code 0 --no-progress trivy-ci-test:${CIRCLE_SHA1}
command: trivy image --exit-code 0 --no-progress trivy-ci-test:${CIRCLE_SHA1}
workflows:
version: 2
release:

View File

@@ -23,6 +23,8 @@ trivy:
# See https://github.com/docker-library/docker/pull/166
DOCKER_TLS_CERTDIR: ""
IMAGE: trivy-ci-test:$CI_COMMIT_SHA
TRIVY_NO_PROGRESS: "true"
TRIVY_CACHE_DIR: ".trivycache/"
before_script:
- export TRIVY_VERSION=$(wget -qO - "https://api.github.com/repos/aquasecurity/trivy/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
- echo $TRIVY_VERSION
@@ -32,11 +34,11 @@ trivy:
# Build image
- docker build -t $IMAGE .
# Build report
- ./trivy --exit-code 0 --cache-dir .trivycache/ --no-progress --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 --exit-code 0 --cache-dir .trivycache/ --no-progress --severity HIGH $IMAGE
- ./trivy image --exit-code 0 --severity HIGH $IMAGE
# Fail on severe vulnerabilities
- ./trivy --exit-code 1 --cache-dir .trivycache/ --severity CRITICAL --no-progress $IMAGE
- ./trivy image --exit-code 1 --severity CRITICAL $IMAGE
cache:
paths:
- .trivycache/
@@ -71,20 +73,22 @@ container_scanning:
TRIVY_USERNAME: "$CI_REGISTRY_USER"
TRIVY_PASSWORD: "$CI_REGISTRY_PASSWORD"
TRIVY_AUTH_URL: "$CI_REGISTRY"
TRIVY_NO_PROGRESS: "true"
TRIVY_CACHE_DIR: ".trivycache/"
FULL_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
script:
- trivy --version
# cache cleanup is needed when scanning images with the same tags, it does not remove the database
- time trivy image --clear-cache
# update vulnerabilities db
- time trivy --download-db-only --no-progress --cache-dir .trivycache/
- time trivy image --download-db-only
# Builds report and puts it in the default workdir $CI_PROJECT_DIR, so `artifacts:` can take it from there
- time trivy --exit-code 0 --cache-dir .trivycache/ --no-progress --format template --template "@/contrib/gitlab.tpl"
- time trivy image --exit-code 0 --format template --template "@/contrib/gitlab.tpl"
--output "$CI_PROJECT_DIR/gl-container-scanning-report.json" "$FULL_IMAGE_NAME"
# Prints full report
- time trivy --exit-code 0 --cache-dir .trivycache/ --no-progress "$FULL_IMAGE_NAME"
- time trivy image --exit-code 0 "$FULL_IMAGE_NAME"
# Fail on critical vulnerabilities
- time trivy --exit-code 1 --cache-dir .trivycache/ --severity CRITICAL --no-progress "$FULL_IMAGE_NAME"
- time trivy image --exit-code 1 --severity CRITICAL "$FULL_IMAGE_NAME"
cache:
paths:
- .trivycache/
@@ -126,6 +130,8 @@ trivy:
# See https://github.com/docker-library/docker/pull/166
DOCKER_TLS_CERTDIR: ""
IMAGE: trivy-ci-test:$CI_COMMIT_SHA
TRIVY_NO_PROGRESS: "true"
TRIVY_CACHE_DIR: ".trivycache/"
before_script:
- export TRIVY_VERSION=$(wget -qO - "https://api.github.com/repos/aquasecurity/trivy/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
- echo $TRIVY_VERSION
@@ -134,15 +140,20 @@ trivy:
script:
# Build image
- docker build -t $IMAGE .
# Build report
- ./trivy --exit-code 0 --cache-dir .trivycache/ --no-progress --format template --template "@contrib/gitlab-codeclimate.tpl" -o gl-codeclimate.json $IMAGE
# Image report
- ./trivy image --exit-code 0 --format template --template "@contrib/gitlab-codequality.tpl" -o gl-codeclimate-image.json $IMAGE
# Filesystem report
- ./trivy filesystem --security-checks config,vuln --exit-code 0 --format template --template "@contrib/gitlab-codequality.tpl" -o gl-codeclimate-fs.json .
# Combine report
- apk update && apk add jq
- jq -s 'add' gl-codeclimate-image.json gl-codeclimate-fs.json > gl-codeclimate.json
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)
artifacts:
paths:
gl-codeclimate.json
- gl-codeclimate.json
reports:
codequality: gl-codeclimate.json
```
@@ -155,3 +166,9 @@ already have a code quality report in your pipeline, you can use
be necessary to rename the artifact if you want to reuse the name. To then
combine the previous artifact with the output of trivy, the following `jq`
command can be used, `jq -s 'add' prev-codeclimate.json trivy-codeclimate.json > gl-codeclimate.json`.
### Gitlab CI alternative template example report
You'll be able to see a full report in the Gitlab pipeline code quality UI, where filesystem vulnerabilities and misconfigurations include links to the flagged files and image vulnerabilities report the image/os or runtime/library that the vulnerability originates from instead.
![codequality](../../imgs/gitlab-codequality.png)

View File

@@ -1,4 +1,2 @@
# Integrations
Scan your image automatically as part of your CI workflow, failing the workflow if a vulnerability is found. When you don't want to fail the test, specify `--exit-code 0`.
Since in automated scenarios such as CI/CD you are only interested in the end result, and not the full report, use the `--light` flag to optimize for this scenario and get fast results.

View File

@@ -15,8 +15,8 @@ before_install:
- wget https://github.com/aquasecurity/trivy/releases/download/v${VERSION}/trivy_${VERSION}_Linux-64bit.tar.gz
- tar zxvf trivy_${VERSION}_Linux-64bit.tar.gz
script:
- ./trivy --exit-code 0 --severity HIGH --no-progress trivy-ci-test:${COMMIT}
- ./trivy --exit-code 1 --severity CRITICAL --no-progress trivy-ci-test:${COMMIT}
- ./trivy image --exit-code 0 --severity HIGH --no-progress trivy-ci-test:${COMMIT}
- ./trivy image --exit-code 1 --severity CRITICAL --no-progress trivy-ci-test:${COMMIT}
cache:
directories:
- $HOME/.cache/trivy

View File

@@ -0,0 +1,25 @@
# vs cfsec
[cfsec][cfsec] uses static analysis of your CloudFormation templates to spot potential security issues.
Trivy uses cfsec internally to scan both JSON and YAML configuration files, but Trivy doesn't support some features provided by cfsec.
This section describes the differences between Trivy and cfsec.
| Feature | Trivy | cfsec |
| --------------------------- | --------------------------------------- | -------------------- |
| Built-in Policies | :material-check: | :material-check: |
| Custom Policies | Rego[^1] | :material-close: |
| Policy Metadata[^2] | :material-check: | :material-check: |
| Show Successes | :material-check: | :material-check: |
| Disable Policies | :material-check: | :material-check: |
| Show Issue Lines | :material-close: | :material-check: |
| View Statistics | :material-close: | :material-check: |
| Filtering by Severity | :material-check: | :material-close: |
| Supported Formats | Dockerfile, JSON, YAML, Terraform, etc. | CloudFormation JSON and YAML |
[^1]: CloudFormation files are not supported
[^2]: To enrich the results such as ID, Title, Description, Severity, etc.
cfsec is designed for CloudFormation.
People who use only want to scan their CloudFormation templates should use cfsec.
People who want to scan a wide range of configuration files should use Trivy.
[cfsec]: https://github.com/aquasecurity/cfsec

View File

@@ -23,4 +23,4 @@ tfsec is designed for Terraform.
People who use only Terraform should use tfsec.
People who want to scan a wide range of configuration files should use Trivy.
[tfsec]: https://github.com/tfsec/tfsec
[tfsec]: https://github.com/aquasecurity/tfsec

View File

@@ -13,13 +13,14 @@ As for `--namespaces` option, the detail is described as below.
### File formats
If a file name matches the following file patterns, Trivy will parse the file and pass it as input to your Rego policy.
| File format | File pattern |
| -------------- | ------------------------------------------------ |
| JSON | `*.json` |
| YAML | `*.yaml` |
| TOML | `*.toml` |
| HCL | `*.hcl`, `*.hcl1`, and `*.hcl2` |
| Dockerfile | `Dockerfile`, `Dockerfile.*`, and `*.Dockerfile` |
| File format | File pattern |
| ------------- | --------------------------------------------------------- |
| JSON | `*.json` |
| YAML | `*.yaml` |
| TOML | `*.toml` |
| HCL | `*.hcl`, `*.hcl1`, and `*.hcl2` |
| Dockerfile | `Dockerfile`, `Dockerfile.*`, and `*.Dockerfile` |
| Containerfile | `Containerfile`, `Containerfile.*`, and `*.Containerfile` |
### Configuration languages
In the above general file formats, Trivy automatically identifies the following types of configuration files:

View File

@@ -2,7 +2,7 @@
## Quick start
Simply specify a directory containing IaC files such as Terraform and Dockerfile.
Simply specify a directory containing IaC files such as Terraform, CloudFormation and Dockerfile.
``` bash
$ trivy config [YOUR_IaC_DIRECTORY]
@@ -37,7 +37,7 @@ Trivy will automatically fetch the managed policies and will keep them up-to-dat
The specified directory can contain mixed types of IaC files.
Trivy automatically detects config types and applies relevant policies.
For example, the following example holds IaC files for Terraform, Kubernetes, and Dockerfile in the same directory.
For example, the following example holds IaC files for Terraform, CloudFormation, Kubernetes, and Dockerfile in the same directory.
``` bash
$ ls iac/
@@ -111,7 +111,7 @@ Failures: 9 (HIGH: 6, CRITICAL: 1)
+ + + + +--------------------------------------------------------+
| | | | | Resource |
| | | | | 'aws_api_gateway_domain_name.missing_security_policy' |
| | | | | should include security_policy (defauls to outdated |
| | | | | should include security_policy (defaults to outdated |
| | | | | SSL/TLS policy). -->tfsec.dev/docs/aws/AWS025/ |
+ + + + +--------------------------------------------------------+
| | | | | Resource |
@@ -149,8 +149,14 @@ You can see the config type next to each file name.
===================
Tests: 23 (SUCCESSES: 14, FAILURES: 9, EXCEPTIONS: 0)
Failures: 9 (HIGH: 6, CRITICAL: 1)
...
bucket.yaml (cloudformation)
============================
Tests: 9 (SUCCESSES: 3, FAILURES: 6, EXCEPTIONS: 0)
Failures: 6 (UNKNOWN: 0, LOW: 0, MEDIUM: 2, HIGH: 4, CRITICAL: 0)
```
## Example

View File

@@ -2,7 +2,7 @@
Trivy provides built-in policies to detect configuration issues in Docker, Kubernetes and Terraform.
Also, you can write your own policies in [Rego][rego] to scan JSON, YAML, HCL, etc, like [Conftest][conftest].
![misconf](../imgs/misconf.png)
![misconf](../../imgs/misconf.png)
[rego]: https://www.openpolicyagent.org/docs/latest/policy-language/
[conftest]: https://github.com/open-policy-agent/conftest/

View File

@@ -72,7 +72,7 @@ Failures: 8 (HIGH: 6, CRITICAL: 1)
+ + + + +--------------------------------------------------------+
| | | | | Resource |
| | | | | 'aws_api_gateway_domain_name.missing_security_policy' |
| | | | | should include security_policy (defauls to outdated |
| | | | | should include security_policy (defaults to outdated |
| | | | | SSL/TLS policy). -->tfsec.dev/docs/aws/AWS025/ |
+ + + + +--------------------------------------------------------+
| | | | | Resource |

View File

@@ -3,4 +3,4 @@
See [Reports Formats](../../vulnerability/examples/report.md) in Vulnerability section.
!!! caution
Misconfiguration scanning doesn't support default templates such as XML and SARIF for now.
Misconfiguration scanning doesn't support default templates such as XML for now.

View File

@@ -4,17 +4,18 @@
Built-in policies are mainly written in [Rego][rego].
Those policies are managed under [AppShield repository][appshield].
Only Terraform's policies are currently powered by [tfsec][tfsec].
Terraform policies are currently powered by [tfsec][tfsec] and CloudFormation policies are powered by [cfsec][cfsec].
| Config type | Source |
| ---------------| ----------------------------- |
| Kubernetes | [AppShield][kubernetes] |
| Dockerfile | [AppShield][docker] |
| Terraform | [tfsec][tfsec-checks] |
| Config type | Source |
| ------------------------- | ----------------------- |
| Kubernetes | [AppShield][kubernetes] |
| Dockerfile, Containerfile | [AppShield][docker] |
| Terraform | [tfsec][tfsec-checks] |
| CloudFormation | [cfsec][cfsec-checks] |
For suggestions or issues regarding policy content, please open an issue under [AppShield][appshield] or [tfsec][tfsec] repository.
For suggestions or issues regarding policy content, please open an issue under [AppShield][appshield], [tfsec][tfsec] or [cfsec][cfsec] repository.
CloudFormation and Ansible are coming soon.
Ansible are coming soon.
## Policy Distribution
AppShield policies are distributed as an OPA bundle on [GitHub Container Registry][ghcr] (GHCR).
@@ -28,8 +29,10 @@ Trivy checks for updates to OPA bundle on GHCR every 24 hours and pulls it if th
[appshield]: https://github.com/aquasecurity/appshield
[kubernetes]: https://github.com/aquasecurity/appshield/tree/master/kubernetes
[docker]: https://github.com/aquasecurity/appshield/tree/master/docker
[tfsec-checks]: https://tfsec.dev/docs/aws/home/
[tfsec]: https://github.com/tfsec/tfsec
[tfsec-checks]: https://tfsec.dev/
[tfsec]: https://github.com/aquasecurity/tfsec
[cfsec-checks]: https://cfsec.dev/
[cfsec]: https://github.com/aquasecurity/cfsec
[ghcr]: https://github.com/aquasecurity/appshield/pkgs/container/appshield
[dockerfile-bestpractice]: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/

View File

@@ -9,7 +9,7 @@ USAGE:
OPTIONS:
--template value, -t value output template [$TRIVY_TEMPLATE]
--format value, -f value format (table, json, template) (default: "table") [$TRIVY_FORMAT]
--format value, -f value format (table, json, sarif, template) (default: "table") [$TRIVY_FORMAT]
--input value, -i value input file path instead of image name [$TRIVY_INPUT]
--severity value, -s value severities of vulnerabilities to be displayed (comma separated) (default: "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL") [$TRIVY_SEVERITY]
--output value, -o value output file name [$TRIVY_OUTPUT]
@@ -22,6 +22,7 @@ OPTIONS:
--timeout value timeout (default: 5m0s) [$TRIVY_TIMEOUT]
--ignore-policy value specify the Rego file to evaluate each vulnerability [$TRIVY_IGNORE_POLICY]
--list-all-pkgs enabling the option will output all packages regardless of vulnerability (default: false) [$TRIVY_LIST_ALL_PKGS]
--offline-scan do not issue API requests to identify dependencies (default: false) [$TRIVY_OFFLINE_SCAN]
--token value for authentication [$TRIVY_TOKEN]
--token-header value specify a header name for token (default: "Trivy-Token") [$TRIVY_TOKEN_HEADER]
--remote value server address (default: "http://localhost:4954") [$TRIVY_REMOTE]

View File

@@ -9,7 +9,7 @@ USAGE:
OPTIONS:
--template value, -t value output template [$TRIVY_TEMPLATE]
--format value, -f value format (table, json, template) (default: "table") [$TRIVY_FORMAT]
--format value, -f value format (table, json, sarif, template) (default: "table") [$TRIVY_FORMAT]
--severity value, -s value severities of vulnerabilities to be displayed (comma separated) (default: "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL") [$TRIVY_SEVERITY]
--output value, -o value output file name [$TRIVY_OUTPUT]
--exit-code value Exit code when vulnerabilities were found (default: 0) [$TRIVY_EXIT_CODE]

View File

@@ -2,14 +2,14 @@
```bash
NAME:
trivy filesystem - scan local filesystem
trivy filesystem - scan local filesystem for language-specific dependencies and config files
USAGE:
trivy filesystem [command options] dir
trivy filesystem [command options] path
OPTIONS:
--template value, -t value output template [$TRIVY_TEMPLATE]
--format value, -f value format (table, json, template) (default: "table") [$TRIVY_FORMAT]
--format value, -f value format (table, json, sarif, template) (default: "table") [$TRIVY_FORMAT]
--severity value, -s value severities of vulnerabilities to be displayed (comma separated) (default: "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL") [$TRIVY_SEVERITY]
--output value, -o value output file name [$TRIVY_OUTPUT]
--exit-code value Exit code when vulnerabilities were found (default: 0) [$TRIVY_EXIT_CODE]
@@ -21,14 +21,21 @@ OPTIONS:
--security-checks value comma-separated list of what security issues to detect (vuln,config) (default: "vuln") [$TRIVY_SECURITY_CHECKS]
--ignorefile value specify .trivyignore file (default: ".trivyignore") [$TRIVY_IGNOREFILE]
--cache-backend value cache backend (e.g. redis://localhost:6379) (default: "fs") [$TRIVY_CACHE_BACKEND]
--cache-ttl value cache TTL when using redis as cache backend (default: 0s) [$TRIVY_CACHE_TTL]
--timeout value timeout (default: 5m0s) [$TRIVY_TIMEOUT]
--no-progress suppress progress bar (default: false) [$TRIVY_NO_PROGRESS]
--ignore-policy value specify the Rego file to evaluate each vulnerability [$TRIVY_IGNORE_POLICY]
--list-all-pkgs enabling the option will output all packages regardless of vulnerability (default: false) [$TRIVY_LIST_ALL_PKGS]
--skip-files value specify the file paths to skip traversal [$TRIVY_SKIP_FILES]
--skip-dirs value specify the directories where the traversal is skipped [$TRIVY_SKIP_DIRS]
--config-policy value specify paths to the Rego policy files directory, applying config files [$TRIVY_CONFIG_POLICY]
--config-data value specify paths from which data for the Rego policies will be recursively loaded [$TRIVY_CONFIG_DATA]
--policy-namespaces value, --namespaces value Rego namespaces (default: "users") [$TRIVY_POLICY_NAMESPACES]
--offline-scan do not issue API requests to identify dependencies (default: false) [$TRIVY_OFFLINE_SCAN]
--db-repository value OCI repository to retrieve trivy-db from (default: "ghcr.io/aquasecurity/trivy-db") [$TRIVY_DB_REPOSITORY]
--skip-files value specify the file paths to skip traversal (accepts multiple inputs) [$TRIVY_SKIP_FILES]
--skip-dirs value specify the directories where the traversal is skipped (accepts multiple inputs) [$TRIVY_SKIP_DIRS]
--config-policy value specify paths to the Rego policy files directory, applying config files (accepts multiple inputs) [$TRIVY_CONFIG_POLICY]
--config-data value specify paths from which data for the Rego policies will be recursively loaded (accepts multiple inputs) [$TRIVY_CONFIG_DATA]
--policy-namespaces value, --namespaces value Rego namespaces (default: "users") (accepts multiple inputs) [$TRIVY_POLICY_NAMESPACES]
--server value server address [$TRIVY_SERVER]
--token value for authentication in client/server mode [$TRIVY_TOKEN]
--token-header value specify a header name for token in client/server mode (default: "Trivy-Token") [$TRIVY_TOKEN_HEADER]
--custom-headers value custom headers in client/server mode (accepts multiple inputs) [$TRIVY_CUSTOM_HEADERS]
--help, -h show help (default: false)
```

View File

@@ -0,0 +1,39 @@
# Image
```bash
NAME:
trivy image - scan an image
USAGE:
trivy image [command options] image_name
OPTIONS:
--template value, -t value output template [$TRIVY_TEMPLATE]
--format value, -f value format (table, json, sarif, template) (default: "table") [$TRIVY_FORMAT]
--input value, -i value input file path instead of image name [$TRIVY_INPUT]
--severity value, -s value severities of vulnerabilities to be displayed (comma separated) (default: "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL") [$TRIVY_SEVERITY]
--output value, -o value output file name [$TRIVY_OUTPUT]
--exit-code value Exit code when vulnerabilities were found (default: 0) [$TRIVY_EXIT_CODE]
--skip-db-update, --skip-update skip updating vulnerability database (default: false) [$TRIVY_SKIP_UPDATE, $TRIVY_SKIP_DB_UPDATE]
--download-db-only download/update vulnerability database but don't run a scan (default: false) [$TRIVY_DOWNLOAD_DB_ONLY]
--reset remove all caches and database (default: false) [$TRIVY_RESET]
--clear-cache, -c clear image caches without scanning (default: false) [$TRIVY_CLEAR_CACHE]
--no-progress suppress progress bar (default: false) [$TRIVY_NO_PROGRESS]
--ignore-unfixed display only fixed vulnerabilities (default: false) [$TRIVY_IGNORE_UNFIXED]
--removed-pkgs detect vulnerabilities of removed packages (only for Alpine) (default: false) [$TRIVY_REMOVED_PKGS]
--vuln-type value comma-separated list of vulnerability types (os,library) (default: "os,library") [$TRIVY_VULN_TYPE]
--security-checks value comma-separated list of what security issues to detect (vuln,config) (default: "vuln") [$TRIVY_SECURITY_CHECKS]
--ignorefile value specify .trivyignore file (default: ".trivyignore") [$TRIVY_IGNOREFILE]
--timeout value timeout (default: 5m0s) [$TRIVY_TIMEOUT]
--light deprecated (default: false) [$TRIVY_LIGHT]
--ignore-policy value specify the Rego file to evaluate each vulnerability [$TRIVY_IGNORE_POLICY]
--list-all-pkgs enabling the option will output all packages regardless of vulnerability (default: false) [$TRIVY_LIST_ALL_PKGS]
--cache-backend value cache backend (e.g. redis://localhost:6379) (default: "fs") [$TRIVY_CACHE_BACKEND]
--cache-ttl value cache TTL when using redis as cache backend (default: 0s) [$TRIVY_CACHE_TTL]
--offline-scan do not issue API requests to identify dependencies (default: false) [$TRIVY_OFFLINE_SCAN]
--insecure allow insecure server connections when using SSL (default: false) [$TRIVY_INSECURE]
--db-repository value OCI repository to retrieve trivy-db from (default: "ghcr.io/aquasecurity/trivy-db") [$TRIVY_DB_REPOSITORY]
--skip-files value specify the file paths to skip traversal (accepts multiple inputs) [$TRIVY_SKIP_FILES]
--skip-dirs value specify the directories where the traversal is skipped (accepts multiple inputs) [$TRIVY_SKIP_DIRS]
--help, -h show help (default: false)
```

View File

@@ -18,6 +18,7 @@ COMMANDS:
server, s server mode
config, conf scan config files
plugin, p manage plugins
version print the version
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:

View File

@@ -0,0 +1,173 @@
# 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
```
## 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.
## Example
https://github.com/aquasecurity/trivy-plugin-kubectl
[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

View File

@@ -0,0 +1,38 @@
# Repository
```bash
NAME:
trivy repository - scan remote repository
USAGE:
trivy repository [command options] repo_url
OPTIONS:
--template value, -t value output template [$TRIVY_TEMPLATE]
--format value, -f value format (table, json, sarif, template) (default: "table") [$TRIVY_FORMAT]
--input value, -i value input file path instead of image name [$TRIVY_INPUT]
--severity value, -s value severities of vulnerabilities to be displayed (comma separated) (default: "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL") [$TRIVY_SEVERITY]
--output value, -o value output file name [$TRIVY_OUTPUT]
--exit-code value Exit code when vulnerabilities were found (default: 0) [$TRIVY_EXIT_CODE]
--skip-db-update, --skip-update skip updating vulnerability database (default: false) [$TRIVY_SKIP_UPDATE, $TRIVY_SKIP_DB_UPDATE]
--skip-policy-update skip updating built-in policies (default: false) [$TRIVY_SKIP_POLICY_UPDATE]
--clear-cache, -c clear image caches without scanning (default: false) [$TRIVY_CLEAR_CACHE]
--ignore-unfixed display only fixed vulnerabilities (default: false) [$TRIVY_IGNORE_UNFIXED]
--removed-pkgs detect vulnerabilities of removed packages (only for Alpine) (default: false) [$TRIVY_REMOVED_PKGS]
--vuln-type value comma-separated list of vulnerability types (os,library) (default: "os,library") [$TRIVY_VULN_TYPE]
--security-checks value comma-separated list of what security issues to detect (vuln,config) (default: "vuln") [$TRIVY_SECURITY_CHECKS]
--ignorefile value specify .trivyignore file (default: ".trivyignore") [$TRIVY_IGNOREFILE]
--cache-backend value cache backend (e.g. redis://localhost:6379) (default: "fs") [$TRIVY_CACHE_BACKEND]
--cache-ttl value cache TTL when using redis as cache backend (default: 0s) [$TRIVY_CACHE_TTL]
--timeout value timeout (default: 5m0s) [$TRIVY_TIMEOUT]
--no-progress suppress progress bar (default: false) [$TRIVY_NO_PROGRESS]
--quiet, -q suppress progress bar and log output (default: false) [$TRIVY_QUIET]
--ignore-policy value specify the Rego file to evaluate each vulnerability [$TRIVY_IGNORE_POLICY]
--list-all-pkgs enabling the option will output all packages regardless of vulnerability (default: false) [$TRIVY_LIST_ALL_PKGS]
--offline-scan do not issue API requests to identify dependencies (default: false) [$TRIVY_OFFLINE_SCAN]
--insecure allow insecure server connections when using SSL (default: false) [$TRIVY_INSECURE]
--db-repository value OCI repository to retrieve trivy-db from (default: "ghcr.io/aquasecurity/trivy-db") [$TRIVY_DB_REPOSITORY]
--skip-files value specify the file paths to skip traversal (accepts multiple inputs) [$TRIVY_SKIP_FILES]
--skip-dirs value specify the directories where the traversal is skipped (accepts multiple inputs) [$TRIVY_SKIP_DIRS]
--help, -h show help (default: false)
```

View File

@@ -9,7 +9,7 @@ USAGE:
OPTIONS:
--template value, -t value output template [$TRIVY_TEMPLATE]
--format value, -f value format (table, json, template) (default: "table") [$TRIVY_FORMAT]
--format value, -f value format (table, json, sarif, template) (default: "table") [$TRIVY_FORMAT]
--severity value, -s value severities of vulnerabilities to be displayed (comma separated) (default: "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL") [$TRIVY_SEVERITY]
--output value, -o value output file name [$TRIVY_OUTPUT]
--exit-code value Exit code when vulnerabilities were found (default: 0) [$TRIVY_EXIT_CODE]
@@ -25,6 +25,7 @@ OPTIONS:
--no-progress suppress progress bar (default: false) [$TRIVY_NO_PROGRESS]
--ignore-policy value specify the Rego file to evaluate each vulnerability [$TRIVY_IGNORE_POLICY]
--list-all-pkgs enabling the option will output all packages regardless of vulnerability (default: false) [$TRIVY_LIST_ALL_PKGS]
--offline-scan do not issue API requests to identify dependencies (default: false) [$TRIVY_OFFLINE_SCAN]
--skip-files value specify the file paths to skip traversal [$TRIVY_SKIP_FILES]
--skip-dirs value specify the directories where the traversal is skipped [$TRIVY_SKIP_DIRS]
--config-policy value specify paths to the Rego policy files directory, applying config files [$TRIVY_CONFIG_POLICY]

View File

@@ -0,0 +1,19 @@
# SBOM
```bash
NAME:
trivy sbom - generate SBOM for an artifact
USAGE:
trivy sbom [command options] ARTIFACT
OPTIONS:
--output value, -o value output file name [$TRIVY_OUTPUT]
--clear-cache, -c clear image caches without scanning (default: false) [$TRIVY_CLEAR_CACHE]
--ignorefile value specify .trivyignore file (default: ".trivyignore") [$TRIVY_IGNOREFILE]
--timeout value timeout (default: 5m0s) [$TRIVY_TIMEOUT]
--severity value, -s value severities of vulnerabilities to be displayed (comma separated) (default: "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL") [$TRIVY_SEVERITY]
--artifact-type value, --type value input artifact type (image, fs, repo, archive) (default: "image") [$TRIVY_ARTIFACT_TYPE]
--sbom-format value, --format value SBOM format (cyclonedx) (default: "cyclonedx") [$TRIVY_SBOM_FORMAT]
--help, -h show help (default: false)
```

View File

@@ -0,0 +1,21 @@
# Server
```bash
NAME:
trivy server - server mode
USAGE:
trivy server [command options] [arguments...]
OPTIONS:
--skip-db-update, --skip-update skip updating vulnerability database (default: false) [$TRIVY_SKIP_UPDATE, $TRIVY_SKIP_DB_UPDATE]
--download-db-only download/update vulnerability database but don't run a scan (default: false) [$TRIVY_DOWNLOAD_DB_ONLY]
--reset remove all caches and database (default: false) [$TRIVY_RESET]
--cache-backend value cache backend (e.g. redis://localhost:6379) (default: "fs") [$TRIVY_CACHE_BACKEND]
--cache-ttl value cache TTL when using redis as cache backend (default: 0s) [$TRIVY_CACHE_TTL]
--db-repository value OCI repository to retrieve trivy-db from (default: "ghcr.io/aquasecurity/trivy-db") [$TRIVY_DB_REPOSITORY]
--token value for authentication in client/server mode [$TRIVY_TOKEN]
--token-header value specify a header name for token in client/server mode (default: "Trivy-Token") [$TRIVY_TOKEN_HEADER]
--listen value listen address (default: "localhost:4954") [$TRIVY_LISTEN]
--help, -h show help (default: false)
```

View File

@@ -55,5 +55,5 @@ $ trivy client --remote http://localhost:8080 --token dummy alpine:3.10
## Architecture
![architecture](../../imgs/client-server.png)
![architecture](../../../imgs/client-server.png)

View File

@@ -4,13 +4,13 @@
## Image
![standalone](../../imgs/image.png)
![standalone](../../../imgs/image.png)
## Filesystem
![fs](../../imgs/fs.png)
![fs](../../../imgs/fs.png)
## Git Repository
![repo](../../imgs/repo.png)
![repo](../../../imgs/repo.png)

View File

@@ -0,0 +1,160 @@
# Troubleshooting
## Scan
### Timeout
!!! error
``` bash
$ trivy image ...
...
analyze error: timeout: context deadline exceeded
```
Your scan may time out. Java takes a particularly long time to scan. Try increasing the value of the ---timeout option such as `--timeout 15m`.
### Certification
!!! error
Error: x509: certificate signed by unknown authority
`TRIVY_INSECURE` can be used to allow insecure connections to a container registry when using SSL.
```
$ TRIVY_INSECURE=true trivy image [YOUR_IMAGE]
```
### GitHub Rate limiting
!!! error
``` bash
$ trivy image ...
...
API rate limit exceeded for xxx.xxx.xxx.xxx.
```
Specify GITHUB_TOKEN for authentication
https://developer.github.com/v3/#rate-limiting
```
$ GITHUB_TOKEN=XXXXXXXXXX trivy alpine:3.10
```
### Maven rate limiting / inconsistent jar vulnerability reporting
!!! error
``` bash
$ trivy image ...
...
status 403 Forbidden from http://search.maven.org/solrsearch/select
```
Trivy calls Maven API for better detection of JAR files, but many requests may exceed rate limiting.
This can easily happen if you are running more than one instance of Trivy which is concurrently scanning multiple images.
Once this starts happening Trivy's vulnerability reporting on jar files may become inconsistent.
There are two options to resolve this issue:
The first is to enable offline scanning using the `--offline-scan` option to stop Trivy from making API requests.
This option affects only vulnerability scanning. The vulnerability database and builtin policies are downloaded as usual.
If you want to skip them as well, you can try `--skip-update` and `--skip-policy-update`.
**Note that a number of vulnerabilities might be fewer than without the `--offline-scan` option.**
The second, more scalable, option is the place Trivy behind a rate-limiting forward-proxy to the Maven Central API.
One way to achieve this is to use nginx. You can use the following nginx config to enable both rate-limiting and caching (the caching greatly reduces the number of calls to the Maven Central API, especially if you are scanning a lot of similar images):
```nginx
limit_req_zone global zone=maven:1m rate=10r/s;
proxy_cache_path /tmp/cache keys_zone=mavencache:10m;
server {
listen 80;
proxy_cache mavencache;
location / {
limit_req zone=maven burst=1000;
proxy_cache_valid any 1h;
proxy_pass https://search.maven.org:443;
}
}
```
This config file will allow a maximum of 10 requests per second to the Maven API, this number was determined experimentally so you might want to use something else if it doesn't fit your needs.
Once nginx is up and running, you need to tell all your Trivy deployments to proxy their Maven API calls through nginx. You can do this by setting the `MAVEN_CENTRAL_URL` environment variable. For example, if your nginx proxy is running at `127.0.0.1`, you can set `MAVEN_CENTRAL_URL=http://127.0.0.1/solrsearch/select`.
### Running in parallel takes same time as series run
When running trivy on multiple images simultaneously, it will take same time as running trivy in series.
This is because of a limitation of boltdb.
> Bolt obtains a file lock on the data file so multiple processes cannot open the same database at the same time. Opening an already open Bolt database will cause it to hang until the other process closes it.
Reference : [boltdb: Opening a database][boltdb].
[boltdb]: https://github.com/boltdb/bolt#opening-a-database
### Error downloading vulnerability DB
!!! error
FATAL failed to download vulnerability DB
If trivy is running behind corporate firewall, you have to add the following urls to your allowlist.
- ghcr.io
- pkg-containers.githubusercontent.com
### Old DB schema
!!! error
--skip-update cannot be specified with the old DB schema.
Trivy v0.23.0 or later requires Trivy DB v2. Please update your local database or follow [the instruction of air-gapped environment][../advanced/air-gap.md].
## Homebrew
### Scope error
!!! error
Error: Your macOS keychain GitHub credentials do not have sufficient scope!
```
$ brew tap aquasecurity/trivy
Error: Your macOS keychain GitHub credentials do not have sufficient scope!
Scopes they need: none
Scopes they have:
Create a personal access token:
https://github.com/settings/tokens/new?scopes=gist,public_repo&description=Homebrew
echo 'export HOMEBREW_GITHUB_API_TOKEN=your_token_here' >> ~/.zshrc
```
Try:
```
$ printf "protocol=https\nhost=github.com\n" | git credential-osxkeychain erase
```
### Already installed
!!! error
Error: aquasecurity/trivy/trivy 64 already installed
```
$ brew upgrade
...
Error: aquasecurity/trivy/trivy 64 already installed
```
Try:
```
$ brew unlink trivy && brew uninstall trivy
($ rm -rf /usr/local/Cellar/trivy/64)
$ brew install aquasecurity/trivy/trivy
```
## Others
### Unknown error
Try again with `--reset` option:
```
$ trivy image --reset
```
[air-gapped]: ../how-to-guides/air-gap.md

233
docs/docs/sbom/cyclonedx.md Normal file
View File

@@ -0,0 +1,233 @@
# CycloneDX
Trivy generates JSON reports in the [CycloneDX][cyclonedx] format.
Note that XML format is not supported at the moment.
You can use the regular subcommands (like `image`, `fs` and `rootfs`) and specify `cyclonedx` with the `--format` option.
```
$ trivy image --format cyclonedx --output result.json alpine:3.15
```
<details>
<summary>Result</summary>
```
$ cat result.json | jq .
{
"bomFormat": "CycloneDX",
"specVersion": "1.4",
"serialNumber": "urn:uuid:2be5773d-7cd3-4b4b-90a5-e165474ddace",
"version": 1,
"metadata": {
"timestamp": "2022-02-22T15:11:40.270597Z",
"tools": [
{
"vendor": "aquasecurity",
"name": "trivy",
"version": "dev"
}
],
"component": {
"bom-ref": "pkg:oci/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300?repository_url=index.docker.io%2Flibrary%2Falpine&arch=amd64",
"type": "container",
"name": "alpine:3.15",
"version": "",
"purl": "pkg:oci/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300?repository_url=index.docker.io%2Flibrary%2Falpine&arch=amd64",
"properties": [
{
"name": "aquasecurity:trivy:SchemaVersion",
"value": "2"
},
{
"name": "aquasecurity:trivy:ImageID",
"value": "sha256:c059bfaa849c4d8e4aecaeb3a10c2d9b3d85f5165c66ad3a4d937758128c4d18"
},
{
"name": "aquasecurity:trivy:RepoDigest",
"value": "alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300"
},
{
"name": "aquasecurity:trivy:DiffID",
"value": "sha256:8d3ac3489996423f53d6087c81180006263b79f206d3fdec9e66f0e27ceb8759"
},
{
"name": "aquasecurity:trivy:RepoTag",
"value": "alpine:3.15"
}
]
}
},
"components": [
{
"bom-ref": "pkg:apk/alpine/alpine-baselayout@3.2.0-r18?distro=3.15.0",
"type": "library",
"name": "alpine-baselayout",
"version": "3.2.0-r18",
"licenses": [
{
"expression": "GPL-2.0-only"
}
],
"purl": "pkg:apk/alpine/alpine-baselayout@3.2.0-r18?distro=3.15.0",
"properties": [
{
"name": "aquasecurity:trivy:SrcName",
"value": "alpine-baselayout"
},
{
"name": "aquasecurity:trivy:SrcVersion",
"value": "3.2.0-r18"
},
{
"name": "aquasecurity:trivy:LayerDigest",
"value": "sha256:59bf1c3509f33515622619af21ed55bbe26d24913cedbca106468a5fb37a50c3"
},
{
"name": "aquasecurity:trivy:LayerDiffID",
"value": "sha256:8d3ac3489996423f53d6087c81180006263b79f206d3fdec9e66f0e27ceb8759"
}
]
},
...(snip)...
{
"bom-ref": "pkg:apk/alpine/zlib@1.2.11-r3?distro=3.15.0",
"type": "library",
"name": "zlib",
"version": "1.2.11-r3",
"licenses": [
{
"expression": "Zlib"
}
],
"purl": "pkg:apk/alpine/zlib@1.2.11-r3?distro=3.15.0",
"properties": [
{
"name": "aquasecurity:trivy:SrcName",
"value": "zlib"
},
{
"name": "aquasecurity:trivy:SrcVersion",
"value": "1.2.11-r3"
},
{
"name": "aquasecurity:trivy:LayerDigest",
"value": "sha256:59bf1c3509f33515622619af21ed55bbe26d24913cedbca106468a5fb37a50c3"
},
{
"name": "aquasecurity:trivy:LayerDiffID",
"value": "sha256:8d3ac3489996423f53d6087c81180006263b79f206d3fdec9e66f0e27ceb8759"
}
]
},
{
"bom-ref": "3da6a469-964d-4b4e-b67d-e94ec7c88d37",
"type": "operating-system",
"name": "alpine",
"version": "3.15.0",
"properties": [
{
"name": "aquasecurity:trivy:Type",
"value": "alpine"
},
{
"name": "aquasecurity:trivy:Class",
"value": "os-pkgs"
}
]
}
],
"dependencies": [
{
"ref": "3da6a469-964d-4b4e-b67d-e94ec7c88d37",
"dependsOn": [
"pkg:apk/alpine/alpine-baselayout@3.2.0-r18?distro=3.15.0",
"pkg:apk/alpine/alpine-keys@2.4-r1?distro=3.15.0",
"pkg:apk/alpine/apk-tools@2.12.7-r3?distro=3.15.0",
"pkg:apk/alpine/busybox@1.34.1-r3?distro=3.15.0",
"pkg:apk/alpine/ca-certificates-bundle@20191127-r7?distro=3.15.0",
"pkg:apk/alpine/libc-utils@0.7.2-r3?distro=3.15.0",
"pkg:apk/alpine/libcrypto1.1@1.1.1l-r7?distro=3.15.0",
"pkg:apk/alpine/libretls@3.3.4-r2?distro=3.15.0",
"pkg:apk/alpine/libssl1.1@1.1.1l-r7?distro=3.15.0",
"pkg:apk/alpine/musl@1.2.2-r7?distro=3.15.0",
"pkg:apk/alpine/musl-utils@1.2.2-r7?distro=3.15.0",
"pkg:apk/alpine/scanelf@1.3.3-r0?distro=3.15.0",
"pkg:apk/alpine/ssl_client@1.34.1-r3?distro=3.15.0",
"pkg:apk/alpine/zlib@1.2.11-r3?distro=3.15.0"
]
},
{
"ref": "pkg:oci/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300?repository_url=index.docker.io%2Flibrary%2Falpine&arch=amd64",
"dependsOn": [
"3da6a469-964d-4b4e-b67d-e94ec7c88d37"
]
}
],
"vulnerabilities": [
{
"id": "CVE-2021-42386",
"source": {
"name": "alpine",
"url": "https://secdb.alpinelinux.org/"
},
"ratings": [
{
"source": {
"name": "nvd"
},
"score": 7.2,
"severity": "high",
"method": "CVSSv31",
"vector": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H"
},
{
"source": {
"name": "nvd"
},
"score": 6.5,
"severity": "medium",
"method": "CVSSv2",
"vector": "AV:N/AC:L/Au:S/C:P/I:P/A:P"
},
{
"source": {
"name": "redhat"
},
"score": 6.6,
"severity": "medium",
"method": "CVSSv31",
"vector": "CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:H"
}
],
"cwes": [
416
],
"description": "A use-after-free in Busybox's awk applet leads to denial of service and possibly code execution when processing a crafted awk pattern in the nvalloc function",
"advisories": [
{
"url": "https://access.redhat.com/security/cve/CVE-2021-42386"
},
{
"url": "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-42386"
}
],
"published": "2021-11-15 21:15:00 +0000 UTC",
"updated": "2022-01-04 17:14:00 +0000 UTC",
"affects": [
{
"ref": "pkg:apk/alpine/busybox@1.33.1-r3?distro=3.14.2"
},
{
"ref": "pkg:apk/alpine/ssl_client@1.33.1-r3?distro=3.14.2"
}
]
}
]
}
```
</details>
[cyclonedx]: https://cyclonedx.org/

191
docs/docs/sbom/index.md Normal file
View File

@@ -0,0 +1,191 @@
# SBOM
Trivy currently supports the following SBOM formats.
- [CycloneDX][cyclonedx]
To generate SBOM, you can use the `--format` option for each subcommand such as `image` and `fs`.
```
$ trivy image --format cyclonedx --output result.json alpine:3.15
```
In addition, you can use the `trivy sbom` subcommand.
```
$ trivy sbom alpine:3.15
```
<details>
<summary>Result</summary>
```
{
"bomFormat": "CycloneDX",
"specVersion": "1.3",
"serialNumber": "urn:uuid:2be5773d-7cd3-4b4b-90a5-e165474ddace",
"version": 1,
"metadata": {
"timestamp": "2022-02-22T15:11:40.270597Z",
"tools": [
{
"vendor": "aquasecurity",
"name": "trivy",
"version": "dev"
}
],
"component": {
"bom-ref": "pkg:oci/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300?repository_url=index.docker.io%2Flibrary%2Falpine&arch=amd64",
"type": "container",
"name": "alpine:3.15",
"version": "",
"purl": "pkg:oci/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300?repository_url=index.docker.io%2Flibrary%2Falpine&arch=amd64",
"properties": [
{
"name": "aquasecurity:trivy:SchemaVersion",
"value": "2"
},
{
"name": "aquasecurity:trivy:ImageID",
"value": "sha256:c059bfaa849c4d8e4aecaeb3a10c2d9b3d85f5165c66ad3a4d937758128c4d18"
},
{
"name": "aquasecurity:trivy:RepoDigest",
"value": "alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300"
},
{
"name": "aquasecurity:trivy:DiffID",
"value": "sha256:8d3ac3489996423f53d6087c81180006263b79f206d3fdec9e66f0e27ceb8759"
},
{
"name": "aquasecurity:trivy:RepoTag",
"value": "alpine:3.15"
}
]
}
},
"components": [
{
"bom-ref": "pkg:apk/alpine/alpine-baselayout@3.2.0-r18?distro=3.15.0",
"type": "library",
"name": "alpine-baselayout",
"version": "3.2.0-r18",
"licenses": [
{
"expression": "GPL-2.0-only"
}
],
"purl": "pkg:apk/alpine/alpine-baselayout@3.2.0-r18?distro=3.15.0",
"properties": [
{
"name": "aquasecurity:trivy:SrcName",
"value": "alpine-baselayout"
},
{
"name": "aquasecurity:trivy:SrcVersion",
"value": "3.2.0-r18"
},
{
"name": "aquasecurity:trivy:LayerDigest",
"value": "sha256:59bf1c3509f33515622619af21ed55bbe26d24913cedbca106468a5fb37a50c3"
},
{
"name": "aquasecurity:trivy:LayerDiffID",
"value": "sha256:8d3ac3489996423f53d6087c81180006263b79f206d3fdec9e66f0e27ceb8759"
}
]
},
...(snip)...
{
"bom-ref": "pkg:apk/alpine/zlib@1.2.11-r3?distro=3.15.0",
"type": "library",
"name": "zlib",
"version": "1.2.11-r3",
"licenses": [
{
"expression": "Zlib"
}
],
"purl": "pkg:apk/alpine/zlib@1.2.11-r3?distro=3.15.0",
"properties": [
{
"name": "aquasecurity:trivy:SrcName",
"value": "zlib"
},
{
"name": "aquasecurity:trivy:SrcVersion",
"value": "1.2.11-r3"
},
{
"name": "aquasecurity:trivy:LayerDigest",
"value": "sha256:59bf1c3509f33515622619af21ed55bbe26d24913cedbca106468a5fb37a50c3"
},
{
"name": "aquasecurity:trivy:LayerDiffID",
"value": "sha256:8d3ac3489996423f53d6087c81180006263b79f206d3fdec9e66f0e27ceb8759"
}
]
},
{
"bom-ref": "3da6a469-964d-4b4e-b67d-e94ec7c88d37",
"type": "operating-system",
"name": "alpine",
"version": "3.15.0",
"properties": [
{
"name": "aquasecurity:trivy:Type",
"value": "alpine"
},
{
"name": "aquasecurity:trivy:Class",
"value": "os-pkgs"
}
]
}
],
"dependencies": [
{
"ref": "3da6a469-964d-4b4e-b67d-e94ec7c88d37",
"dependsOn": [
"pkg:apk/alpine/alpine-baselayout@3.2.0-r18?distro=3.15.0",
"pkg:apk/alpine/alpine-keys@2.4-r1?distro=3.15.0",
"pkg:apk/alpine/apk-tools@2.12.7-r3?distro=3.15.0",
"pkg:apk/alpine/busybox@1.34.1-r3?distro=3.15.0",
"pkg:apk/alpine/ca-certificates-bundle@20191127-r7?distro=3.15.0",
"pkg:apk/alpine/libc-utils@0.7.2-r3?distro=3.15.0",
"pkg:apk/alpine/libcrypto1.1@1.1.1l-r7?distro=3.15.0",
"pkg:apk/alpine/libretls@3.3.4-r2?distro=3.15.0",
"pkg:apk/alpine/libssl1.1@1.1.1l-r7?distro=3.15.0",
"pkg:apk/alpine/musl@1.2.2-r7?distro=3.15.0",
"pkg:apk/alpine/musl-utils@1.2.2-r7?distro=3.15.0",
"pkg:apk/alpine/scanelf@1.3.3-r0?distro=3.15.0",
"pkg:apk/alpine/ssl_client@1.34.1-r3?distro=3.15.0",
"pkg:apk/alpine/zlib@1.2.11-r3?distro=3.15.0"
]
},
{
"ref": "pkg:oci/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300?repository_url=index.docker.io%2Flibrary%2Falpine&arch=amd64",
"dependsOn": [
"3da6a469-964d-4b4e-b67d-e94ec7c88d37"
]
}
]
}
```
</details>
`fs`, `repo` and `archive` also work with `sbom` subcommand.
```
# filesystem
$ trivy sbom --artifact-type fs /path/to/project
# repository
$ trivy sbom --artifact-type repo github.com/aquasecurity/trivy-ci-test
# container image archive
$ trivy sbom --artifact-type archive alpine.tar
```
[cyclonedx]: cyclonedx.md

View File

@@ -0,0 +1,143 @@
# Configuration
Trivy tries to load `trivy-secret.yaml` in the current directory by default.
If the file doesn't exist, only built-in rules are used.
You can customize the config file path via the `--secret-config` flag.
You can see the example [here][examples].
## Custom Rules
Trivy allows defining custom rules. You can see an example.
``` yaml
rules:
- id: rule1
category: general
title: Generic Rule
severity: HIGH
path:
- .*\.sh
keywords:
- secret
regex: (?i)(?P<key>(secret))(=|:).{0,5}['"](?P<secret>[0-9a-zA-Z\-_=]{8,64})['"]
secret-group-name: secret
allow-rules:
- id: skip-text
description: skip text files
path: .*\.txt
```
`id` (required)
: - Unique identifier for this rule.
`category` (required)
: - String used for metadata and reporting purposes.
`title` (required)
: - Short human-readable title of the rule.
`severity` (required)
: - How critical this rule is.
- Allowed values:
- CRITICAL
- HIGH
- MEDIUM
- LOW
`regex` (required)
: - Golang regular expression used to detect secrets.
`path` (optional)
: - Golang regular expression used to match paths.
`keywords` (optional, recommended)
: - Keywords are used for pre-regex check filtering.
- Rules that contain keywords will perform a quick string compare check to make sure the keyword(s) are in the content being scanned.
- Ideally these values should either be part of the identifier or unique strings specific to the rule's regex.
- It is recommended to define for better performance.
`allow-rules` (optional)
: - Allow rules for a single rule to reduce false positives with known secrets.
- The details are below.
## Allow Rules
If the detected secret is matched with the specified `regex`, then that secret will be skipped and not detected.
The same logic applies for `path`.
`allow-rules` can be defined globally and per each rule. The fields are the same.
``` yaml
rules:
- id: rule1
category: general
title: Generic Rule
severity: HIGH
regex: (?i)(?P<key>(secret))(=|:).{0,5}['"](?P<secret>[0-9a-zA-Z\-_=]{8,64})['"]
allow-rules:
- id: skip-text
description: skip text files
path: .*\.txt
allow-rules:
- id: social-security-number
description: skip social security number
regex: 219-09-9999
```
`id` (required)
: - Unique identifier for this allow rule.
`description` (optional)
: - Short human-readable description of this allow rule.
`regex` (optional)
: - Golang regular expression used to allow detected secrets.
- `regex` or `path` must be specified.
`path` (optional)
: - Golang regular expression used to allow matched paths.
- `regex` or `path` must be specified.
## Enable Rules
Trivy provides plenty of out-of-box rules and allow rules, but you may not need all of them.
In that case, `enable-builin-rules` will be helpful.
If you just need AWS secret detection, you can enable only relevant rules as shown below.
It specifies AWS-related rule IDs in `enable-builin-rules`.
All other rules are disabled, so the scanning will be much faster.
We would strongly recommend using this option if you don't need all rules.
You can see a full list of [built-in rule IDs][builtin] and [built-in allow rule IDs][builtin-allow].
``` yaml
enable-builtin-rules:
- aws-access-key-id
- aws-account-id
- aws-secret-access-key
```
## Disable Rules
Trivy offers built-in rules and allow rules, but you may want to disable some of them.
For example, you don't use Slack, so Slack doesn't have to be scanned.
You can specify the Slack rule IDs, `slack-access-token` and `slack-web-hook` in `disable-rules` so that those rules will be disabled for less false positives.
You should specify either `enable-builin-rules` or `disable-rules`.
If they both are specified, `disable-rules` takes precedence.
In case `github-pat` is specified in `enable-builin-rules` and `disable-rules`, it will be disabled.
In addition, there are some allow rules.
Markdown files are ignored by default, but you may want to scan markdown files as well.
You can disable the allow rule by adding `markdown` to `disable-allow-rules`.
You can see a full list of [built-in rule IDs][builtin] and [built-in allow rule IDs][builtin-allow].
``` yaml
disable-rules:
- slack-access-token
- slack-web-hook
disable-allow-rules:
- markdown
```
[builtin]: https://github.com/aquasecurity/fanal/blob/main/secret/builtin-rules.go
[builtin]: https://github.com/aquasecurity/fanal/blob/main/secret/builtin-allow-rules.go
[examples]: ./examples.md

View File

@@ -0,0 +1,98 @@
# Examples
Also see [quick start][quick-start].
## Skip Directories
Trivy traversals directories and scans all files except those matching the built-in allow rules by default.
If your have a lot of files in your container image or project, the scanning takes time.
To make it faster, you can skip traversal in the specific directory.
Also, it would be helpful if your project contains secrets and certificates for testing.
``` shell
$ trivy image --skip-dirs /var/lib --skip-dirs /var/log YOUR_IMAGE
```
``` shell
$ trivy fs --skip-dirs ./my-test-dir --skip-dirs ./my-testing-cert/ /path/to/your_project
```
`--skip-fles` also works similarly.
## Filter by severity
Use `--severity` option.
``` shell
$ trivy fs --severity CRITICAL ./
app/secret.sh (secrets)
=======================
Total: 1 (CRITICAL: 1)
+----------+-------------------+----------+---------+--------------------------------+
| CATEGORY | DESCRIPTION | SEVERITY | LINE NO | MATCH |
+----------+-------------------+----------+---------+--------------------------------+
| AWS | AWS Access Key ID | CRITICAL | 10 | export AWS_ACCESS_KEY_ID=***** |
+----------+-------------------+----------+---------+--------------------------------+
```
## Disable secret scanning
If you need vulnerability scanning only, you can disable secret scanning via the `--security-checks` flag.
``` shell
$ trivy image --security-checks vuln alpine:3.15
```
## With configuration file
`trivy-secret.yaml` in the working directory is loaded by default.
``` yaml
$ cat trivy-secret.yaml
rules:
- id: rule1
category: general
title: Generic Rule
severity: HIGH
regex: (?i)(?P<key>(secret))(=|:).{0,5}['"](?P<secret>[0-9a-zA-Z\-_=]{8,64})['"]
allow-rules:
- id: social-security-number
description: skip social security number
regex: 219-09-9999
- id: log-dir
description: skip log directory
path: ^\/var\/log\/
disable-rules:
- slack-access-token
- slack-web-hook
disable-allow-rules:
- markdown
# The following command automatically loads the above configuration.
$ trivy image YOUR_IMAGE
```
Also, you can customize the config file path via `--secret-config`.
``` yaml
$ cat ./secret-config/trivy.yaml
rules:
- id: rule1
category: general
title: Generic Rule
severity: HIGH
regex: (?i)(?P<key>(secret))(=|:).{0,5}['"](?P<secret>[0-9a-zA-Z\-_=]{8,64})['"]
allow-rules:
- id: skip-text
description: skip text files
path: .*\.txt
enable-builtin-rules:
- aws-access-key-id
- aws-account-id
- aws-secret-access-key
disable-allow-rules:
- usr-dirs
# Pass the above config with `--secret-config`.
$ trivy fs --secret-config ./secret-config/trivy.yaml /path/to/your_project
```
[quick-start]: ./scanning.md#quick-start

View File

@@ -0,0 +1,124 @@
# Secret Scanning
Trivy scans any container image, filesystem and git repository to detect exposed secrets like passwords, api keys, and tokens.
Secret scanning is enabled by default.
Trivy will scan every plaintext file, according to builtin rules or configuration. There are plenty of builtin rules:
- AWS access key
- GCP service account
- GitHub personal access token
- GitLab personal access token
- Slack access token
- etc.
You can see a full list of [built-in rules][builtin] and [built-in allow rules][builtin-allow].
!!! tip
If your secret is not detected properly, please make sure that your file including the secret is not in [the allowed paths][builtin-allow].
You can disable allow rules via [disable-allow-rules][disable-rules].
## Quick start
This section shows how to scan secrets in container image and filesystem. Other subcommands should be the same.
### Container image
Specify an image name.
``` shell
$ trivy image myimage:1.0.0
2022-04-21T18:56:44.099+0300 INFO Detected OS: alpine
2022-04-21T18:56:44.099+0300 INFO Detecting Alpine vulnerabilities...
2022-04-21T18:56:44.101+0300 INFO Number of language-specific files: 0
myimage:1.0.0 (alpine 3.15.0)
=============================
Total: 6 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 2)
+--------------+------------------+----------+-------------------+---------------+---------------------------------------+
| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |
+--------------+------------------+----------+-------------------+---------------+---------------------------------------+
| busybox | CVE-2022-28391 | CRITICAL | 1.34.1-r3 | 1.34.1-r5 | CVE-2022-28391 affecting |
| | | | | | package busybox 1.35.0 |
| | | | | | -->avd.aquasec.com/nvd/cve-2022-28391 |
+--------------+------------------| |-------------------+---------------+---------------------------------------+
| ssl_client | CVE-2022-28391 | | 1.34.1-r3 | 1.34.1-r5 | CVE-2022-28391 affecting |
| | | | | | package busybox 1.35.0 |
| | | | | | -->avd.aquasec.com/nvd/cve-2022-28391 |
+--------------+------------------+----------+-------------------+---------------+---------------------------------------+
app/secret.sh (secrets)
=======================
Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 1)
+----------+-------------------+----------+---------+--------------------------------+
| CATEGORY | DESCRIPTION | SEVERITY | LINE NO | MATCH |
+----------+-------------------+----------+---------+--------------------------------+
| AWS | AWS Access Key ID | CRITICAL | 10 | export AWS_ACCESS_KEY_ID=***** |
+----------+-------------------+----------+---------+--------------------------------+
```
!!! tip
Trivy tries to detect a base image and skip those layers for secret scanning.
A base image usually contains a lot of files and makes secret scanning much slower.
If a secret is not detected properly, you can see base layers with the `--debug` flag.
### Filesystem
``` shell
$ trivy fs /path/to/your_project
...(snip)...
certs/key.pem (secrets)
========================
Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0)
+----------------------+------------------------+----------+---------+---------------------------------+
| CATEGORY | DESCRIPTION | SEVERITY | LINE NO | MATCH |
+----------------------+------------------------+----------+---------+---------------------------------+
| AsymmetricPrivateKey | Asymmetric Private Key | HIGH | 1 | -----BEGIN RSA PRIVATE KEY----- |
+----------------------+------------------------+----------+---------+---------------------------------+
```
!!! tip
Your project may have some secrets for testing. You can skip them with `--skip-dirs` or `--skip-files`.
We would recommend specifying these options so that the secret scanning can be faster if those files don't need to be scanned.
Also, you can specify paths to be allowed in a configuration file. See the detail [here][configuration].
## Configuration
Trivy has a set of builtin rules for secret scanning, which can be extended or modified by a configuration file.
If you don't need secret scanning, you can disable it via the `--security-checks` flag.
```shell
$ trivy image --security-checks vuln alpine:3.15
```
## Recommendation
We would recommend specifying `--skip-dirs` for faster secret scanning.
In container image scanning, Trivy walks the file tree rooted `/` and scans all the files other than [built-in allowed paths][builtin-allow].
It will take a while if your image contains a lot of files even though Trivy tries to avoid scanning layers from a base image.
If you want to make scanning faster, `--skip-dirs` and `--skip-files` helps so that Trivy will skip scanning those files and directories.
The usage examples are [here][examples].
`allow-rules` is also helpful. See the [allow-rules][allow-rules] section.
In addition, all the built-in rules are enabled by default, so it takes some time to scan all of them.
If you don't need all those rules, you can use `enable-builtin-rules` or `disable-rules` in the configuration file.
You should use `enable-builin-rules` if you need only AWS secret detection, for example.
All rules are disabled except for the ones you specify, so it runs very fast.
On the other hand, you should use `disable-rules` if you just want to disable some built-in rules.
See the [enable-rules][enable-rules] and [disable-rules][disable-rules] sections for the detail.
## Credit
This feature is inspired by [gitleaks][gitleaks].
[builtin]: https://github.com/aquasecurity/fanal/blob/main/secret/builtin-rules.go
[builtin-allow]: https://github.com/aquasecurity/fanal/blob/main/secret/builtin-allow-rules.go
[configuration]: ./configuration.md
[allow-rules]: ./configuration.md#allow-rules
[enable-rules]: ./configuration.md#enable-rules
[disable-rules]: ./configuration.md#disable-rules
[examples]: ./examples.md
[gitleaks]: https://github.com/zricethezav/gitleaks

View File

@@ -11,28 +11,31 @@
| Ubuntu | [Ubuntu CVE Tracker][ubuntu] |
| RHEL/CentOS | [OVAL][rhel-oval] |
| | [Security Data][rhel-api] |
| AlmaLinux | [AlmaLinux Product Errata][alma] |
| Rocky Linux | [Rocky Linux UpdateInfo][rocky] |
| Oracle Linux | [OVAL][oracle] |
| CBL-Mariner | [OVAL][mariner] |
| OpenSUSE/SLES | [CVRF][suse] |
| Photon OS | [Photon Security Advisory][photon] |
# Programming Language
| Language | Source | Commercial Use | Delay[^1]|
| ---------------------------- | -------------------------------------------------|:---------------:|:--------:|
| PHP | [PHP Security Advisories Database][php] | ✅ | - |
| | [GitHub Advisory Database (Composer)][php-ghsa] | ✅ | - |
| Python | [Safety DB][python] | ❌ | 1 month |
| | [GitHub Advisory Database (pip)][python-ghsa] | ✅ | - |
| Ruby | [Ruby Advisory Database][ruby] | ✅ | - |
| | [GitHub Advisory Database (RubyGems)][ruby-ghsa] | ✅ | - |
| Node.js | [Ecosystem Security Working Group][nodejs] | ✅ | - |
| | [GitHub Advisory Database (npm)][nodejs-ghsa] | ✅ | - |
| Java | [GitLab Advisories Community][gitlab] | ✅ | 1 month |
| | [GitHub Advisory Database (Maven)][java-ghsa] | ✅ | - |
| Go | [GitLab Advisories Community][gitlab] | ✅ | 1 month |
| | [The Go Vulnerability Database][go] | ✅ | - |
| Rust | [RustSec Advisory Database][rust] | ✅ | - |
| .NET | [GitHub Advisory Database (NuGet)][dotnet-ghsa] | ✅ | - |
| Language | Source | Commercial Use | Delay[^1]|
| ---------------------------- | ----------------------------------------------------|:---------------:|:--------:|
| PHP | [PHP Security Advisories Database][php] | ✅ | - |
| | [GitHub Advisory Database (Composer)][php-ghsa] | ✅ | - |
| Python | [GitHub Advisory Database (pip)][python-ghsa] | ✅ | - |
| | [Open Source Vulnerabilities (PyPI)][python-osv] | ✅ | - |
| Ruby | [Ruby Advisory Database][ruby] | ✅ | - |
| | [GitHub Advisory Database (RubyGems)][ruby-ghsa] | ✅ | - |
| Node.js | [Ecosystem Security Working Group][nodejs] | ✅ | - |
| | [GitHub Advisory Database (npm)][nodejs-ghsa] | ✅ | - |
| Java | [GitLab Advisories Community][gitlab] | ✅ | 1 month |
| | [GitHub Advisory Database (Maven)][java-ghsa] | ✅ | - |
| Go | [GitLab Advisories Community][gitlab] | ✅ | 1 month |
| | [The Go Vulnerability Database][go] | ✅ | - |
| Rust | [Open Source Vulnerabilities (crates.io)][rust-osv] | ✅ | - |
| .NET | [GitHub Advisory Database (NuGet)][dotnet-ghsa] | ✅ | - |
[^1]: Intentional delay between vulnerability disclosure and registration in the DB
@@ -51,9 +54,12 @@
[ubuntu]: https://ubuntu.com/security/cve
[rhel-oval]: https://www.redhat.com/security/data/oval/v2/
[rhel-api]: https://www.redhat.com/security/data/metrics/
[alma]: https://errata.almalinux.org/
[rocky]: https://download.rockylinux.org/pub/rocky/
[oracle]: https://linux.oracle.com/security/oval/
[suse]: http://ftp.suse.com/pub/projects/security/cvrf/
[photon]: https://packages.vmware.com/photon/photon_cve_metadata/
[mariner]: https://github.com/microsoft/CBL-MarinerVulnerabilityData/
[php-ghsa]: https://github.com/advisories?query=ecosystem%3Acomposer
[python-ghsa]: https://github.com/advisories?query=ecosystem%3Apip
@@ -63,11 +69,12 @@
[dotnet-ghsa]: https://github.com/advisories?query=ecosystem%3Anuget
[php]: https://github.com/FriendsOfPHP/security-advisories
[python]: https://github.com/pyupio/safety-db
[ruby]: https://github.com/rubysec/ruby-advisory-db
[nodejs]: https://github.com/nodejs/security-wg
[gitlab]: https://gitlab.com/gitlab-org/advisories-community
[go]: https://github.com/golang/vulndb
[rust]: (https://github.com/RustSec/advisory-db)
[python-osv]: https://osv.dev/list?q=&ecosystem=PyPI
[rust-osv]: https://osv.dev/list?q=&ecosystem=crates.io
[nvd]: https://nvd.nist.gov/

View File

@@ -0,0 +1,39 @@
# Language-specific Packages
`Trivy` automatically detects the following files in the container and scans vulnerabilities in the application dependencies.
| Language | File | Image[^7] | Rootfs[^8] | Filesystem[^9] | Repository[^10] |Dev dependencies |
|----------|--------------------------|:---------:|:----------:|:--------------:|:--------------:|-----------------|
| Ruby | Gemfile.lock | - | - | ✅ | ✅ | included |
| | gemspec | ✅ | ✅ | - | - | included |
| Python | Pipfile.lock | - | - | ✅ | ✅ | excluded |
| | poetry.lock | - | - | ✅ | ✅ | included |
| | requirements.txt | - | - | ✅ | ✅ | included |
| | egg package[^1] | ✅ | ✅ | - | - | excluded |
| | wheel package[^2] | ✅ | ✅ | - | - | excluded |
| PHP | composer.lock | ✅ | ✅ | ✅ | ✅ | excluded |
| Node.js | package-lock.json | - | - | ✅ | ✅ | excluded |
| | yarn.lock | - | - | ✅ | ✅ | included |
| | package.json | ✅ | ✅ | - | - | excluded |
| .NET | packages.lock.json | ✅ | ✅ | ✅ | ✅ | included |
| | packages.config | ✅ | ✅ | ✅ | ✅ | excluded |
| Java | JAR/WAR/PAR/EAR[^3][^4] | ✅ | ✅ | - | - | included |
| | pom.xml[^5] | - | - | ✅ | ✅ | excluded |
| Go | Binaries built by Go[^6] | ✅ | ✅ | - | - | excluded |
| | go.sum | - | - | ✅ | ✅ | included |
| Rust | Cargo.lock | ✅ | ✅ | ✅ | ✅ | included |
The path of these files does not matter.
Example: [Dockerfile](https://github.com/aquasecurity/trivy-ci-test/blob/main/Dockerfile)
[^1]: `*.egg-info`, `*.egg-info/PKG-INFO`, `*.egg` and `EGG-INFO/PKG-INFO`
[^2]: `.dist-info/META-DATA`
[^3]: `*.jar`, `*.war`, `*.par` and `*.ear`
[^4]: It requires Internet access
[^5]: It requires Internet access when the POM doesn't exist in your local repository
[^6]: UPX-compressed binaries don't work
[^7]: ✅ means "enabled" and `-` means "disabled" in the image scanning
[^8]: ✅ means "enabled" and `-` means "disabled" in the rootfs scanning
[^9]: ✅ means "enabled" and `-` means "disabled" in the filesystem scanning
[^10]: ✅ means "enabled" and `-` means "disabled" in the git repository scanning

View File

@@ -0,0 +1,24 @@
# Supported OS
The unfixed/unfixable vulnerabilities mean that the patch has not yet been provided on their distribution. Trivy doesn't support self-compiled packages/binaries, but official packages provided by vendors such as Red Hat and Debian.
| OS | Supported Versions | Target Packages | Detection of unfixed vulnerabilities |
| -------------------------------- |-------------------------------------------| ----------------------------- | :----------------------------------: |
| Alpine Linux | 2.2 - 2.7, 3.0 - 3.15, edge | Installed by apk | NO |
| Red Hat Universal Base Image[^1] | 7, 8 | Installed by yum/rpm | YES |
| Red Hat Enterprise Linux | 6, 7, 8 | Installed by yum/rpm | YES |
| CentOS | 6, 7, 8 | Installed by yum/rpm | YES |
| AlmaLinux | 8 | Installed by yum/rpm | NO |
| Rocky Linux | 8 | Installed by yum/rpm | NO |
| Oracle Linux | 5, 6, 7, 8 | Installed by yum/rpm | NO |
| CBL-Mariner | 1.0, 2.0 | Installed by yum/rpm | YES |
| Amazon Linux | 1, 2 | Installed by yum/rpm | NO |
| openSUSE Leap | 42, 15 | Installed by zypper/rpm | NO |
| SUSE Enterprise Linux | 11, 12, 15 | Installed by zypper/rpm | NO |
| Photon OS | 1.0, 2.0, 3.0, 4.0 | Installed by tdnf/yum/rpm | NO |
| Debian GNU/Linux | wheezy, jessie, stretch, buster, bullseye | Installed by apt/apt-get/dpkg | YES |
| Ubuntu | All versions supported by Canonical | Installed by apt/apt-get/dpkg | YES |
| Distroless[^2] | Any | Installed by apt/apt-get/dpkg | YES |
[^1]: https://developers.redhat.com/products/rhel/ubi
[^2]: https://github.com/GoogleContainerTools/distroless

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