NOTEOnly Semgrep Code and Secrets rules can be forked.
Fork a rule
One way to create new rules is to fork an existing rule in the Semgrep Registry and modify it to meet your software and business requirements. For example, Semgrep’s Javacrypto ruleset prohibits the use of weak hashing algorithms SHA-1 and MD5. However, your organization also prohibits the use of other hash functions as part of its standards or security compliance. The following steps illustrate the process of forking an existing use-of-sha1 rule and changing it to forbid MD2 hashes.
1
In the Library search box, enter
use-of-sha. The Library lists the rules whose name or path matches. Each result shows the rule’s folder under its name, such as java.lang.security.audit.crypto, and highlights the matching text.2
Click the use-of-sha1 rule in the
java.lang.security.audit.crypto folder to load it. You can’t edit Registry rules directly, so click Fork to make a copy.Alternatively, hover over the rule in the Library and click Fork rule, or right-click the rule and select Fork rule.3
Semgrep copies the rule to your organization’s set of rules.
4
Edit the rule.
5
Update your test cases.
6
Click Run to test and validate your rule.
7
When you finish your changes, click Save.
SHA-1 and MD5, has been modified to find uses of MD2 and the severity of such findings is increased from WARNING to ERROR.