From d686f676e62ca8c829bcbcca120834fab701db3c Mon Sep 17 00:00:00 2001 From: mikereiddigital Date: Fri, 28 Jun 2024 15:01:52 +0100 Subject: [PATCH] Adds redact to the unit test workflow log. --- .github/workflows/go-terratest.yml | 4 +++- scripts/redact-output.sh | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 scripts/redact-output.sh diff --git a/.github/workflows/go-terratest.yml b/.github/workflows/go-terratest.yml index 0840f44..258e635 100644 --- a/.github/workflows/go-terratest.yml +++ b/.github/workflows/go-terratest.yml @@ -27,4 +27,6 @@ jobs: run: go mod download - name: Run Go Tests working-directory: test - run: go test -v + run: | + chmod 700 ../scripts/redact-output.sh + go test -v | ../scripts/redact-output.sh diff --git a/scripts/redact-output.sh b/scripts/redact-output.sh new file mode 100644 index 0000000..e370724 --- /dev/null +++ b/scripts/redact-output.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Based on: https://github.com/ministryofjustice/opg-org-infra/blob/main/scripts/redact_output.sh + +sed -e 's/AWS_SECRET_ACCESS_KEY".*//g' \ + -e 's/AWS_ACCESS_KEY_ID".*//g' \ + -e 's/$AWS_SECRET_ACCESS_KEY".*//g' \ + -e 's/$AWS_ACCESS_KEY_ID".*//g' \ + -e 's/\[id=.*\]/\[id=\]/g' \ + -e 's/::[0-9]\{12\}:/::REDACTED:/g' \ + -e 's/:[0-9]\{12\}:/:REDACTED:/g'