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.
Equivalences
NOTEThis feature was deprecated in Semgrep v0.61.0.
$X + $Y <==> $Y + $X). Equivalence rules use the equivalences top-level key and one equivalence key for each equivalence.
For example:
Extract mode
DEPRECATION NOTICEAs of Semgrep 1.65.0, extract mode has been deprecated and removed from Semgrep. This feature may return in the future.
Example of extract mode
Without extract mode, writing rules to validate template, Markdown or configuration files which contain code in another language can be burdensome and require significant rule duplication. Let’s take the following Bash rule as an example (a simplified version of thecurl-eval rule from the Semgrep Registry):
RUN instruction or as an argument to Python’s os.system standard library function.
curl-eval rule.
curl-eval rule. See the following Dockerfile example that contains a Bash command:
Extract mode rule schema
Extract mode rules require the following usual Semgrep rule keys:idlanguages- One of
pattern,patterns,pattern-either, orpattern-regex
extractdest-language
reducejson
extract
The extract key is required in extract mode. The value must be a metavariable appearing in your pattern(s). Semgrep uses the code bound to the metavariable for subsequent queries of non-extract mode rules targeting dest-language.
dest-language
The dest-language key is required in extract mode. The value must be a language tag.
transform
The transform is an optional key in the extract mode. The value of this key specifies whether the extracted content is parsed as raw source code or as a JSON array.
The value of transform key must be one of the following:
no_transformExtract the matched content as raw source code. This is the default value.
concat_json_string_arrayExtract the matched content as a JSON array. Each element of the array correspond to a line the resulting source code. This value is useful in extracting code from JSON formats such as Jupyter Notebooks.
reduce
The reduce key is optional in extract mode. The value of this key specifies a method to combine the ranges extracted by a single rule within a file.
The value of reduce key must be one of the following:
separateTreat all matched ranges as separate units for subsequent queries. This is the default value.
concatConcatenate all matched ranges together and treat this result as a single unit for subsequent queries.
Limitations of extract mode
Although extract mode supports JSON array decoding with thejson key, it does not support other additional processing for the extracted text, such as unescaping strings.
While extract mode can help to enable rules which try and track taint across a language boundary within a file, taint rules cannot have a source and sink split across the original file and extracted text.
Turbo Mode
NOTEAs of June 16th, 2025, Turbo Mode has been deprecated and removed from the Semgrep Playground.