You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/contributing/contributing-rules.md
+28-20
Original file line number
Diff line number
Diff line change
@@ -2,29 +2,30 @@
2
2
slug: contributing-to-semgrep-rules-repository
3
3
description: "This article outlines how to contribute to Semgrep Registry."
4
4
hide_title: true
5
+
title: Contribute rules to the Semgrep Registry
5
6
toc_max_heading_level: 4
6
7
---
7
8
8
9
import LinkToRegistryRule from "/src/components/LinkToRegistryRule"
9
-
10
10
import RequiredRuleFields from "/src/components/reference/_required-rule-fields.mdx"
11
11
12
-
# Contributing rules
12
+
# Contribute rules to the Semgrep Registry
13
13
14
-
Publish rules in the open source Semgrep Registry and share them with the Semgrep community to help others benefit from your rule-writing efforts and contribute to the field of software security. There are two ways in which you can contribute rules to the Semgrep Registry:
14
+
Publish rules to the Semgrep Registry to share them with the Semgrep community and contribute to the field of software security. There are two ways in which you can contribute rules to the Semgrep Registry:
15
15
16
16
<dl>
17
17
<dt>For users of Semgrep AppSec Platform</dt>
18
-
<dd>Contribute rules to the Semgrep Registry through Semgrep AppSec Platform. This workflow is recommended. See <a href="#contributing-through-semgrep-appsec-platform-recommended"> Contributing through Semgrep AppSec Platform (recommended)</a>. This workflow creates the necessary pull request for you and streamlines the whole process.</dd>
18
+
<dd>Contribute new rules to the Semgrep Registry through Semgrep AppSec Platform. This workflow is recommended. See <a href="#contribute-through-semgrep-appsec-platform-recommended"> Contribute through Semgrep AppSec Platform (recommended)</a>. This workflow creates the necessary pull request for you and streamlines the whole process.</dd>
19
19
<dt>For contributors to the repository through GitHub</dt>
20
-
<dd>Contribute rules to the Semgrep Registrythrough a pull request. See the <a href="#contributing-through-github"> Contributing through GitHub</a> section for detailed information.</dd>
20
+
<dd>Contribute rules to the Semgrep Registry, or suggest changes to existing rules, through a pull request to `semgrep-rules`. See the <a href="#contribute-through-github"> Contribute through GitHub</a> section for detailed information.</dd>
21
21
</dl>
22
22
23
-
## Contributing through Semgrep AppSec Platform (recommended)
23
+
## Contribute through Semgrep AppSec Platform (recommended)
24
24
25
-
To contribute and publish rules to the Semgrep Registry through Semgrep AppSec Platform, follow these steps:
25
+
This is the recommended path for adding a new rule. To suggest a change to an existing rule, see [Update existing rules in Semgrep Registry](#update-existing-rules-in-semgrep-registry).
26
26
27
-
1. Go to [Playground](https://semgrep.dev/playground/new).
27
+
1. Sign in to [<iclass="fas fa-external-link fa-xs"></i> Semgrep AppSec Platform](https://semgrep.dev/login).
28
+
1. Go to the [<iclass="fas fa-external-link fa-xs"></i> Semgrep Playground](https://semgrep.dev/playground/new).
28
29
1. Click <iclassName="fa-solid fa-file-plus-minus inline_svg"></i> **Create New Rule**.
29
30
1. Choose one of the following:
30
31
- Create a new rule and test code by clicking <iclass="fa-solid fa-circle-plus"></i> **plus** icon, select **New rule** and then click <iclassName="fa-solid fa-floppy-disk inline_svg"></i> **Save**. Note: The test file must contain at least one true positive and one true negative test case to be approved. See the [Tests](#tests) section of this document for more information.
@@ -34,21 +35,30 @@ To contribute and publish rules to the Semgrep Registry through Semgrep AppSec P
34
35
1. Fill in the required and optional fields.
35
36
1. Click <iclassName="fa-solid fa-circle-check inline_svg"></i> **Continue**, and then click <iclassName="fa-solid fa-code-pull-request inline_svg"></i> **Create PR**.
36
37
37
-
This workflow automatically creates a pull request in the GitHub [Semgrep Registry](https://github.com/semgrep/semgrep-rules). Find more about the Semgrep Registry by reading the [Rule writing](#writing-a-rule-for-semgrep-registry) and [Tests](#tests) sections.
38
+
This workflow automatically creates a pull request in the GitHub [Semgrep Registry](https://github.com/semgrep/semgrep-rules). Find more about the Semgrep Registry by reading the [Rule writing](#write-a-rule-for-semgrep-registry) and [Tests](#tests) sections.
38
39
39
40
You can also publish rules as private rules outside of Semgrep Registry. These rules are not included in the Semgrep Registry, but they are accessible to your Semgrep organisation. See the [Private rules](/writing-rules/private-rules) documentation for more information.
40
41
41
-
## Contributing through GitHub
42
+
## Contribute through GitHub
42
43
43
-
Fork our repository and make a pull request. Sign our Contributor License Agreement (CLA) on GitHub before Semgrep, Inc. can accept your contributions. Make a pull request to the [Semgrep Registry](https://github.com/semgrep/semgrep-rules) with two files:
44
-
1. The semgrep pattern (as YAML file).
45
-
2. The test file (with the file extension of the language or framework). The test file must contain at least one true positive and one true negative test case to be approved. See the [Tests](#tests) section of this document for more information.
44
+
1. Create a pull request in the [<iclass="fas fa-external-link fa-xs"></i> semgrep/semgrep-rules](https://github.com/semgrep/semgrep-rules) repository. The pull request requires two files:
45
+
- The Semgrep rule saved as a YAML file.
46
+
- The test file with the file extension of the language or framework. The test file must contain at least one true positive and one true negative test case to be approved. See the [Tests](#tests) section of this document for more information.
47
+
1. Sign the Contributor License Agreement (CLA) on GitHub; this is required before Semgrep can accept your contributions.
46
48
47
49
Pull requests require the approval of at least one maintainer and successfully passed [CI jobs](https://github.com/semgrep/semgrep-rules/actions).
48
50
49
-
Find more about the Semgrep Registry by reading the [Rule writing](#writing-a-rule-for-semgrep-registry) and [Tests](#tests) sections.
51
+
Find more about the Semgrep Registry by reading the [Rule writing](#write-a-rule-for-semgrep-registry) and [Tests](#tests) sections.
52
+
53
+
## Licensing
54
+
55
+
The Semgrep Registry can import rules from different repositories. These repositories can enforce their own licensing for rules. If you'd like to enforce a specific license, such as the MIT license or GNU Lesser GPL:
50
56
51
-
## Writing a rule for Semgrep Registry
57
+
1. Create a GitHub repository and store your rules there.
58
+
1. Reach out to the Semgrep team through the [<iclass="fas fa-external-link fa-xs"></i> Community Slack](https://go.semgrep.dev/slack) or [Support](/support)
59
+
60
+
61
+
## Write a rule for Semgrep Registry
52
62
53
63
The following sections document necessary fields in rule files of Semgrep Registry, provide information about rule messages, inform about test files, mention rule quality checkers, and describe additional fields required by rules in the security category.
54
64
@@ -175,7 +185,7 @@ In addition to the fields mentioned above, rules submitted to Semgrep Registry h
175
185
- Cross-file (interfile) analysis requires `interfile: true` under the `options` key in YAML rules. For more information, see [Creating rules that analyze across files](/semgrep-code/semgrep-pro-engine-intro/#write-rules-that-analyze-across-files-and-functions).
176
186
:::
177
187
178
-
### Understanding rule namespacing
188
+
### Rule namespace
179
189
180
190
The namespacing format for contributing rules in the [Semgrep Registry](https://github.com/semgrep/semgrep-rules) is `<language>/<framework>/<category>/$MORE`. If the rule does not belong to a particular framework, add it to the language directory, which uses the word `lang` in place of the `<framework>` - `<language>/<lang>`.
181
191
@@ -235,7 +245,7 @@ For an example of a good rule message, see: [this rule for Django's `mark_safe`]
235
245
236
246
When you contribute rules to the Semgrep Registry, our quality checkers (linters) evaluate if the rule conforms to Semgrep, Inc. standards. The `semgrep-rule-lints` job runs linters on a new rule to check for mistakes, performance problems, and best practices for submitting to the Semgrep Registry. To improve your rule writing, use Semgrep itself to [scan semgrep-rules](https://semgrep.dev/blog/2021/how-we-made-semgrep-rules-run-on-semgrep-rules/).
237
247
238
-
### Including fields required by security category
248
+
### Fields required by the `security` category
239
249
240
250
Rules in category `security` in the Semgrep Registry require specific metadata fields that ensure consistency across the ecosystem in both Semgrep AppSec Platform and Semgrep CLI. Nest these metadata under the `metadata` field.
241
251
@@ -542,9 +552,7 @@ You can provide custom values. Sample values include:
542
552
- XML Injection
543
553
- XPath Injection
544
554
545
-
## Updating existing open source rules in Semgrep Registry
546
-
547
-
To update an existing open source rule, follow these steps:
555
+
## Update existing rules in Semgrep Registry
548
556
549
557
1. Find a rule you want to update in the [semgrep-rules](https://github.com/semgrep/semgrep-rules/) repository.
550
558
2. Submit a PR to the repository with your new update.
Copy file name to clipboardexpand all lines: docs/contributing/philosophy.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ tags:
7
7
8
8
# Semgrep Community Edition (CE) philosophy
9
9
10
-
[Semgrep CE](https://semgrep.dev/) is a lightweight static analysis tool for many languages. It can find bug variants with patterns that look like source code.
10
+
[Semgrep CE](https://github.com/semgrep/semgrep/) is a lightweight static analysis tool for many languages. It can find bug variants with patterns that look like source code.
11
11
12
12
As you think about contributing to Semgrep CE, consider these design principles that have guided Semgrep CE development so far:
0 commit comments