Skip to content

Commit 75b4b88

Browse files
chore: Add semgrep scan (#1179)
Add Semgrep scan for scanning docker related config. Later include docker related ruleset to the rules repo. <!-- description here --> ### Checklist - CI 🟢 <!-- Kubernetes and Docker Compose MUST be kept in sync. You should not merge a change here without a corresponding change in the other repository, unless it truly is specific to this repository. If uneeded, add link or explanation of why it is not needed here. * [ ] Sister [deploy-sourcegraph](https://github.com/sourcegraph/deploy-sourcegraph) change: * [ ] Sister [customer-replica](https://github.com/sourcegraph/deploy-sourcegraph-docker-customer-replica-1) change (if necessary, for any changes affecting pure-docker or configuration): * [ ] All images have a valid tag and SHA256 sum --> ### Test plan - CI for semgrep scan should scan actively for all pull request <!-- As part of SOC2/GN-104 and SOC2/GN-105 requirements, all pull requests are REQUIRED to provide a "test plan". A test plan is a loose explanation of what you have done or implemented to test this, as outlined in our Testing principles and guidelines: https://docs.sourcegraph.com/dev/background-information/testing_principles Write your test plan here after the "Test plan" header. -->
1 parent 686053e commit 75b4b88

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.github/workflows/semgrep.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Semgrep - SAST Scan
2+
3+
on:
4+
pull_request_target:
5+
types: [edited, opened, synchronize, ready_for_review]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
semgrep:
13+
permissions:
14+
contents: read # for actions/checkout to fetch code
15+
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
16+
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
17+
runs-on: ubuntu-latest
18+
container:
19+
image: semgrep/semgrep:1.104.0
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
ref: ${{ github.event.pull_request.head.ref }}
25+
repository: ${{ github.event.pull_request.head.repo.full_name }}
26+
27+
- name: Checkout semgrep-rules repo
28+
uses: actions/checkout@v4
29+
with:
30+
repository: sourcegraph/security-semgrep-rules
31+
token: ${{ secrets.GH_SEMGREP_SAST_TOKEN }}
32+
path: semgrep-rules
33+
34+
- name: Run Semgrep SAST Scan
35+
run: |
36+
mv semgrep-rules ../
37+
semgrep ci -f ../semgrep-rules/semgrep-rules/ --metrics=off --oss-only --suppress-errors --sarif -o results.sarif --exclude='semgrep-rules' --baseline-commit "$(git merge-base main HEAD)" || true
38+
- name: Upload SARIF file
39+
uses: github/codeql-action/upload-sarif@v3
40+
with:
41+
sarif_file: results.sarif

0 commit comments

Comments
 (0)