Skip to content

Commit 5cb5c86

Browse files
galbwemergify[bot]
authored andcommitted
ci: add github workflow to lint files using semgrep
1 parent 828ca4e commit 5cb5c86

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

.github/workflows/semgrep.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Semgrep
2+
3+
# Semgrep is a static analysis tool to lint code for patterns we want to forbid
4+
# https://github.com/returntocorp/semgrep
5+
6+
permissions:
7+
contents: read
8+
9+
on: [workflow_dispatch, pull_request, push]
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
lint:
17+
name: Semgrep - Lint
18+
runs-on: ubuntu-20.04
19+
container:
20+
image: returntocorp/semgrep
21+
steps:
22+
- name: Check out ockam repository
23+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
24+
- name: Run Semgrep
25+
# .semgrepignore is not processed outside of working directory. See https://github.com/returntocorp/semgrep/issues/5669
26+
run: |
27+
mv tools/semgrep/.semgrepignore . & \
28+
semgrep --verbose --config="r2c" --config="tools/semgrep/rules/example.yaml"

tools/semgrep/.semgrepignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.gitignore

tools/semgrep/rules/example.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
rules:
2+
- id: is-comparison
3+
languages:
4+
- python
5+
message: The operator 'is' is for reference equality, not value equality! Use `==` instead!
6+
pattern: $SOMEVAR is "..."
7+
severity: ERROR

0 commit comments

Comments
 (0)