Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.semgrep.dev/llms.txt

Use this file to discover all available pages before exploring further.

Prerequisites

General steps

1
Create a custom Semgrep rule.
2
Verify and test that the rule matches the code you want to detect.
3
Optional: Set the custom Semgrep rule as a secure default.
4
Deploy the rule as a guardrail in the following developer interfaces: IDE, PR or MR comments, or pre-commit.
The following table lists the relevant documentation for each step:
StepsReferences and notes
Create a custom ruleIn addition to the required fields of a Semgrep rule, the following metadata fields are useful:
  • category
  • confidence
  • likelihood
  • impact
  • subcategory
Filling out confidence and impact in particular is useful for filtering rules within the Semgrep web app.

Read the metadata reference documentation.
Verify that the rule matches as intended
Optional: Set the rule as a secure defaultWhen creating a custom secure default, you must use category: security and subcategory: secure default values in your rule (see Secure default snippet).
Deploy the rule as a guardrailFor PR or MR comments:

For IDEs: Require developers to install the Semgrep extension for their IDE.

For pre-commit: Install and configure Semgrep for pre-commit.

Secure default snippet

When creating a custom secure default, you must use category: security and subcategory: secure default values in your rule:
rules:
  - id: some-custom-default
    ...
    metadata:
      category: security
      subcategory:
        - secure default
    ...