Skip to content

Commit 3e845e3

Browse files
Merge pull request #6 from MetaMask/ellul/semgrep-local
Add binary to assist in local semgrep scanning
2 parents 2d41c78 + 5308867 commit 3e845e3

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

CONTRIBUTING.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ rules:
6565
<img width="600" alt="" src="https://github.com/user-attachments/assets/e918311f-94d8-4be0-86d8-cc6c30853740" />
6666
6767
68-
## Testing Your Rules
68+
## Writing Tests For Your Rules
6969
7070
Testing is a critical step in ensuring the quality and reliability of your rules. Follow these steps:
7171
@@ -87,6 +87,16 @@ Testing is a critical step in ensuring the quality and reliability of your rules
8787
./bin/test
8888
```
8989
90+
## Testing Rules Against Local Repositories
91+
92+
If you would like to test your rules against a local folder or directory on your machine, you can run the following command to perform a local scan:
93+
94+
```bash
95+
./bin/scan path/to/directory
96+
```
97+
98+
Note that Semgrep will scan _all_ files within the specified directory. In other words, if the directory contains multiple repositories, all of them will be scanned at once.
99+
90100
## Contribution Workflow
91101

92102
1. Create a new branch from the main branch for your changes.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ This repository is home to the GitHub action workflow that will run perform a se
1111
with:
1212
# optional string parameter
1313
paths_ignored: ...
14-
```
14+
```
15+
16+
For information on how to contribute rules to this repository, please see https://github.com/MetaMask/semgrep-action/blob/main/CONTRIBUTING.md.

bin/scan

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
# Run semgrep locally against a directory
3+
4+
if [ -z "$1" ]; then
5+
echo "Usage: $0 <path/to/directory>"
6+
exit 1
7+
fi
8+
9+
# Run semgrep locally against the provided directory
10+
semgrep --config rules/src/ "$1"

0 commit comments

Comments
 (0)