Skip to main content

20 docs tagged with "Rule writing"

View all tags

Autofix

Autofix is a Semgrep feature where rules contain suggested fixes to resolve findings.

Constant propagation

Semgrep performs flow-sensitive constant folding and this information is used by the matching engine.

Custom rule examples

Not sure what to write a rule for? Below are some common questions, ideas, and topics to spur your imagination. Happy hacking! đź’ˇ

Generic pattern matching

Semgrep can match generic patterns in languages that it doesn’t support yet. You can use generic pattern matching for languages that do **not** have a parser, configuration files, or other structured data such as XML.

Metavariable analysis

metavariable-analysis allows Semgrep users to check metavariables for common problematic properties, such as RegEx denial of service (ReDoS) and high-entropy values.

Overview

Learn how to use Semgrep’s intuitive syntax to write rules specific to your codebase. You can write and share rules directly from your browser using the Semgrep Playground, or write rules in your terminal and run them on the command line.

Pattern examples

This section is automatically generated from the unit test suite inside Semgrep. Per-language references are also available within the Playground.

Pattern syntax

Learn Semgrep's pattern syntax to search code for a given code pattern. If you're just getting started writing Semgrep rules, check out the Semgrep Tutorial at https://semgrep.dev/learn

Private rules

Semgrep Code users can publish rules to the Semgrep Registry that are not visible to others outside their organization. This can be useful for organizations where rules may contain code-sensitive information or legal requirements prevent using a public registry.

Rule syntax

This document describes the YAML rule syntax of Semgrep including required and optional fields. Just getting started with Semgrep rule writing? Check out the Semgrep Tutorial at https://semgrep.dev/learn

Semantic detection in Java

Proprietary Semgrep features for the Java language that can increase true positives and reduce false positives.

Semgrep trophy case

This is a list of vulnerabilities found and security fixes made with Semgrep.

Taint analysis

Taint mode allows you to write simple rules that catch complex injection bugs thanks to taint analysis.

Testing rules

Semgrep provides a convenient testing mechanism for your rules. You can simply write code and provide a few annotations to let Semgrep know where you are or aren't expecting findings.

Troubleshooting rules

Follow these troubleshooting steps when your pattern fails to parse, your rule doesn't match its intended code, and other rule writing pitfalls.