Skip to content

Commit 574ce38

Browse files
authored
feat(ci): added codeql scanning workflow (#4462)
Codeql to run on pull_requests and push to cover both normal and unusual changes # What does this PR do? Adding codeql scans to avoid command injection and [pwn request](https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/) issues Design: - Runs only `actions` language checks for speed, extendable in case javascript type actions need to be scanned - Runs only if workflow files are changed - Only runs the tests on main branch pushes/PRs Having issues will not fail the runs, only updates security findings, it is possible to make this specifically gating to merge through a Branch Protection Rule with the following option: <img width="1744" height="522" alt="image" src="https://github.com/user-attachments/assets/cf5f5abe-fddf-4590-9eca-fd325b54f070" /> <img width="1758" height="192" alt="image" src="https://github.com/user-attachments/assets/d5e9835d-5e5e-4e72-9087-b3434ef7c260" /> Appx 1m to run faster than the current slowest job ## Test Plan See [test pr](gmatuz#1 )
1 parent e59a167 commit 574ce38

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

.github/workflows/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Llama Stack uses GitHub Actions for Continuous Integration (CI). Below is a tabl
66
| ---- | ---- | ------- |
77
| Backward Compatibility Check | [backward-compat.yml](backward-compat.yml) | Check backward compatibility for config.yaml files |
88
| Build Distribution Images | [build-distributions.yml](build-distributions.yml) | Build Distribution Images |
9+
| CodeQL Workflow Security Scan | [codeql.yml](codeql.yml) | CodeQL Workflow Security Scan |
910
| API Conformance Tests | [conformance.yml](conformance.yml) | Run the API Conformance test suite on the changes. |
1011
| Installer CI | [install-script-ci.yml](install-script-ci.yml) | Test the installation script |
1112
| Integration Auth Tests | [integration-auth-tests.yml](integration-auth-tests.yml) | Run the integration test suite with Kubernetes authentication |

.github/workflows/codeql.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "CodeQL Workflow Security Scan"
2+
3+
on:
4+
push:
5+
# Running on push for workflows not going through PRs
6+
branches: [ "main" ]
7+
# Limit scans to changes in the .github directory, bash scripts are not scanned anyway
8+
paths:
9+
- '.github/**'
10+
pull_request:
11+
# PRs are checked for new issues
12+
branches: [ "main" ]
13+
# Limit scans to changes in the .github directory, bash scripts are not scanned anyway
14+
paths:
15+
- '.github/**'
16+
17+
jobs:
18+
analyze:
19+
name: Analyze
20+
runs-on: ubuntu-latest
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
# actions is the most specific language option for
25+
# codeql does NOT support Bash
26+
# In case javascript is used in workflows, that should be added or replace
27+
language: [ 'actions' ]
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
32+
33+
# Initializes CodeQL tools for scanning.
34+
- name: Initialize CodeQL
35+
uses: github/codeql-action/init@45c373516f557556c15d420e3f5e0aa3d64366bc # v3
36+
with:
37+
languages: ${{ matrix.language }}
38+
# "security-extended" is recommended for higher severity coverage - not necessary can be removed to speed up
39+
queries: security-extended
40+
41+
# Scans the code and uploads results to GitHub Security tab.
42+
# The "Fail on High" logic is handled by Branch Protection Rules in Settings
43+
- name: Perform CodeQL Analysis
44+
uses: github/codeql-action/analyze@45c373516f557556c15d420e3f5e0aa3d64366bc # v3
45+
with:
46+
category: "/language:${{ matrix.language }}"

0 commit comments

Comments
 (0)