Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ rules:
<img width="600" alt="" src="https://github.com/user-attachments/assets/e918311f-94d8-4be0-86d8-cc6c30853740" />


## Testing Your Rules
## Writing Tests For Your Rules

Testing is a critical step in ensuring the quality and reliability of your rules. Follow these steps:

Expand All @@ -87,6 +87,16 @@ Testing is a critical step in ensuring the quality and reliability of your rules
./bin/test
```

## Testing Rules Against Local Repositories

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:

```bash
./bin/scan path/to/directory
```

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.

## Contribution Workflow

1. Create a new branch from the main branch for your changes.
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ This repository is home to the GitHub action workflow that will run perform a se
with:
# optional string parameter
paths_ignored: ...
```
```

For information on how to contribute rules to this repository, please see https://github.com/MetaMask/semgrep-action/blob/main/CONTRIBUTING.md.
10 changes: 10 additions & 0 deletions bin/scan
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# Run semgrep locally against a directory

if [ -z "$1" ]; then
echo "Usage: $0 <path/to/directory>"
exit 1
fi

# Run semgrep locally against the provided directory
semgrep --config rules/src/ "$1"
Loading