Skip to content

Commit 9686dcc

Browse files
committed
✨ Add Semgrep OSS Example
1 parent 60cdb90 commit 9686dcc

File tree

3 files changed

+69
-5
lines changed

3 files changed

+69
-5
lines changed
119 KB
Loading

docs/code-scanning-tools/semgrep.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,70 @@ Pixee can automatically triage and fix issues detected by [Semgrep](https://semg
99

1010
# GitHub Advanced Security
1111

12-
No setup is required for GitHub Advanced Security (GHAS) users to receive fixes from Semgrep results that are uploaded as Code Scanning alerts.
12+
No setup is required for GitHub Advanced Security (GHAS) users to receive fixes from Semgrep results that are uploaded as Code Scanning alerts. Simply installing the Pixeebot GitHub App is sufficient.
1313

1414
# Others
1515

16-
Use the [pixee/upload-tool-results-action](https://github.com/pixee/upload-tool-results-action) GitHub Action to synchronize Semgrep findings with Pixee.
16+
Use the [pixee/upload-tool-results-action](https://github.com/pixee/upload-tool-results-action) GitHub Action together with the Pixeebot GitHub App to synchronize Semgrep findings with Pixee.
17+
18+
The following GitHub Action workflow example demonstrates how to include Semgrep vulnerability detection with Pixee fixes in a Java application:
19+
20+
```yaml
21+
name: Analyze with Semgrep and Fix with Pixee
22+
23+
on:
24+
push:
25+
branches:
26+
- main
27+
pull_request:
28+
branches:
29+
- main
30+
31+
permissions:
32+
contents: read
33+
id-token: write
34+
35+
jobs:
36+
build:
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v4
42+
43+
- name: Set up JDK 17
44+
uses: actions/setup-java@v4
45+
with:
46+
java-version: "17"
47+
distribution: "temurin"
48+
49+
- name: Build with Maven
50+
run: mvn --batch-mode verify
51+
52+
- name: Install Semgrep
53+
run: |
54+
python3 -m pip install semgrep
55+
56+
- name: Run Semgrep
57+
run: |
58+
semgrep --config auto --sarif --output webgoat-semgrep-results.sarif.json
59+
60+
- name: Fix with Pixee
61+
uses: pixee/upload-tool-results-action@v2
62+
with:
63+
tool: semgrep
64+
file: webgoat-semgrep-results.sarif.json
65+
```
66+
67+
This workflow:
68+
69+
1. Builds the Java project using Maven, to give Semgrep more context to find vulnerabilities.
70+
2. Runs semgrep OSS on the project and stores the results in a standard SARIF file.
71+
3. Runs the pixee/upload-tool-results-action that sends the SARIF file to Pixee.
72+
73+
Once Pixee receives the Semgrep vulnerabilities, it recalls them on its next analysis of this commit.
74+
75+
- When this commit the head of a pull request, then Pixee triggers its _PR Hardening_ analysis to fix as many Semgrep findings in this PR as it can.
76+
- When this commit is the head of the main branch, then Pixee uses these findings the next time its _Continuous Improvement Campaign_ analysis runs. Users may trigger such an analysis to occur immediately by issuing the chat command `@pixeebot next` in any PR or issue comment on this repository. Pixee's continuous improvement campaign shows the queue of fixes in Pixeebot Acitvity Dashboard issue.
77+
78+
![Pixeebot Activity Dashboard issue](./semgrep-issue-dashlist.png)

docs/installing.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ Also [contact us](https://pixee.ai/demo-landing-page) if you want to partner as
1919

2020
## Tool connections
2121

22-
Pixee fixes problems detected by [your existing code scanning tools and
23-
services](/code-scanning-tools/overview). Therefore, you will need to connect
24-
Pixee to your code scanning tools and services, before Pixee sends fixes.
22+
Pixee fixes problems detected by [your existing code scanning tools and services](/code-scanning-tools/overview).
23+
24+
If you use GitHub Advanced Security, then installing the Pixeebot GitHub App is sufficient for connecting Pixee to your GHAS results.
25+
26+
Otherwise, you will need to connect Pixee to your code scanning tools and services, before Pixee can send fixes. If your repository does not use any code scanning tools and services, but you still want to try Pixee, see our guide for [adding Semgrep CLI and Pixee to your GitHub repository](./code-scanning-tools/semgrep.md).
2527

2628
## Repository access
2729

0 commit comments

Comments
 (0)