|
1 | | -name: "CodeQL Advanced Analysis" |
| 1 | +name: "CodeQL Analysis" |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: [ "main", "master" ] # Trigger analysis on push to main branches |
| 5 | + branches: [ "main" ] |
6 | 6 | pull_request: |
7 | | - branches: [ "main", "master" ] # Also run on PRs targeting these branches |
| 7 | + branches: [ "main" ] |
8 | 8 | schedule: |
9 | | - - cron: "0 2 * * 1" # Optional: run a scheduled scan every Monday at 2 AM UTC |
| 9 | + - cron: "0 2 * * 1" # Weekly Monday scan |
10 | 10 |
|
11 | 11 | permissions: |
12 | 12 | contents: read |
13 | 13 | security-events: write |
14 | | - actions: read |
15 | 14 |
|
16 | 15 | jobs: |
17 | 16 | analyze: |
18 | | - name: "CodeQL Analyze" |
| 17 | + name: Analyze Code with CodeQL |
19 | 18 | runs-on: ubuntu-latest |
20 | 19 | permissions: |
21 | | - security-events: write |
22 | 20 | contents: read |
23 | | - actions: read |
| 21 | + security-events: write |
24 | 22 |
|
25 | 23 | strategy: |
26 | | - fail-fast: false |
27 | 24 | matrix: |
28 | | - language: [ 'javascript', 'python', 'java' ] # Add or remove languages based on your repo |
| 25 | + language: [ 'javascript' ] # ✅ Only scan JavaScript (or 'typescript' if used) |
29 | 26 |
|
30 | 27 | steps: |
31 | 28 | - name: Checkout repository |
32 | 29 | uses: actions/checkout@v4 |
33 | 30 |
|
34 | | - # (Optional) Setup environment, dependencies, or build tools here |
35 | 31 | - name: Setup Node.js |
36 | | - if: matrix.language == 'javascript' |
37 | 32 | uses: actions/setup-node@v4 |
38 | 33 | with: |
39 | 34 | node-version: '20' |
40 | 35 |
|
41 | | - - name: Setup Python |
42 | | - if: matrix.language == 'python' |
43 | | - uses: actions/setup-python@v5 |
44 | | - with: |
45 | | - python-version: '3.11' |
46 | | - |
47 | | - - name: Setup Java |
48 | | - if: matrix.language == 'java' |
49 | | - uses: actions/setup-java@v4 |
50 | | - with: |
51 | | - java-version: '17' |
52 | | - distribution: 'temurin' |
53 | | - |
54 | | - # (Optional) Install project dependencies |
55 | | - - name: Install dependencies |
56 | | - if: matrix.language == 'javascript' |
| 36 | + - name: Install dependencies (if package.json exists) |
| 37 | + if: hashFiles('**/package.json') != '' |
57 | 38 | run: npm ci |
58 | 39 |
|
59 | 40 | - name: Initialize CodeQL |
60 | 41 | uses: github/codeql-action/init@v3 |
61 | 42 | with: |
62 | 43 | languages: ${{ matrix.language }} |
63 | | - queries: +security-and-quality # Runs both security and quality query suites |
| 44 | + queries: +security-and-quality |
64 | 45 |
|
| 46 | + # For JS/TS projects, autobuild is usually enough |
65 | 47 | - name: Autobuild |
66 | 48 | uses: github/codeql-action/autobuild@v3 |
67 | 49 |
|
68 | | - # (Optional) Manual build step (if autobuild fails) |
69 | | - # - name: Build manually |
70 | | - # run: | |
71 | | - # mvn clean install -DskipTests=true |
72 | | - |
73 | 50 | - name: Perform CodeQL Analysis |
74 | 51 | uses: github/codeql-action/analyze@v3 |
75 | | - with: |
76 | | - category: "/language:${{ matrix.language }}" |
0 commit comments