Skip to content

Commit

Permalink
🪞 Optionally use ECR for Trivy's database (#282)
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Woffenden <jacob.woffenden@digital.justice.gov.uk>
  • Loading branch information
jacobwoffenden authored Oct 17, 2024
1 parent 83fe116 commit 196c43f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions terraform-static-analysis/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ inputs:
description: "The name of the main branch e.g. 'main', defaults to 'main'"
required: false
default: "main"
use_trivy_ecr_database:
description: "Download the Trivy databases from ECR"
required: false
default: "false"

runs:
using: "docker"
Expand Down
8 changes: 8 additions & 0 deletions terraform-static-analysis/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ echo "INPUT_TRIVY_SEVERITY: $INPUT_TRIVY_SEVERITY"
echo "INPUT_TFSEC_TRIVY: $INPUT_TFSEC_TRIVY"
echo "INPUT_TRIVY_SKIP_DIR: $INPUT_TRIVY_SKIP_DIR"
echo "INPUT_MAIN_BRANCH_NAME: $INPUT_MAIN_BRANCH_NAME"
echo "INPUT_USE_TRIVY_ECR_DATABASE: $INPUT_USE_TRIVY_ECR_DATABASE"
echo

# install tfsec from GitHub (taken from README.md)
if [[ -n "$INPUT_TFSEC_VERSION" && "${INPUT_TFSEC_TRIVY}" == "tfsec" ]]; then
env GO111MODULE=on go install github.com/aquasecurity/tfsec/cmd/tfsec@"${INPUT_TFSEC_VERSION}"
Expand All @@ -35,6 +37,12 @@ else
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin latest
fi

# use ECR for Trivy databases
if [[ "$INPUT_USE_TRIVY_ECR_DATABASE" == "true" ]];
export TRIVY_DB_REPOSITORY="public.ecr.aws/aquasecurity/trivy-db:2"
export TRIVY_JAVA_DB_REPOSITORY="public.ecr.aws/aquasecurity/trivy-java-db:1"
fi

line_break() {
echo
echo "*****************************"
Expand Down

0 comments on commit 196c43f

Please sign in to comment.