Skip to content

Commit 521b069

Browse files
authored
Merge branch 'semgrep:main' into patch-1
2 parents 2696038 + 0f0fb43 commit 521b069

File tree

155 files changed

+4915
-1623
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+4915
-1623
lines changed

algolia-config.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@
5252
"coverage",
5353
"leverage",
5454
"teams",
55-
"terms"
55+
"terms",
56+
"IdP",
57+
"IDE"
5658
],
5759
"separatorsToIndex": "_",
5860
"attributesForFaceting": [
@@ -109,6 +111,10 @@
109111
[
110112
"Semgrep Supply Chain",
111113
"SSC"
114+
],
115+
[
116+
"Identity provider",
117+
"IdP"
112118
]
113119
]
114120
},

docs/contributing/adding-a-language.md

+110-122
Large diffs are not rendered by default.

docs/contributing/contributing-rules.md

+28-20
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,30 @@
22
slug: contributing-to-semgrep-rules-repository
33
description: "This article outlines how to contribute to Semgrep Registry."
44
hide_title: true
5+
title: Contribute rules to the Semgrep Registry
56
toc_max_heading_level: 4
67
---
78

89
import LinkToRegistryRule from "/src/components/LinkToRegistryRule"
9-
1010
import RequiredRuleFields from "/src/components/reference/_required-rule-fields.mdx"
1111

12-
# Contributing rules
12+
# Contribute rules to the Semgrep Registry
1313

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:
1515

1616
<dl>
1717
<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>
1919
<dt>For contributors to the repository through GitHub</dt>
20-
<dd>Contribute rules to the Semgrep Registry through 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>
2121
</dl>
2222

23-
## Contributing through Semgrep AppSec Platform (recommended)
23+
## Contribute through Semgrep AppSec Platform (recommended)
2424

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).
2626

27-
1. Go to [Playground](https://semgrep.dev/playground/new).
27+
1. Sign in to [<i class="fas fa-external-link fa-xs"></i> Semgrep AppSec Platform](https://semgrep.dev/login).
28+
1. Go to the [<i class="fas fa-external-link fa-xs"></i> Semgrep Playground](https://semgrep.dev/playground/new).
2829
1. Click <i className="fa-solid fa-file-plus-minus inline_svg"></i> **Create New Rule**.
2930
1. Choose one of the following:
3031
- Create a new rule and test code by clicking <i class="fa-solid fa-circle-plus"></i> **plus** icon, select **New rule** and then click <i className="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
3435
1. Fill in the required and optional fields.
3536
1. Click <i className="fa-solid fa-circle-check inline_svg"></i> **Continue**, and then click <i className="fa-solid fa-code-pull-request inline_svg"></i> **Create PR**.
3637

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.
3839

3940
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.
4041

41-
## Contributing through GitHub
42+
## Contribute through GitHub
4243

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 [<i class="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.
4648

4749
Pull requests require the approval of at least one maintainer and successfully passed [CI jobs](https://github.com/semgrep/semgrep-rules/actions).
4850

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:
5056

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 [<i class="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
5262

5363
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.
5464

@@ -175,7 +185,7 @@ In addition to the fields mentioned above, rules submitted to Semgrep Registry h
175185
- 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).
176186
:::
177187

178-
### Understanding rule namespacing
188+
### Rule namespace
179189

180190
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>`.
181191

@@ -235,7 +245,7 @@ For an example of a good rule message, see: [this rule for Django's `mark_safe`]
235245

236246
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/).
237247

238-
### Including fields required by security category
248+
### Fields required by the `security` category
239249

240250
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.
241251

@@ -542,9 +552,7 @@ You can provide custom values. Sample values include:
542552
- XML Injection
543553
- XPath Injection
544554

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
548556

549557
1. Find a rule you want to update in the [semgrep-rules](https://github.com/semgrep/semgrep-rules/) repository.
550558
2. Submit a PR to the repository with your new update.

docs/contributing/philosophy.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ tags:
77

88
# Semgrep Community Edition (CE) philosophy
99

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.
1111

1212
As you think about contributing to Semgrep CE, consider these design principles that have guided Semgrep CE development so far:
1313

docs/contributing/semgrep-core-contributing.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ The following explains how to build `semgrep-core` so you can make and test chan
1111
```bash
1212
brew install opam
1313
opam init
14-
opam switch create 4.14.0 ocaml-base-compiler.4.14.0
15-
opam switch 4.14.0
14+
opam switch create semgrep 5.2.1
1615
eval $(opam env)
1716
```
1817

0 commit comments

Comments
 (0)