Skip to content

Commit 8892e01

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 28cd4c0 commit 8892e01

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/codeql.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
actions: read # Required to read workflow information
23+
contents: read # Required to checkout repository
24+
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
language: ['actions'] # Analyze GitHub Actions workflows
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
33+
with:
34+
persist-credentials: false
35+
36+
- name: Initialize CodeQL
37+
uses: github/codeql-action/init@0d579ffd059c29b07949a3cce3983f0780820c98 # v4
38+
with:
39+
languages: ${{ matrix.language }}
40+
# Optional: Specify custom queries
41+
# queries: security-extended,security-and-quality
42+
43+
- name: Perform CodeQL Analysis
44+
uses: github/codeql-action/analyze@0d579ffd059c29b07949a3cce3983f0780820c98 # v4
45+
with:
46+
category: "/language:${{ matrix.language }}"
47+
upload: true
48+
# Upload SARIF results to GitHub Security tab
49+
output: sarif-results

0 commit comments

Comments
 (0)