Write rules using Semgrep Editor
Semgrep Editor allows you to write rules, verify their performance through tests, and add them to your organization’s Policies page to enforce code standards and increase code security.
The Editor is free to use on all subscription tiers.
Access Semgrep Editor
- Sign in to your Semgrep AppSec Platform account.
- Click Rules > Editor.
- Do any of the following steps:
- To create a new rule, click on the (+) plus sign or Create new rule button.
- To open any rule you’ve recently edited, select it from the Recent list.
- To view a sample rule, select it from the Examples list. The rule renders within the Editor.
- To start a tutorial or read the docs, select it from the Learn list. This navigates you away from the Editor.
View a rule
Semgrep Editor is composed of three panes and a top menu.
- Library
- View and open rules owned by your organization or available through the Semgrep Registry.
- Rule editor
- Enter your rule's YAML in this pane. This pane supports both structure and advanced modes. This pane also contains metadata editing functionality in Structure mode, and match review functionality in Advanced mode.
- Sample code
- Enter test code in this pane and click Run to verify that the rule performs as intended. A matches panel appears after Semgrep runs to display matches and tests.
- Top menu
- Save, share, and add your rule to one of your policies.
Group Registry rules
By default, Semgrep Registry rules are grouped by directory. Most of these directories correspond to languages. The Library can also be grouped by rulesets, which are rules sorted by category, such as security, best practices, and frameworks.
To group by ruleset, right-click on the empty space on the registry's name entry and select Group by ruleset.