Skip to content

Commit 9756b22

Browse files
add security scan flow
1 parent dc3c592 commit 9756b22

1 file changed

Lines changed: 58 additions & 45 deletions

File tree

.github/workflows/security-scan.yml

Lines changed: 58 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@ on:
44
push:
55
pull_request:
66

7+
permissions:
8+
contents: read
9+
security-events: write
10+
711
jobs:
8-
security:
9-
name: Security & Secrets Scan
12+
security-scan:
13+
name: Universal Security Scanner
1014
runs-on: ubuntu-latest
1115

1216
steps:
13-
- name: Checkout code
17+
- name: Checkout repository
1418
uses: actions/checkout@v4
1519
with:
16-
fetch-depth: 0 # IMPORTANT: scan full history
20+
fetch-depth: 0
1721

1822
# -----------------------------
1923
# 1. GITLEAKS
@@ -24,14 +28,13 @@ jobs:
2428
args: detect --source . --no-git
2529

2630
# -----------------------------
27-
# 2. TRUFFLEHOG (deep secrets)
31+
# 2. TRUFFLEHOG
2832
# -----------------------------
2933
- name: Run TruffleHog
30-
uses: trufflesecurity/trufflehog@v3
34+
uses: trufflesecurity/trufflehog@main
3135
with:
32-
path: .
33-
# Search git history too
34-
base: origin/main
36+
scan: filesystem
37+
path: "."
3538

3639
# -----------------------------
3740
# 3. detect-secrets
@@ -45,54 +48,64 @@ jobs:
4548
detect-secrets audit .secrets.baseline || exit 1
4649
4750
# -----------------------------
48-
# 4. NPM / Node dependency scan
51+
# 4. Dependency Scanners (auto)
4952
# -----------------------------
50-
- name: Install Node (optional)
51-
uses: actions/setup-node@v4
52-
with:
53-
node-version: 20
5453

55-
- name: Run npm audit
54+
# NodeJS
55+
- name: npm audit (only if package.json exists)
56+
if: hashFiles('package.json') != ''
5657
run: |
57-
if [ -f package-lock.json ]; then
58-
npm ci
59-
npm audit --production --audit-level=high
60-
fi
58+
npm install --ignore-scripts
59+
npm audit --audit-level=high
6160
62-
# -----------------------------
63-
# 5. Python dependency scan
64-
# -----------------------------
65-
- name: Python dependency audit
66-
uses: pypa/gh-action-pip-audit@v1.0.8
61+
# Python
62+
- name: pip-audit (only if requirements.txt exists)
6763
if: hashFiles('requirements.txt') != ''
64+
uses: pypa/gh-action-pip-audit@v1.0.8
6865

69-
# -----------------------------
70-
# 6. CodeQL Analysis (vulnerabilities)
71-
# -----------------------------
66+
# PHP Composer
67+
- name: Composer audit (only if composer.json exists)
68+
if: hashFiles('composer.json') != ''
69+
run: |
70+
sudo apt-get update
71+
sudo apt-get install -y composer
72+
composer install --no-scripts
73+
composer audit || true
74+
75+
# Go
76+
- name: Go vet (only if go.mod exists)
77+
if: hashFiles('go.mod') != ''
78+
uses: actions/setup-go@v5
79+
with:
80+
go-version: 'stable'
81+
- name: Go vulnerability check
82+
if: hashFiles('go.mod') != ''
83+
run: |
84+
go mod tidy
85+
go vet ./...
86+
go list -json -deps ./... | go vuln check
87+
88+
# -----------------------------
89+
# 5. CODEQL (Auto-detect languages)
90+
# -----------------------------
7291
codeql:
73-
name: CodeQL
74-
runs-on: ubuntu-latest
7592
permissions:
76-
security-events: write
77-
actions: read
7893
contents: read
94+
security-events: write
7995

80-
strategy:
81-
fail-fast: false
82-
matrix:
83-
language: [ 'javascript', 'typescript', 'python', 'go' ] # adjust
96+
runs-on: ubuntu-latest
8497

8598
steps:
86-
- name: Checkout code
87-
uses: actions/checkout@v4
99+
- name: Checkout code
100+
uses: actions/checkout@v4
88101

89-
- name: Initialize CodeQL
90-
uses: github/codeql-action/init@v3
91-
with:
92-
languages: ${{ matrix.language }}
102+
- name: Initialize CodeQL
103+
uses: github/codeql-action/init@v3
104+
with:
105+
languages: auto
93106

94-
- name: Autobuild
95-
uses: github/codeql-action/autobuild@v3
107+
- name: Autobuild
108+
uses: github/codeql-action/autobuild@v3
96109

97-
- name: Analyze
98-
uses: github/codeql-action/analyze@v3
110+
- name: Analyze
111+
uses: github/codeql-action/analyze@v3

0 commit comments

Comments
 (0)