Skip to content
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

use octosts for downloading protected tf-modules #43

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vscode
.DS_Store
.DS_Store
.idea
34 changes: 29 additions & 5 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,35 @@ inputs:
description: "A category for describing the Trivy action. Useful for differentiating between different runs of different images."
required: false
default: "Trivy"
scan_platform_modules:
description: "If you need to use terraform platform modules (github.com/kartverket/terraform-modules)"
required: false
default: "false"
skip_dirs:
description: "comma seperated list of directories where traversal is skipped"
required: false
default: ""

runs:
using: "composite"
steps:
- name: Checkout Repository
- uses: octo-sts/action@6177b4481c00308b3839969c3eca88c96a91775f # v1.0.0
if: inputs.scan_platform_modules == 'true'
id: octo-sts
with:
scope: kartverket
identity: kartverket_repos
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v4
with:
submodules: ${{ inputs.checkout_submodules == 'true' && 'recursive' || 'false' }}
token: ${{ inputs.checkout_submodules == 'true' && steps.octo-sts.outputs.token || github.token }}

- name: hack for github internal repo access
if: inputs.scan_platform_modules == 'true'
run: git config --global url."https://x-access-token:${{ steps.octo-sts.outputs.token }}@github.com".insteadOf ssh://git@github.com
shell: bash

- name: Check If Both Scans Disabled
if: (inputs.trivy == 'false' || inputs.image_url == '') && inputs.tfsec == 'false'
Expand Down Expand Up @@ -63,6 +86,7 @@ runs:
output: trivy-config.sarif
severity: UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
timeout: 15m
skip-dirs: ${{ inputs.skip_dirs }}

- name: Upload SARIF file
if: inputs.tfsec == 'true'
Expand Down Expand Up @@ -169,15 +193,15 @@ runs:
_message="$error_start_message high or critical found on branch '$REF_NAME'. $error_end_message";
_exit_code=1;
fi

elif [[ $ALLOW_SEVERITY_LEVEL == 'high' ]]
then
if [[ $is_critical_vuln_present == 'false' ]]
then
_message="Only high vulnerabilities detected! Allowing due to input ALLOW_SEVERITY_LEVEL being set to high.";
_exit_code=0;
fi

if [[ ${{ github.event_name }} == 'pull_request' ]]
then
_message="$error_start_message critical. $error_end_message $error_search_pr_message";
Expand All @@ -186,12 +210,12 @@ runs:
_message="$error_start_message critical found on '$REF_NAME' branch. $error_end_message";
_exit_code=1
fi

elif [[ $ALLOW_SEVERITY_LEVEL == 'critical' ]]
then
_message="High or critical vulnerabilities detected! Allowing due to input ALLOW_SEVERITY_LEVEL being set to critical.";
_exit_code=0;

else
_message="Input 'ALLOW_SEVERITY_LEVEL' was not one of the known values, found '$ALLOW_SEVERITY_LEVEL'. If you see this message, please contact SKIP.";
_exit_code=1
Expand Down