diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..ca79ca5 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/security-scan.yml b/.github/workflows/security-scan.yml new file mode 100644 index 0000000..9d96752 --- /dev/null +++ b/.github/workflows/security-scan.yml @@ -0,0 +1,56 @@ +name: Security scan + +# Dependency vulnerabilities (osv-scanner) on every push/PR and weekly; +# leaked secrets (gitleaks) in the commits a push or PR adds. +# Scanner binaries are pinned by version and verified by SHA-256. + +on: + push: + branches: [main] + pull_request: + schedule: + - cron: "13 8 * * 1" + workflow_dispatch: + +permissions: + contents: read + +jobs: + scan: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Install scanners + run: | + set -euo pipefail + cd "$RUNNER_TEMP" + curl -fsSLo osv-scanner https://github.com/google/osv-scanner/releases/download/v2.7.1/osv-scanner_linux_amd64 + echo "fb7dab19a8bd9bbe5c3189f09d4b7ee1820c9553a23bac202648a56efd2f6ee8 osv-scanner" | sha256sum -c - + curl -fsSLo gitleaks.tgz https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_x64.tar.gz + echo "551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb gitleaks.tgz" | sha256sum -c - + tar -xzf gitleaks.tgz gitleaks + chmod +x osv-scanner gitleaks + echo "$RUNNER_TEMP" >> "$GITHUB_PATH" + + - name: Dependency vulnerabilities (osv-scanner) + run: | + rc=0 + osv-scanner scan source -r . || rc=$? + # 128 = no lockfiles/manifests found; nothing to scan. + if [ "$rc" -eq 128 ]; then echo "No dependency manifests found."; exit 0; fi + exit "$rc" + + - name: Secrets in new commits (gitleaks) + if: github.event_name == 'push' || github.event_name == 'pull_request' + env: + BASE: ${{ github.event.pull_request.base.sha || github.event.before }} + run: | + if [ -z "$BASE" ] || [ "$BASE" = "0000000000000000000000000000000000000000" ]; then + echo "No base commit (new branch); skipping." + exit 0 + fi + gitleaks git . --redact --no-banner --log-opts="$BASE..HEAD"