Skip to content

Commit 407c660

Browse files
committed
ci: add security scanning workflow with Gitleaks, Trivy, and npm audit
Runs on push to main, PRs, weekly cron (Monday 06:00 UTC), and manual dispatch. Gitleaks detects leaked secrets, Trivy scans the filesystem for known CVEs, and npm audit checks production dependencies. Closes #42 Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent 66fc2cd commit 407c660

1 file changed

Lines changed: 55 additions & 60 deletions

File tree

.github/workflows/security.yml

Lines changed: 55 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,76 @@
1-
name: Security
1+
name: security
22

33
on:
4-
pull_request:
5-
branches: [main]
64
push:
75
branches: [main]
6+
pull_request:
87
schedule:
9-
- cron: "0 6 * * 1" # Monday 6am UTC
8+
- cron: "0 6 * * 1"
109
workflow_dispatch:
1110

11+
permissions:
12+
contents: read
13+
1214
concurrency:
1315
group: security-${{ github.ref }}
1416
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
1517

16-
permissions:
17-
contents: read
18-
1918
jobs:
19+
gitleaks:
20+
name: Secret detection
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 5
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v6
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Gitleaks
30+
uses: gitleaks/gitleaks-action@v2
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
2034
trivy:
21-
name: Trivy
22-
runs-on:
23-
- self-hosted
24-
- macOS
25-
- ARM64
26-
- patchloom-vscode
35+
name: Vulnerability scan
36+
runs-on: ubuntu-latest
2737
timeout-minutes: 10
2838
steps:
29-
- name: Harden Runner
30-
uses: step-security/harden-runner@v2
39+
- name: Checkout
40+
uses: actions/checkout@v6
41+
42+
- name: Setup Node.js
43+
uses: actions/setup-node@v6
3144
with:
32-
egress-policy: audit
33-
- uses: actions/checkout@v6
34-
- name: Install Trivy
35-
run: |
36-
if ! command -v trivy &>/dev/null; then
37-
brew install trivy
38-
fi
45+
node-version-file: .nvmrc
46+
cache: npm
47+
48+
- name: Install dependencies
49+
run: npm ci
50+
3951
- name: Trivy filesystem scan
40-
run: trivy fs --scanners vuln --severity HIGH,CRITICAL --exit-code 1 --ignore-unfixed .
52+
uses: aquasecurity/trivy-action@master
53+
with:
54+
scan-type: fs
55+
severity: HIGH,CRITICAL
56+
exit-code: 1
4157

42-
gitleaks:
43-
name: Gitleaks
44-
runs-on:
45-
- self-hosted
46-
- macOS
47-
- ARM64
48-
- patchloom-vscode
58+
npm-audit:
59+
name: npm audit
60+
runs-on: ubuntu-latest
4961
timeout-minutes: 5
5062
steps:
51-
- name: Harden Runner
52-
uses: step-security/harden-runner@v2
53-
with:
54-
egress-policy: audit
55-
- uses: actions/checkout@v6
63+
- name: Checkout
64+
uses: actions/checkout@v6
65+
66+
- name: Setup Node.js
67+
uses: actions/setup-node@v6
5668
with:
57-
fetch-depth: 0
58-
- name: Install gitleaks
59-
env:
60-
GITLEAKS_VERSION: "8.30.1"
61-
run: |
62-
if command -v gitleaks &>/dev/null; then
63-
echo "gitleaks already installed"
64-
exit 0
65-
fi
66-
archive="${RUNNER_TEMP}/gitleaks.tar.gz"
67-
bindir="${RUNNER_TEMP}/gitleaks-bin"
68-
mkdir -p "$bindir"
69-
case "$(uname -s)-$(uname -m)" in
70-
Linux-x86_64) platform="linux_x64" ;;
71-
Linux-aarch64) platform="linux_arm64" ;;
72-
Darwin-x86_64) platform="darwin_x64" ;;
73-
Darwin-arm64) platform="darwin_arm64" ;;
74-
*) echo "Unsupported platform: $(uname -s)-$(uname -m)" >&2; exit 1 ;;
75-
esac
76-
curl --retry 5 --retry-all-errors --retry-delay 2 -sSfL \
77-
-o "$archive" \
78-
"https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_${platform}.tar.gz"
79-
tar -xzf "$archive" -C "$bindir" gitleaks
80-
printf '%s\n' "$bindir" >> "$GITHUB_PATH"
81-
- run: gitleaks detect --source . --exit-code 1
69+
node-version-file: .nvmrc
70+
cache: npm
71+
72+
- name: Install dependencies
73+
run: npm ci
74+
75+
- name: Audit production dependencies
76+
run: npm audit --audit-level=high --omit=dev

0 commit comments

Comments
 (0)