a template repo for semgrep rules and semgrep performance.
This guide assumes you are familiar with Semgrep and have it already installed.
- Test out this template repo with the following command:
git clone https://github.com/semgrep/template-rules.git
To test out the rules template, run:
semgrep --config template-rules/rules template-rules/rules/hello-world.py
To test out the benchmarking scripts in semgrep/perf
, run:
cd semgrep/perf
make
or refer to https://github.com/returntocorp/semgrep/tree/develop/perf.
- Copy this template to your own repo.
These configurations are Github Action scripts that you can run in CI. You can find them in perf-templates
.
benchmark-tests.yml
benchmark-tests.yml
is a YAML file that runs the timing benchmark with source code in perf.
The Run Timing Benchmark With Latest Semgrep Version
action runs the benchmark script with the following flags:
--small-only
: runs the script on small benchmarking repositories only, as compared to medium-sized or large-sized repositories.--std-only
: runs semgrep with no optimization flags.--output-time-per-rule-json
: outputs a JSON file that states the total time taken per rule per repository and the average time taken per rule.
The Run Timing Benchmark With Specified Config File
action runs the benchmark script with the additional flag:
--config
: runs the benchmarking script using the repositories and rules specified in a YAML config file.
config-template.yml
config-template.yml
is a YAML file that lets the user specify which repositories and rules to run the benchmarking scripts on. Feeding this file into the --config
flag for the run-benchmarks
script in the semgrep/perf
folder.
- Copy the desired configuration files into your
.github/workflows
folder. - Change these configuration templates as needed.
- Create a pull request with these changes and see if the appropriate tests are running in your Github Actions!
- Add your rules (and their test files) to the
rules
folder - Iterate rules and ensure they pass the built-in tests
- Open a PR to the Awesome Semgrep list
- Ask for help in the Semgrep community slack any time 👋