Skip to content

Commit cec960e

Browse files
authored
Create codeql.yml
1 parent 67b5a06 commit cec960e

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

.github/workflows/codeql.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# ===============================================================
2+
# 🔍 CodeQL Advanced – Multi-Language Static Analysis Workflow
3+
# ===============================================================
4+
#
5+
# This workflow:
6+
# • Scans JavaScript/TypeScript, Python, and GitHub Actions workflows
7+
# • Detects security vulnerabilities and code quality issues
8+
# • Uploads SARIF results to the “Code scanning” tab in GitHub Security
9+
# • Caches databases and dependencies to speed up analysis
10+
# • Runs on every push/PR to `main` and weekly (Wednesday @ 21:15 UTC)
11+
#
12+
# ---------------------------------------------------------------
13+
14+
name: CodeQL Advanced
15+
16+
on:
17+
push:
18+
branches: [ "main" ]
19+
pull_request:
20+
branches: [ "main" ]
21+
schedule:
22+
- cron: '15 21 * * 3' # Weekly on Wednesday at 21:15 UTC
23+
24+
# -----------------------------------------------------------------
25+
# Minimal permissions – principle of least privilege
26+
# -----------------------------------------------------------------
27+
permissions:
28+
contents: read # for checking out the code
29+
security-events: write # required to upload SARIF results
30+
actions: read # required in private repositories
31+
packages: read # required to download CodeQL packs
32+
33+
jobs:
34+
analyze:
35+
name: CodeQL (${{ matrix.language }})
36+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
37+
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
include:
42+
- language: javascript-typescript
43+
build: none
44+
- language: python
45+
build: none
46+
- language: actions
47+
build: none
48+
49+
steps:
50+
# -------------------------------------------------------------
51+
# 0️⃣ Checkout source
52+
# -------------------------------------------------------------
53+
- name: ⬇️ Checkout code
54+
uses: actions/checkout@v4
55+
56+
# -------------------------------------------------------------
57+
# 1️⃣ Optional setup – runtimes for specific languages
58+
# -------------------------------------------------------------
59+
- name: 🐍 Setup Python
60+
if: matrix.language == 'python'
61+
uses: actions/setup-python@v5
62+
with:
63+
python-version: '3.x'
64+
65+
- name: 🟢 Setup Node.js
66+
if: matrix.language == 'javascript-typescript'
67+
uses: actions/setup-node@v4
68+
with:
69+
node-version: '20'
70+
71+
# -------------------------------------------------------------
72+
# 2️⃣ Initialize CodeQL
73+
# -------------------------------------------------------------
74+
- name: 🛠️ Initialize CodeQL
75+
uses: github/codeql-action/init@v3
76+
with:
77+
languages: ${{ matrix.language }}
78+
dependency-caching: true
79+
queries: |
80+
+security-extended
81+
+security-and-quality
82+
83+
# -------------------------------------------------------------
84+
# 3️⃣ Manual build step (not needed for JS/Python/Actions)
85+
# -------------------------------------------------------------
86+
- if: matrix.build == 'manual'
87+
name: ⚙️ Manual build (placeholder)
88+
shell: bash
89+
run: |
90+
echo "Add manual build commands here if needed."
91+
exit 1
92+
93+
# -------------------------------------------------------------
94+
# 4️⃣ Perform CodeQL analysis
95+
# -------------------------------------------------------------
96+
- name: 🔬 Perform CodeQL analysis
97+
uses: github/codeql-action/analyze@v3
98+
with:
99+
category: "/language:${{ matrix.language }}"

0 commit comments

Comments
 (0)