-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(secret): support enable rules #2035
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
857d3b8
docs: add examples and enable-builin-rules
knqyf263 b43f48a
chore(deps): update fanal
knqyf263 8cd0fc4
docs: udpate README
knqyf263 75cf696
docs: update links
knqyf263 53954b6
Merge branch 'main' into enable_rules
knqyf263 a61b3d8
chore: pin python package versions
knqyf263 fcb41a9
chore: pin versions
knqyf263 e552875
Update docs/docs/secret/scanning.md
knqyf263 3a8aae8
docs: add links to builtin-rules and builtin-allow-rules
knqyf263 9ab2e7c
chore(deps): update fanal
knqyf263 173c07a
docs: add a link to quick start
knqyf263 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
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. | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a reference to QuickStart here?