-
Notifications
You must be signed in to change notification settings - Fork 0
feat(security): add CodeQL composites and integrate into pr-security-scan #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ea4ffca
ci(codeql): add CodeQL analysis workflow for this repository
bedatty 540b7db
ci(codeql): extract CodeQL steps into composites and improve workflow
bedatty 63acc04
refactor(codeql): use changed-workflows composite and remove push tri…
bedatty 138d109
docs(codeql-analyze): add actions:read to permissions section
bedatty 83e544a
docs(codeql): document wrapped upstream actions in READMEs
bedatty 60a3f28
feat(security): add CodeQL to pr-security-scan and consolidate self-c…
bedatty 4b033f1
refactor(security): extract CodeQL config generation into codeql-conf…
bedatty 5089c6b
fix(security): address code injection risks and improve robustness
bedatty 816be6b
fix(codeql-reporter): mark SARIF unavailable on parse errors and move…
bedatty 79d40ae
fix(codeql-reporter): separate parse errors from SARIF unavailability
bedatty 1dee197
revert(pr-security-scan): remove CodeQL changes from reusable workflow
bedatty eab2c6e
fix(codeql-config): use exact file paths instead of parent directories
bedatty 9a88600
fix(codeql-reporter): add PR filter to security tab link
bedatty 9cdf3c0
fix(security): warn on partial parse errors and remove dead path-mode…
bedatty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| name: Self — CodeQL | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - develop | ||
| - main | ||
| paths: | ||
| - '**.yml' | ||
| - '**.yaml' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| security-events: write | ||
| actions: read | ||
|
|
||
| jobs: | ||
| # ----------------- Changed Files Detection ----------------- | ||
| changed-files: | ||
| name: Detect Changed Files | ||
| runs-on: blacksmith-4vcpu-ubuntu-2404 | ||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| outputs: | ||
| action_files: ${{ steps.detect.outputs.action-files }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Detect changed files | ||
| id: detect | ||
| uses: ./src/config/changed-workflows | ||
| with: | ||
| github-token: ${{ github.token }} | ||
|
|
||
| # ----------------- CodeQL Analysis ----------------- | ||
| analyze: | ||
| name: CodeQL Analysis | ||
| needs: changed-files | ||
| if: needs.changed-files.outputs.action_files != '' | ||
| runs-on: blacksmith-4vcpu-ubuntu-2404 | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Initialize CodeQL | ||
| uses: ./src/security/codeql-init | ||
| with: | ||
| languages: actions | ||
|
|
||
| - name: Perform CodeQL Analysis | ||
| uses: ./src/security/codeql-analyze | ||
| with: | ||
| category: '/language:actions' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <table border="0" cellspacing="0" cellpadding="0"> | ||
| <tr> | ||
| <td><img src="https://github.com/LerianStudio.png" width="72" alt="Lerian" /></td> | ||
| <td><h1>codeql-analyze</h1></td> | ||
| </tr> | ||
| </table> | ||
|
|
||
| Composite action that performs CodeQL analysis and uploads SARIF results to the GitHub Security tab. Designed to be paired with [`codeql-init`](../codeql-init/). | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## Inputs | ||
|
|
||
| | Input | Description | Required | Default | | ||
| |---|---|:---:|---| | ||
| | `category` | Category for SARIF results used for deduplication (e.g., `/language:actions`) | Yes | — | | ||
| | `output` | Output directory for SARIF files | No | `../results` | | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Basic (paired with codeql-init) | ||
|
|
||
| ```yaml | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Initialize CodeQL | ||
| uses: LerianStudio/github-actions-shared-workflows/src/security/codeql-init@v1.x.x | ||
| with: | ||
| languages: actions | ||
|
|
||
| - name: Perform CodeQL Analysis | ||
| uses: LerianStudio/github-actions-shared-workflows/src/security/codeql-analyze@v1.x.x | ||
| with: | ||
| category: '/language:actions' | ||
| ``` | ||
|
|
||
| ## Permissions required | ||
|
|
||
| ```yaml | ||
| permissions: | ||
| contents: read | ||
| security-events: write # required for SARIF upload to GitHub Security tab | ||
| ``` | ||
|
bedatty marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: CodeQL Analyze | ||
| description: Perform CodeQL analysis and upload SARIF results to GitHub Security tab | ||
|
|
||
| inputs: | ||
| category: | ||
| description: 'Category for SARIF results used for deduplication (e.g., /language:actions)' | ||
| required: true | ||
| output: | ||
| description: 'Output directory for SARIF files' | ||
| required: false | ||
| default: '../results' | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Perform CodeQL Analysis | ||
| uses: github/codeql-action/analyze@v4 | ||
| with: | ||
| category: ${{ inputs.category }} | ||
| output: ${{ inputs.output }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| <table border="0" cellspacing="0" cellpadding="0"> | ||
| <tr> | ||
| <td><img src="https://github.com/LerianStudio.png" width="72" alt="Lerian" /></td> | ||
| <td><h1>codeql-init</h1></td> | ||
| </tr> | ||
| </table> | ||
|
|
||
| Composite action that initializes CodeQL analysis for specified languages. Uses the `security-extended` query suite by default for broader coverage. Designed to be paired with [`codeql-analyze`](../codeql-analyze/). | ||
|
|
||
| ## Inputs | ||
|
|
||
| | Input | Description | Required | Default | | ||
| |---|---|:---:|---| | ||
| | `languages` | Languages to analyze (comma-separated, e.g., `actions`, `javascript-typescript`, `go`) | Yes | — | | ||
| | `queries` | Query suite to use (`security-standard`, `security-extended`, `security-and-quality`) | No | `security-extended` | | ||
| | `config-file` | Path to CodeQL configuration file | No | — | | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Basic (GitHub Actions YAML analysis) | ||
|
|
||
| ```yaml | ||
| jobs: | ||
| codeql: | ||
| runs-on: blacksmith-4vcpu-ubuntu-2404 | ||
| permissions: | ||
| contents: read | ||
| security-events: write | ||
| actions: read | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Initialize CodeQL | ||
| uses: LerianStudio/github-actions-shared-workflows/src/security/codeql-init@v1.x.x | ||
| with: | ||
| languages: actions | ||
|
|
||
| - name: Analyze | ||
| uses: LerianStudio/github-actions-shared-workflows/src/security/codeql-analyze@v1.x.x | ||
| with: | ||
| category: '/language:actions' | ||
| ``` | ||
|
|
||
| ### Multiple languages | ||
|
|
||
| ```yaml | ||
| - name: Initialize CodeQL | ||
| uses: LerianStudio/github-actions-shared-workflows/src/security/codeql-init@v1.x.x | ||
| with: | ||
| languages: javascript-typescript | ||
| queries: security-and-quality | ||
| ``` | ||
|
|
||
| ## Permissions required | ||
|
|
||
| ```yaml | ||
| permissions: | ||
| contents: read | ||
| security-events: write | ||
| actions: read # required for workflows using private repositories | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: CodeQL Init | ||
| description: Initialize CodeQL analysis for specified languages with configurable query suite | ||
|
|
||
| inputs: | ||
| languages: | ||
| description: 'Languages to analyze (comma-separated, e.g., actions, javascript-typescript, go)' | ||
| required: true | ||
| queries: | ||
| description: 'Query suite to use (security-standard, security-extended, security-and-quality)' | ||
| required: false | ||
| default: 'security-extended' | ||
| config-file: | ||
| description: 'Path to CodeQL configuration file' | ||
| required: false | ||
| default: '' | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Initialize CodeQL | ||
| uses: github/codeql-action/init@v4 | ||
| with: | ||
| languages: ${{ inputs.languages }} | ||
| queries: ${{ inputs.queries }} | ||
| config-file: ${{ inputs.config-file || '' }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.