Skip to content

Commit 70c93cc

Browse files
committed
feat(docs): Add SARIF integration instructions
Closes #45
1 parent 4d73e04 commit 70c93cc

2 files changed

Lines changed: 86 additions & 1 deletion

File tree

docs/tutorial/ci-cd.md

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ It could be located at e.g., `.github/workflows/ci.yml`.
1616

1717
**3. Add the step to run Misti to your YAML file**
1818

19-
For example:
19+
<details>
20+
<summary>Example GitHub Actions configuration</summary>
2021

2122
```yaml
2223
name: CI
@@ -60,6 +61,8 @@ jobs:
6061
run: yarn misti --min-severity medium /path/to/your/tact.config.json
6162
```
6263
64+
</details>
65+
6366
The `yarn misti --min-severity medium /path/to/your/tact.config.json` command will run Misti against your project. If Misti detects any issues that are not suppressed by your configuration, it will return a non-zero exit code, causing the CI pipeline to fail.
6467

6568
The `--min-severity medium` will filter out low-priority warnings. You can always run Misti with all the detectors enabled locally in order to get the most comprehensive warnings output: `yarn misti --all-detectors /path/to/your/tact.config.json`
@@ -68,6 +71,88 @@ The `--min-severity medium` will filter out low-priority warnings. You can alway
6871

6972
If you find that Misti is too noisy (e.g., detecting issues that are not relevant to your project), you can adjust your Misti configuration file to suppress those warnings. Refer to the [Configuration](./configuration) section for more details on how to customize your settings.
7073

74+
### Using SARIF and GitHub Actions
75+
Additionally, it is possible to integrate Misti with GitHub Actions code scanning using the SARIF output format. After this, the issues found by Misti will be shown in the PR like this:
76+
77+
![CFG Example](/img/misti-sarif.png)
78+
79+
To implement this, adjust the previous GitHub Actions with the following:
80+
1. Add `--output-format sarif` and `-O /tmp/misti` to the Misti execution command
81+
2. Add the following commands at the top of your file:
82+
```yaml
83+
permissions:
84+
security-events: write
85+
actions: read
86+
contents: read
87+
```
88+
3. Add the following action after executing Misti:
89+
```yaml
90+
- name: Upload SARIF results
91+
uses: github/codeql-action/upload-sarif@v3
92+
with:
93+
sarif_file: /tmp/misti/warnings.sarif
94+
category: misti-security-analysis
95+
```
96+
97+
<details>
98+
<summary>Updated GitHub Actions configuration</summary>
99+
100+
```yaml
101+
name: CI
102+
103+
permissions:
104+
security-events: write
105+
actions: read
106+
contents: read
107+
108+
on:
109+
push:
110+
branches: [ "main" ]
111+
pull_request:
112+
branches: [ "main" ]
113+
workflow_dispatch:
114+
115+
jobs:
116+
test:
117+
strategy:
118+
fail-fast: false
119+
matrix:
120+
node-version: [22]
121+
os: [ubuntu-latest]
122+
runs-on: ${{ matrix.os }}
123+
steps:
124+
- name: Checkout code
125+
uses: actions/checkout@v2
126+
127+
- name: Install Soufflé on Ubuntu
128+
if: matrix.os == 'ubuntu-latest'
129+
run: |
130+
sudo wget https://souffle-lang.github.io/ppa/souffle-key.public -O /usr/share/keyrings/souffle-archive-keyring.gpg
131+
echo "deb [signed-by=/usr/share/keyrings/souffle-archive-keyring.gpg] https://souffle-lang.github.io/ppa/ubuntu/ stable main" | sudo tee /etc/apt/sources.list.d/souffle.list
132+
sudo apt update
133+
sudo apt install souffle
134+
135+
- name: Setup Node.js
136+
uses: actions/setup-node@v3
137+
with:
138+
node-version: ${{ matrix.node-version }}
139+
140+
- name: Install dependencies
141+
run: yarn install
142+
143+
- name: Run Misti
144+
run: yarn misti --min-severity medium -o sarif -O /tmp/misti /path/to/your/tact.config.json
145+
146+
- name: Upload SARIF results
147+
uses: github/codeql-action/upload-sarif@v3
148+
if: always() && hashFiles('/tmp/misti/warnings.sarif') != ''
149+
with:
150+
sarif_file: /tmp/misti/warnings.sarif
151+
category: misti-security-analysis
152+
```
153+
154+
</details>
155+
71156
## Integration with Blueprint Projects
72157
To add Misti to the CI for your Blueprint project, follow these steps:
73158
1. [Install `blueprint-misti`](./blueprint.md).

static/img/misti-sarif.png

66.5 KB
Loading

0 commit comments

Comments
 (0)