ci(security): add secret, dependency, shell and injection scans
This commit is contained in:
1 file changed
+42
-6
@@ -1,9 +1,10 @@
|
||||
name: security
|
||||
|
||||
# Shared security gate for FWS repositories: leaked credentials, known
|
||||
# vulnerabilities in the dependencies and shell injection patterns. Every tool
|
||||
# is a static binary downloaded at run time, so the job does not depend on what
|
||||
# the runner image happens to ship.
|
||||
# vulnerabilities in the dependencies, shell injection patterns and, through
|
||||
# opengrep, the language level injection rules (SQL, command, template, XSS).
|
||||
# Every tool is a static binary downloaded at run time so the job does not
|
||||
# depend on what the runner image happens to ship.
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
@@ -18,6 +19,7 @@ env:
|
||||
GITLEAKS_VERSION: '8.28.0'
|
||||
OSV_SCANNER_VERSION: '2.7.1'
|
||||
SHELLCHECK_VERSION: '0.10.0'
|
||||
OPENGREP_VERSION: '2.1.0'
|
||||
|
||||
jobs:
|
||||
secrets:
|
||||
@@ -28,8 +30,8 @@ jobs:
|
||||
|
||||
# `dir` scans the checkout rather than the history: a credential that was
|
||||
# removed from the tree must not keep the gate red forever, and the tree
|
||||
# is what a pull request introduces. Repositories that need to allowlist
|
||||
# fixtures ship a .gitleaks.toml next to this file.
|
||||
# is what a pull request introduces. A repository that needs to allowlist
|
||||
# fixtures ships a .gitleaks.toml next to this file.
|
||||
- name: Scan the tree for credentials
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -74,7 +76,7 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git ls-files -z '*.sh' '*.bash' 'PKGBUILD' > "$RUNNER_TEMP/scripts"
|
||||
echo "$(tr -cd '\0' < "$RUNNER_TEMP/scripts" | wc -c) shell files to check"
|
||||
printf '%s shell files to check\n' "$(tr -cd '\0' < "$RUNNER_TEMP/scripts" | wc -c)"
|
||||
|
||||
# SC2086/SC2046 and friends are the shapes an injection takes in shell.
|
||||
# They stay advisory for now: existing scripts would turn the gate red on
|
||||
@@ -93,3 +95,37 @@ jobs:
|
||||
[ -s "$RUNNER_TEMP/scripts" ] || { echo "No shell scripts in this repository."; exit 0; }
|
||||
xargs -0 -a "$RUNNER_TEMP/scripts" -r \
|
||||
"$RUNNER_TEMP/shellcheck-v${SHELLCHECK_VERSION}/shellcheck" -x --severity=error
|
||||
|
||||
sast:
|
||||
name: sast
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install opengrep
|
||||
run: |
|
||||
set -euo pipefail
|
||||
curl -fsSL -o "$RUNNER_TEMP/opengrep" \
|
||||
"https://github.com/opengrep/opengrep/releases/download/v${OPENGREP_VERSION}/opengrep_linux_x86"
|
||||
chmod +x "$RUNNER_TEMP/opengrep"
|
||||
|
||||
# Advisory on purpose: the rules flag real injection shapes (SQL, command,
|
||||
# template, XSS) but also patterns that a codebase already reviewed. Run
|
||||
# it blocking once the reported findings have been triaged and the false
|
||||
# positives allowlisted in .semgrepignore.
|
||||
- name: Injection and unsafe-pattern scan (advisory)
|
||||
continue-on-error: true
|
||||
run: |
|
||||
set -uo pipefail
|
||||
args=()
|
||||
git ls-files '*.php' | grep -q . && args+=(--config p/php) || true
|
||||
git ls-files '*.js' '*.mjs' '*.cjs' '*.ts' | grep -q . && args+=(--config p/javascript) || true
|
||||
git ls-files '*.py' | grep -q . && args+=(--config p/python) || true
|
||||
git ls-files '*.go' | grep -q . && args+=(--config p/golang) || true
|
||||
if [ "${#args[@]}" -eq 0 ]; then
|
||||
echo "No supported source files in this repository."
|
||||
exit 0
|
||||
fi
|
||||
"$RUNNER_TEMP/opengrep" scan "${args[@]}" --severity ERROR \
|
||||
--exclude 3rdparty --exclude node_modules --exclude vendor --exclude external .
|
||||
Reference in new issue
Block a user