Skip to content

Commit ebafac1

Browse files
committed
workflows: add CodeQL analysis workflow for GitHub Actions
Introduce a new CodeQL scanning workflow (.github/workflows/codeql.yml) that statically analyzes all GitHub Actions workflow files in the repository on every pull request targeting main. What it does: - Runs CodeQL with the 'actions' language target, which scans .yml workflow files for security misconfigurations such as missing permissions, unpinned action tags, script injection, and other GitHub Actions-specific vulnerabilities. - Uploads SARIF results to the GitHub Security tab, making findings visible directly in pull requests and the repository's security overview. - Uses concurrency groups to cancel superseded runs on the same branch, avoiding wasted CI time. Security posture of the workflow itself: - Top-level permissions default to contents: read. - The analyze job explicitly declares the minimum required scopes: actions: read (to inspect workflow metadata) and contents: read (to checkout the repository). - All third-party actions are pinned to immutable commit SHAs to prevent supply chain attacks: * actions/checkout @ de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 * codeql-action/init @ 0d579ffd059c29b07949a3cce3983f0780820c98 # v4 * codeql-action/analyze @ 0d579ffd059c29b07949a3cce3983f0780820c98 # v4 - persist-credentials: false is set on checkout to avoid leaking the GITHUB_TOKEN to subsequent steps. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
1 parent 6051c9b commit ebafac1

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/codeql.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
name: "CodeQL Analysis"
3+
# yamllint disable-line rule:truthy
4+
on:
5+
pull_request:
6+
branches:
7+
- 'main'
8+
9+
permissions:
10+
contents: read
11+
12+
# Specifies group name that stops previous workflows if the name matches
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
analyze:
19+
name: Analyze GitHub Actions Workflows
20+
runs-on: ubuntu-latest
21+
permissions:
22+
security-events: write # Required to upload SARIF results
23+
actions: read # Required to read workflow information
24+
contents: read # Required to checkout repository
25+
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
language: ['actions'] # Analyze GitHub Actions workflows
30+
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34+
with:
35+
persist-credentials: false
36+
37+
- name: Initialize CodeQL
38+
uses: github/codeql-action/init@0d579ffd059c29b07949a3cce3983f0780820c98 # v4
39+
with:
40+
languages: ${{ matrix.language }}
41+
# Optional: Specify custom queries
42+
# queries: security-extended,security-and-quality
43+
44+
- name: Perform CodeQL Analysis
45+
uses: github/codeql-action/analyze@0d579ffd059c29b07949a3cce3983f0780820c98 # v4
46+
with:
47+
category: "/language:${{ matrix.language }}"
48+
upload: true
49+
# Upload SARIF results to GitHub Security tab
50+
output: sarif-results

0 commit comments

Comments
 (0)