-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (93 loc) · 3.21 KB
/
Copy pathcodeql.yml
File metadata and controls
112 lines (93 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Security - CodeQL Analysis
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches: [ main ]
paths:
- '.github/workflows/**'
- '**/*.js'
- '**/*.ts'
- '**/*.mjs'
- '**/*.cjs'
- 'package.json'
- 'pnpm-lock.yaml'
- '.github/workflows/codeql.yml'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/**'
- '**/*.js'
- '**/*.ts'
- '**/*.mjs'
- '**/*.cjs'
- 'package.json'
- 'pnpm-lock.yaml'
- '.github/workflows/codeql.yml'
schedule:
# Run weekly on Mondays at 2 AM UTC
- cron: '0 2 * * 1'
jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
issues: write
security-events: write
pull-requests: write
strategy:
fail-fast: false
matrix:
language: [ 'actions' ]
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
queries: security-extended,security-and-quality
- name: Perform CodeQL Analysis
id: analyze
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"
upload: true
- name: Comment PR with CodeQL Results
if: github.event_name == 'pull_request' && steps.analyze.outcome == 'success'
uses: actions/github-script@v9
with:
script: |
const body = `🔍 **CodeQL Analysis Complete** (${{ matrix.language }})
CodeQL analysis has completed successfully. Results are available in the **Security** tab of this PR.
**Language Analyzed:** ${{ matrix.language }}
**Query Suite:** security-extended, security-and-quality
📋 **View Results:**
- Check the Security tab above for detailed findings
- Review any alerts and address them before merging
> **Note:** CodeQL does not natively support PowerShell. This analysis covers GitHub Actions workflows in \`.github/workflows\`.
*Analysis performed automatically by CodeQL*`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
- name: Comment PR with CodeQL Errors
if: github.event_name == 'pull_request' && steps.analyze.outcome == 'failure'
uses: actions/github-script@v9
with:
script: |
const body = `❌ **CodeQL Analysis Failed** (${{ matrix.language }})
CodeQL analysis encountered an error. Please check the workflow logs for details.
**Language:** ${{ matrix.language }}
*Check the workflow run for error details.*`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});