Skip to content

Commit 7748720

Browse files
authored
Merge pull request #31 from SecureCodeWarrior/master
Added directory and glob support
2 parents b9e854b + 92e668a commit 7748720

17 files changed

Lines changed: 4754 additions & 689 deletions

README.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ This Action currently supports adding training material based on CWE references
66

77
## Usage
88

9+
### Individual SARIF file
10+
911
```yaml
1012
steps:
1113
# Fetch SARIF - for example:
@@ -40,15 +42,67 @@ This Action currently supports adding training material based on CWE references
4042
sarif_file: sarif/findings.processed.sarif
4143
```
4244
45+
### Multiple SARIF files using glob path
46+
47+
```yaml
48+
steps:
49+
# Fetch SARIF - see additional examples above
50+
- name: Download SARIF
51+
uses: vendor/sast-tool-sarif@v1
52+
with:
53+
user: ${{ secrets.USER }}
54+
key: ${{ secrets.KEY }}
55+
scan-id: ${{ secrets.SCAN_ID }}
56+
output-dir: ./sarifs # in this example we assume the tool outputs multiple SARIF files as .json files
57+
58+
- name: Add SCW Training
59+
uses: SecureCodeWarrior/github-action-add-sarif-contextual-training@v1
60+
with:
61+
inputSarifFile: ./sarifs/*.json
62+
outputSarifFile: ./processed-sarifs
63+
githubToken: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Import Results
66+
uses: github/codeql-action/upload-sarif@v1
67+
with:
68+
sarif_file: ./processed-sarifs
69+
```
70+
71+
### Multiple SARIF files in directory
72+
73+
```yaml
74+
steps:
75+
# Fetch SARIF - see additional examples above
76+
- name: Download SARIF
77+
uses: vendor/sast-tool-sarif@v1
78+
with:
79+
user: ${{ secrets.USER }}
80+
key: ${{ secrets.KEY }}
81+
scan-id: ${{ secrets.SCAN_ID }}
82+
output-dir: ./sarifs # in this example we assume the tool outputs multiple SARIF files in nested directories within the specified output directory
83+
84+
- name: Add SCW Training
85+
uses: SecureCodeWarrior/github-action-add-sarif-contextual-training@v1
86+
with:
87+
inputSarifFile: ./sarifs
88+
outputSarifFile: ./processed-sarifs
89+
githubToken: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- name: Import Results
92+
uses: github/codeql-action/upload-sarif@v1
93+
with:
94+
sarif_file: ./processed-sarifs
95+
```
96+
4397
## Inputs
4498
4599
### `inputSarifFile`
46100

47-
The SARIF file to add Secure Code Warrior contextual training material to. **Default value:** `./findings.sarif`
101+
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`
48102

49103
### `outputSarifFile`
50104

51-
The SARIF file to add Secure Code Warrior contextual training material to. **Default value:** `./findings.processed.sarif`
105+
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`
52106

53107
### `githubToken` (optional)
54108

action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
name: 'Add Secure Code Warrior contextual training to SARIF'
2-
description: 'GitHub Action for adding contextual application security training material to SARIF files based on CWE references'
2+
description: 'Adds contextual application security training material to SARIF files, providing links to secure coding exercises and short explainer videos'
33
author: 'SecureCodeWarrior'
44
branding:
55
icon: 'shield'
66
color: 'orange'
77
inputs:
88
inputSarifFile:
9-
description: 'Relative location of SARIF file to process'
9+
description: 'Relative location of SARIF file(s) to process'
1010
required: true
1111
default: './findings.sarif'
1212
outputSarifFile:
13-
description: 'Relative destination location for processed SARIF file'
13+
description: 'Relative destination location for processed SARIF file(s)'
1414
required: true
1515
default: './findings.processed.sarif'
1616
githubToken:

0 commit comments

Comments
 (0)