-
Notifications
You must be signed in to change notification settings - Fork 245
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: store artifacts in cache by default #399
Changes from all commits
bad351b
b937d02
a1e9b97
59d3056
ccf6e0f
4f4b6e0
c19d38f
40d20e1
84a6ffe
5dd4e7e
330fdca
a8b935f
e94275c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
name: 'Aqua Security Trivy' | ||
description: 'Scans container images for vulnerabilities with Trivy' | ||
author: 'Aqua Security' | ||
|
||
inputs: | ||
scan-type: | ||
description: 'Scan type to use for scanning vulnerability' | ||
|
@@ -24,7 +25,7 @@ inputs: | |
description: 'ignore unfixed vulnerabilities' | ||
required: false | ||
default: 'false' | ||
vuln-type: | ||
vuln-type: # TODO: rename to pkg-types | ||
description: 'comma-separated list of vulnerability types (os,library)' | ||
required: false | ||
default: 'os,library' | ||
|
@@ -55,7 +56,7 @@ inputs: | |
cache-dir: | ||
description: 'specify where the cache is stored' | ||
required: false | ||
default: '' | ||
default: '${{ github.workspace }}/.cache/trivy' | ||
timeout: | ||
description: 'timeout (default 5m0s)' | ||
required: false | ||
|
@@ -79,9 +80,6 @@ inputs: | |
description: 'comma-separated list of relative paths in repository to one or more .trivyignore files' | ||
required: false | ||
default: '' | ||
artifact-type: | ||
description: 'input artifact type (image, fs, repo, archive) for SBOM generation' | ||
required: false | ||
github-pat: | ||
description: 'GitHub Personal Access Token (PAT) for submitting SBOM to GitHub Dependency Snapshot API' | ||
required: false | ||
|
@@ -97,33 +95,73 @@ inputs: | |
docker-host: | ||
description: 'unix domain socket path to use for docker scanning, ex. unix:///var/run/docker.sock' | ||
required: false | ||
version: | ||
description: 'Trivy version to use' | ||
required: false | ||
default: 'v0.56.1' | ||
cache: | ||
description: 'Used to specify whether caching is needed. Set to false, if you would like to disable caching.' | ||
required: false | ||
default: 'true' | ||
|
||
runs: | ||
using: 'docker' | ||
image: "Dockerfile" | ||
args: | ||
- '-a ${{ inputs.scan-type }}' | ||
- '-b ${{ inputs.format }}' | ||
- '-c ${{ inputs.template }}' | ||
- '-d ${{ inputs.exit-code }}' | ||
- '-e ${{ inputs.ignore-unfixed }}' | ||
- '-f ${{ inputs.vuln-type }}' | ||
- '-g ${{ inputs.severity }}' | ||
- '-h ${{ inputs.output }}' | ||
- '-i ${{ inputs.image-ref }}' | ||
- '-j ${{ inputs.scan-ref }}' | ||
- '-k ${{ inputs.skip-dirs }}' | ||
- '-l ${{ inputs.input }}' | ||
- '-m ${{ inputs.cache-dir }}' | ||
- '-n ${{ inputs.timeout }}' | ||
- '-o ${{ inputs.ignore-policy }}' | ||
- '-p ${{ inputs.hide-progress }}' | ||
- '-q ${{ inputs.skip-files }}' | ||
- '-r ${{ inputs.list-all-pkgs }}' | ||
- '-s ${{ inputs.scanners }}' | ||
- '-t ${{ inputs.trivyignores }}' | ||
- '-u ${{ inputs.github-pat }}' | ||
- '-v ${{ inputs.trivy-config }}' | ||
- '-x ${{ inputs.tf-vars }}' | ||
- '-z ${{ inputs.limit-severities-for-sarif }}' | ||
- '-y ${{ inputs.docker-host }}' | ||
using: 'composite' | ||
steps: | ||
- name: Install Trivy | ||
shell: bash | ||
run: curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sudo sh -s -- -b /usr/local/bin ${{ inputs.version }} | ||
Comment on lines
+108
to
+112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this switched from docker to running on the local system? It's not a good practice to grant sudo access to github action runners. I just had some actions fail because they attempted to use sudo. Unless I misunderstand what "composite" means? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It also means There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello @mattnakama-skytap @danielnitsche There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DmitriyLewen You might want to consider installing via something like https://github.com/jaxxstorm/action-install-gh-release There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rvesse We just published. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
- name: Get current date | ||
id: date | ||
shell: bash | ||
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | ||
|
||
- name: Restore DB from cache | ||
if: ${{ inputs.cache == 'true' }} | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ inputs.cache-dir }} | ||
key: cache-trivy-${{ steps.date.outputs.date }} | ||
restore-keys: cache-trivy- | ||
|
||
- name: Set GitHub Path | ||
run: echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH | ||
shell: bash | ||
env: | ||
GITHUB_ACTION_PATH: ${{ github.action_path }} | ||
|
||
- name: Run Trivy | ||
shell: bash | ||
run: entrypoint.sh | ||
env: | ||
# For shell script | ||
# > If the action is written using a composite, then it will not automatically get INPUT_<VARIABLE_NAME> | ||
# cf. https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs | ||
INPUT_SCAN_TYPE: ${{ inputs.scan-type }} | ||
INPUT_IMAGE_REF: ${{ inputs.image-ref }} | ||
INPUT_SCAN_REF: ${{ inputs.scan-ref }} | ||
INPUT_TRIVYIGNORES: ${{ inputs.trivyignores }} | ||
INPUT_GITHUB_PAT: ${{ inputs.github-pat }} | ||
INPUT_LIMIT_SEVERITIES_FOR_SARIF: ${{ inputs.limit-severities-for-sarif }} | ||
|
||
# For Trivy | ||
# cf. https://aquasecurity.github.io/trivy/latest/docs/configuration/#environment-variables | ||
TRIVY_INPUT: ${{ inputs.input }} | ||
TRIVY_EXIT_CODE: ${{ inputs.exit-code }} | ||
TRIVY_IGNORE_UNFIXED: ${{ inputs.ignore-unfixed }} | ||
TRIVY_PKG_TYPES: ${{ inputs.vuln-type }} | ||
TRIVY_SEVERITY: ${{ inputs.severity }} | ||
TRIVY_FORMAT: ${{ inputs.format }} | ||
TRIVY_TEMPLATE: ${{ inputs.template }} | ||
TRIVY_OUTPUT: ${{ inputs.output }} | ||
TRIVY_SKIP_DIRS: ${{ inputs.skip-dirs }} | ||
TRIVY_SKIP_FILES: ${{ inputs.skip-files }} | ||
TRIVY_CACHE_DIR: ${{ inputs.cache-dir }} | ||
TRIVY_TIMEOUT: ${{ inputs.timeout }} | ||
TRIVY_IGNORE_POLICY: ${{ inputs.ignore-policy }} | ||
TRIVY_QUIET: ${{ inputs.hide-progress }} | ||
TRIVY_LIST_ALL_PKGS: ${{ inputs.list-all-pkgs }} | ||
TRIVY_SCANNERS: ${{ inputs.scanners }} | ||
TRIVY_CONFIG: ${{ inputs.trivy-config }} | ||
TRIVY_TF_VARS: ${{ inputs.tf-vars }} | ||
TRIVY_DOCKER_HOST: ${{ inputs.docker-host }} |
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.
Since we are adding GitHub cache - some users may want to change the update interval (e.g. update trivy-db every 2 days).
I think the
skip-db-update
(and flags for other DBs) flag can be added for this.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.
On the other hand, we have these flags in config file.
But then perhaps we should mention these flags in the documents.
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.
I've also added an example for cronjob.
a8b935f