Skip to content

Commit 3cd7ec1

Browse files
PLAT-15858 Update documentation and remove language detection code (#248)
* Normalizes CodeQL tool driver name matching Ensures that the CodeQL tool driver name is correctly overwritten to 'GitHub CodeQL' regardless of case or surrounding whitespace. Updates the logic to trim and lowercase the tool driver name before comparing it to "codeql", handling variations in casing and spacing. Also adds unit tests to verify the fix works for different cases. * Bump dependency versions * More updates * Remove unused github token * Minor updates to README --------- Co-authored-by: Colin Wong <[email protected]>
1 parent e15a6ee commit 3cd7ec1

17 files changed

+4064
-3210
lines changed

README.md

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,39 @@
1-
# GitHub Action
1+
# Secure Code Warrior SARIF Processing Tool
22

3-
This GitHub Action adds Secure Code Warrior contextual application security training material to SARIF files. This training material will be displayed within Code Scanning alerts if the resulting SARIF file is imported using the `github/codeql-action/upload-sarif` Action, and includes links to secure coding exercises and short explainer videos where available.
3+
## Overview
44

5-
This Action currently supports adding training material based on CWE references (e.g. CWE 89) and common vulnerability phrases (e.g. use-after-free vulnerability) included in static analysis findings.
5+
This tool processes SARIF (Static Analysis Results Interchange Format) files, typically generated by static code analysis tools like CodeQL, and can be run as a GitHub Action or as a standalone CLI tool.
6+
It adds Secure Code Warrior contextual application security training material to SARIF files.
7+
This training material will be displayed within Code Scanning alerts if the resulting SARIF file is imported using the `github/codeql-action/upload-sarif` Action, and includes links to secure coding exercises and short explainer videos where available.
8+
This tool currently supports adding training material based on CWE references (e.g. CWE 89) and common vulnerability phrases (e.g. use-after-free vulnerability) included in static analysis findings.
69

7-
## Usage
10+
### Key Features
11+
12+
- **Integration of Secure Code Warrior Training Material:**
13+
14+
The tool enriches SARIF files by adding **Secure Code Warrior** contextual application security training content. When the resulting SARIF file is imported using the [`github/codeql-action/upload-sarif`](https://github.com/github/codeql-action) GitHub Action, this training material is displayed directly within Code Scanning alerts.
15+
16+
The added content includes links to:
17+
18+
- Secure coding exercises
19+
- Short explainer videos (where available)
20+
21+
Currently, the tool supports adding training materials based on:
22+
23+
- CWE references (e.g., CWE-89)
24+
- Common vulnerability phrases (e.g., use-after-free vulnerability)
25+
26+
These are extracted from static analysis findings to provide relevant, actionable learning resources alongside detected vulnerabilities.
27+
28+
- **Flexible File Input:**
29+
Supports glob and wildcard patterns for input files, allowing batch processing of SARIF files in a directory, recursively, or by matching specific patterns.
30+
31+
- **Robust Output Handling:**
32+
Outputs processed SARIF results to specified filenames, with support for file overwriting and verification of output file patterns.
33+
34+
---
35+
36+
## Usage - GitHub Actions
837

938
### Individual SARIF file
1039

@@ -34,7 +63,6 @@ This Action currently supports adding training material based on CWE references
3463
with:
3564
inputSarifFile: sarif/findings.sarif
3665
outputSarifFile: sarif/findings.processed.sarif
37-
githubToken: ${{ secrets.GITHUB_TOKEN }}
3866

3967
- name: Import Results
4068
uses: github/codeql-action/upload-sarif@v3
@@ -60,7 +88,6 @@ This Action currently supports adding training material based on CWE references
6088
with:
6189
inputSarifFile: ./sarifs/*.json
6290
outputSarifFile: ./processed-sarifs
63-
githubToken: ${{ secrets.GITHUB_TOKEN }}
6491

6592
- name: Import Results
6693
uses: github/codeql-action/upload-sarif@v3
@@ -86,24 +113,51 @@ This Action currently supports adding training material based on CWE references
86113
with:
87114
inputSarifFile: ./sarifs
88115
outputSarifFile: ./processed-sarifs
89-
githubToken: ${{ secrets.GITHUB_TOKEN }}
90116

91117
- name: Import Results
92118
uses: github/codeql-action/upload-sarif@v3
93119
with:
94120
sarif_file: ./processed-sarifs
95121
```
96122
97-
## Inputs
123+
### Inputs
98124
99-
### `inputSarifFile`
125+
#### `inputSarifFile`
100126

101127
The SARIF file(s) to add Secure Code Warrior contextual training material to. This can be a path to a single file (e.g. `./findings.sarif`), a glob path (e.g. `./scans/**/*.sarif`) or a directory (d.g. `./scans`), in which case all `.sarif` files recursively in the specified directory will be processed. **Default value:** `./findings.sarif`
102128

103-
### `outputSarifFile`
129+
#### `outputSarifFile`
104130

105131
The output path of the resulting SARIF file(s) with Secure Code Warrior contextual training material appended. If a glob path or a directory was provided as the `inputSarifFile` input then the resulting SARIF files will be output to the `./processed-sarifs` directory, which can then simply be the path provided in the `sarif_file` input of the `github/codeql-action/upload-sarif` action. **Default value:** `./findings.processed.sarif`
106132

107-
### `githubToken` (optional)
133+
## Usage - Command line
134+
135+
This GitHub Action can also be run in CLI mode, to enable integration with other CI tools e.g. [Jenkins](https://www.jenkins.io/)
108136

109-
Provide `${{ secrets.GITHUB_TOKEN }}` to use the GitHub access token automatically supplied by GitHub Workflows. This enables language-specific training links to be generated (where available) by fetching the repository language from the GitHub API.
137+
### Syntax
138+
```bash
139+
node clilauncher.js <input-pattern> <output-file>
140+
```
141+
- input-pattern: Path to the SARIF file(s) you want to process. Supports:
142+
- Exact file path
143+
- Wildcard patterns (e.g., *.sarif)
144+
- Recursive globstars (e.g., **/*.sarif)
145+
- output-file: File path where the processed SARIF results will be saved.
146+
147+
**Important:**
148+
- Globstar and wildcard patterns should be enclosed in quotes to prevent the shell from expanding them prematurely.
149+
- If a globstar pattern is used, the default output dir will be `./processed-sarifs`. Otherwise, files will be output to the root directory.
150+
151+
### Examples
152+
153+
| Scenario | Command Example |
154+
|-----------------------------------|---------------------------------------------------------------------------------|
155+
| Process a single specific file | `node clilauncher.js ./sarifs/testInput.sarif findings.processed.sarif` |
156+
| Process all SARIF files in a folder| `node clilauncher.js './sarifs/*.sarif' findings.processed.sarif` |
157+
| Process all SARIF files recursively| `node clilauncher.js './sarifs/**/*.sarif' findings.processed.sarif` |
158+
| Process files with filename prefix | `node clilauncher.js './sarifs/test*.sarif' findings.processed.sarif` |
159+
| Process files with suffix | `node clilauncher.js './sarifs/*Input.sarif' findings.processed.sarif` |
160+
| Single-character wildcard match | `node clilauncher.js './sarifs/test?.sarif' findings.processed.sarif` |
161+
| Character set wildcard match | `node clilauncher.js './sarifs/test[0-9].sarif' findings.processed.sarif` |
162+
| Directory wildcard match | `node clilauncher.js './sarifs/*' findings.processed.sarif` |
163+
| Deep nested glob matching | `node clilauncher.js './sarifs/**/**/*.sarif' findings.processed.sarif` |

action.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ inputs:
1313
description: 'Relative destination location for processed SARIF file(s)'
1414
required: true
1515
default: './findings.processed.sarif'
16-
githubToken:
17-
description: 'Provide `secrets.GITHUB_TOKEN` to use the GitHub access token automatically supplied by GitHub Workflows'
18-
required: false
1916
runs:
2017
using: 'node20'
2118
main: 'dist/index.js'

0 commit comments

Comments
 (0)