|
1 | | -# GitHub Action |
| 1 | +# Secure Code Warrior SARIF Processing Tool |
2 | 2 |
|
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 |
4 | 4 |
|
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. |
6 | 9 |
|
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 |
8 | 40 |
|
9 | 41 | ### Individual SARIF file |
10 | 42 |
|
@@ -94,16 +126,45 @@ This Action currently supports adding training material based on CWE references |
94 | 126 | sarif_file: ./processed-sarifs |
95 | 127 | ``` |
96 | 128 |
|
97 | | -## Inputs |
| 129 | +### Inputs |
98 | 130 |
|
99 | | -### `inputSarifFile` |
| 131 | +#### `inputSarifFile` |
100 | 132 |
|
101 | 133 | 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` |
102 | 134 |
|
103 | | -### `outputSarifFile` |
| 135 | +#### `outputSarifFile` |
104 | 136 |
|
105 | 137 | 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` |
106 | 138 |
|
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 | +``` |
108 | 153 |
|
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` | |
0 commit comments