ci(security): add secret, dependency, shell and injection scans
security / secrets (push) Successful in 9s
security / dependencies (push) Failing after 22s
security / shell (push) Successful in 4s
CI / quality (push) Failing after 42s
security / sast (push) Successful in 29s

This commit is contained in:
BlackAngelTV committed 2026-12-06 18:34:54 +01:00
1 parent 7ce3f7b719
commit fe05ee3ff0
1 file changed
+42 -6
+42 -6
View File
@@ -1,9 +1,10 @@
name: security name: security
# Shared security gate for FWS repositories: leaked credentials, known # Shared security gate for FWS repositories: leaked credentials, known
# vulnerabilities in the dependencies and shell injection patterns. Every tool # vulnerabilities in the dependencies, shell injection patterns and, through
# is a static binary downloaded at run time, so the job does not depend on what # opengrep, the language level injection rules (SQL, command, template, XSS).
# the runner image happens to ship. # 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: on:
push: push:
pull_request: pull_request:
@@ -18,6 +19,7 @@ env:
GITLEAKS_VERSION: '8.28.0' GITLEAKS_VERSION: '8.28.0'
OSV_SCANNER_VERSION: '2.7.1' OSV_SCANNER_VERSION: '2.7.1'
SHELLCHECK_VERSION: '0.10.0' SHELLCHECK_VERSION: '0.10.0'
OPENGREP_VERSION: '2.1.0'
jobs: jobs:
secrets: secrets:
@@ -28,8 +30,8 @@ jobs:
# `dir` scans the checkout rather than the history: a credential that was # `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 # 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 # is what a pull request introduces. A repository that needs to allowlist
# fixtures ship a .gitleaks.toml next to this file. # fixtures ships a .gitleaks.toml next to this file.
- name: Scan the tree for credentials - name: Scan the tree for credentials
run: | run: |
set -euo pipefail set -euo pipefail
@@ -74,7 +76,7 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
git ls-files -z '*.sh' '*.bash' 'PKGBUILD' > "$RUNNER_TEMP/scripts" 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. # 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 # 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; } [ -s "$RUNNER_TEMP/scripts" ] || { echo "No shell scripts in this repository."; exit 0; }
xargs -0 -a "$RUNNER_TEMP/scripts" -r \ xargs -0 -a "$RUNNER_TEMP/scripts" -r \
"$RUNNER_TEMP/shellcheck-v${SHELLCHECK_VERSION}/shellcheck" -x --severity=error "$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 .