Skip to content

Commit a9af088

Browse files
committed
More updates
1 parent d7d8055 commit a9af088

File tree

10 files changed

+83
-467
lines changed

10 files changed

+83
-467
lines changed

README.md

Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,42 @@
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.
6+
The tool 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+
- **Finding Name Normalization:**
29+
If a finding’s tool driver name is exactly `"CodeQL"` (case-sensitive), the tool updates it to `"GitHub CodeQL"`. This addresses known issues related to CodeQL tool naming, particularly when integrated with GitHub workflows.
30+
31+
- **Flexible File Input:**
32+
Supports glob and wildcard patterns for input files, allowing batch processing of SARIF files in a directory, recursively, or by matching specific patterns.
33+
34+
- **Robust Output Handling:**
35+
Outputs processed SARIF results to specified filenames, with support for file overwriting and verification of output file patterns.
36+
37+
---
38+
39+
## Usage - Github Actions
840

941
### Individual SARIF file
1042

@@ -94,16 +126,45 @@ This Action currently supports adding training material based on CWE references
94126
sarif_file: ./processed-sarifs
95127
```
96128
97-
## Inputs
129+
### Inputs
98130
99-
### `inputSarifFile`
131+
#### `inputSarifFile`
100132

101133
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`
102134

103-
### `outputSarifFile`
135+
#### `outputSarifFile`
104136

105137
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`
106138

107-
### `githubToken` (optional)
139+
## Usage - Command line
140+
141+
This GitHub Action can also be run in CLI mode, to enable integration with other CI tools e.g. [Jenkins](https://www.jenkins.io/)
142+
143+
### Syntax
144+
```bash
145+
node clilauncher.js <input-pattern> <output-file>
146+
<input-pattern>: Path to the SARIF file(s) you want to process. Supports:
147+
148+
Exact file path
149+
Wildcard patterns (e.g., *.sarif)
150+
Recursive globstars (e.g., **/*.sarif)
151+
<output-file>: File path where the processed SARIF results will be saved.
152+
```
108153

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.
154+
- **Important:**
155+
- Globstar and wildcard patterns should be enclosed in quotes to prevent the shell from expanding them prematurely.
156+
- If a globstar pattern is used, the default output dir will be `./processed-sarifs`. Otherwise, files will be output to the root directory.
157+
158+
### Examples
159+
160+
| Scenario | Command Example |
161+
|-----------------------------------|---------------------------------------------------------------------------------|
162+
| Process a single specific file | `node clilauncher.js ./sarifs/testInput.sarif findings.processed.sarif` |
163+
| Process all SARIF files in a folder| `node clilauncher.js './sarifs/*.sarif' findings.processed.sarif` |
164+
| Process all SARIF files recursively| `node clilauncher.js './sarifs/**/*.sarif' findings.processed.sarif` |
165+
| Process files with filename prefix | `node clilauncher.js './sarifs/test*.sarif' findings.processed.sarif` |
166+
| Process files with suffix | `node clilauncher.js './sarifs/*Input.sarif' findings.processed.sarif` |
167+
| Single-character wildcard match | `node clilauncher.js './sarifs/test?.sarif' findings.processed.sarif` |
168+
| Character set wildcard match | `node clilauncher.js './sarifs/test[0-9].sarif' findings.processed.sarif` |
169+
| Directory wildcard match | `node clilauncher.js './sarifs/*' findings.processed.sarif` |
170+
| Deep nested glob matching | `node clilauncher.js './sarifs/**/**/*.sarif' findings.processed.sarif` |

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ inputs:
1717
description: 'Provide `secrets.GITHUB_TOKEN` to use the GitHub access token automatically supplied by GitHub Workflows'
1818
required: false
1919
runs:
20-
using: 'node22'
20+
using: 'node20'
2121
main: 'dist/index.js'

dist/index.js

Lines changed: 1 addition & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,7 @@ async function start() {
1212
logger.setLogger((msg) => core.debug(msg));
1313
const onFailure = (message) => core.setFailed(message);
1414

15-
// check if token provided and get language
16-
// const githubToken = core.getInput('githubToken');
17-
let languageKey = null;
18-
// if (githubToken) {
19-
// languageKey = await languageResolver.getLanguageFromRepo(githubToken);
20-
// logger.debug(`Repository language: ${languageKey}`);
21-
// }
22-
23-
run(inFile, outFile, languageKey, onFailure);
15+
run(inFile, outFile, null, onFailure);
2416
}
2517

2618
start();

languageResolver.js

Lines changed: 0 additions & 67 deletions
This file was deleted.

languageResolver.test.js

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)