forked from NHSDigital/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
437e1a4
commit d9f11fd
Showing
6 changed files
with
65 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: "TFSec Scan" | ||
description: "Scan HCL using TFSec" | ||
inputs: | ||
root-modules: | ||
description: "Comma separated list of root module directories to validate, content of the 'infrastructure/environments' is checked by default" | ||
required: false | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: "TFSec Scan Components" | ||
shell: bash | ||
run: | | ||
for component in $(find infrastructure/terraform/components -mindepth 1 -type d); do | ||
scripts/terraform/tfsec.sh $component | ||
done | ||
- name: "TFSec Scan Modules" | ||
shell: bash | ||
run: | | ||
for module in $(find infrastructure/terraform/modules -mindepth 1 -type d); do | ||
scripts/terraform/tfsec.sh $module | ||
done |
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 |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
"**/CVS": true, | ||
"**/Thumbs.db": true, | ||
".devcontainer": true, | ||
".github": true, | ||
".vscode": false | ||
} | ||
} |
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 @@ | ||
minimum_severity: MEDIUM |
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,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Check if tfsec is installed | ||
if ! command -v tfsec &> /dev/null; then | ||
echo "tfsec could not be found, please install it first." | ||
exit 1 | ||
fi | ||
|
||
# Check if a directory was passed as an argument | ||
if [ "$#" -eq 1 ]; then | ||
DIR_TO_SCAN="$1" | ||
elif [ "$#" -gt 1 ]; then | ||
echo "Usage: $0 [directory]" | ||
exit 1 | ||
fi | ||
|
||
# Run tfsec | ||
echo "Running tfsec on directory: $DIR_TO_SCAN" | ||
tfsec \ | ||
--concise-output \ | ||
--force-all-dirs \ | ||
--exclude-downloaded-modules \ | ||
--config-file ../config/tfsec.yaml | ||
"$DIR_TO_SCAN" | ||
|
||
|
||
# Check the exit status of tfsec | ||
if [ $? -eq 0 ]; then | ||
echo "tfsec completed successfully." | ||
else | ||
echo "tfsec found issues." | ||
exit 1 | ||
fi |