Skip to content

Commit 615062d

Browse files
committed
resolve merge conflicts
2 parents 68d254a + 58eb0de commit 615062d

File tree

118 files changed

+1600
-764
lines changed

Some content is hidden

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

118 files changed

+1600
-764
lines changed

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/deployment/connect-scm.md

+37-19
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ tags:
1111

1212
import Tabs from '@theme/Tabs';
1313
import TabItem from '@theme/TabItem';
14+
import PL from '@site/src/components/Placeholder';
1415

1516
# Connect a source code manager
1617

@@ -52,11 +53,11 @@ If you opted to scan a GitHub or GitLab repository when you initially signed in,
5253
1. Optional: If you have created more than one Semgrep account, select the account you want to make a connection for by clicking on the **Navigation bar > Your account name > The account you want to connect**.<br />
5354
<img src="/docs/img/more-accounts-dropdown.png" height="350px" />
5455
1. Go to **<i class="fa-solid fa-gear"></i> Settings > Source code managers > Add > Azure DevOps**.
55-
1. In the **Connect your Azure DevOps organization** dialog box, provide:
56-
- The **Name of your Azure DevOps organization**
56+
1. In the **Connect your Azure DevOps Project** dialog box, provide:
57+
- The **Name of your Azure DevOps Project**. Ensure that the value you provide follows the format <PL>organization</PL>/<PL>project</PL>. This information can be seen in the project URL, for example `https://dev.azure.com/organization/project`.
5758
- Your **Access token**. See [User personal access tokens](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate) for information on generating a token.
5859
2. Click **Connect** to save and proceed.
59-
3. The Azure DevOps organization is now listed under **Source Code managers**. Click **Test** to verify that the new integration is installed correctly.
60+
3. The Azure DevOps project is now listed under **Source code managers**. Click **Test** to verify that the new connection is installed correctly.
6061

6162
</TabItem>
6263
<TabItem value='bitbucket-cloud'>
@@ -67,34 +68,46 @@ If you opted to scan a GitHub or GitLab repository when you initially signed in,
6768
1. Go to **<i class="fa-solid fa-gear"></i> Settings > Source code managers > Add > Bitbucket Cloud**.
6869
1. In the **Connect your Bitbucket Workspace** dialog box, provide:
6970
- The **Name of your Bitbucket Workspace**
70-
- Your **Access token**. Semgrep expects a [workspace-level access token](https://support.atlassian.com/bitbucket-cloud/docs/create-a-workspace-access-token/).
71+
- Your **Access token**. Semgrep requires a [workspace-level access token](https://support.atlassian.com/bitbucket-cloud/docs/create-a-workspace-access-token/).
7172
1. Click **Connect** to save and proceed.
72-
1. The Bitbucket project is now listed under **Source Code managers**. Click **Test** to verify that the new integration is installed correctly.
73+
1. The Bitbucket project is now listed under **Source code managers**. Click **Test** to verify that the new connection is installed correctly.
7374

7475
</TabItem>
7576
<TabItem value='github-cloud'>
7677

78+
### GitHub Cloud with GitHub SSO
79+
80+
These steps are for users that sign in to Semgrep through GitHub.
81+
7782
1. Sign in to [<i class="fas fa-external-link fa-xs"></i> Semgrep AppSec Platform](https://semgrep.dev/login).
7883
1. Optional: If you have created more than one Semgrep account, select the account you want to make a connection for by clicking on the **Navigation bar > Your account name > The account you want to connect**.<br />
7984
<img src="/docs/img/more-accounts-dropdown.png" height="350px" />
8085
1. From the **Navigation bar**, click **<i class="fa-solid fa-gear"></i> Settings > Source code managers**.
81-
1. Click **Connect to GitHub**.
86+
1. Click **Add > GitHub**.
8287
1. Review the permissions requested by Semgrep, then click **Continue**.
8388
1. Click the organization you want to install Semgrep on.
8489
1. Choose to authorize and install Semgrep for **<i class="fa-regular fa-circle-dot"></i> All repositories** or **<i class="fa-regular fa-circle-dot"></i> Only select repositories**.
8590
1. Click **Install and authorize**.
8691
1. After a successful link, you are signed out of Semgrep AppSec Platform automatically, as your credentials have changed after linking an organization.
8792
1. Sign back in to Semgrep AppSec Platform.
8893

89-
</TabItem>
94+
### GitHub Cloud with non-GitHub SSO
9095

91-
<!-- removed temporarily because we're using the "old flow"
92-
:::tip
93-
- Getting Assistant recommendations grants Semgrep **code access**.
94-
- **Leave PR comments** refers to Semgrep's capability to post findings to developers in PRs.
95-
:::
96+
These steps are for users that sign in to Semgrep through a **non-GitHub** SSO provider.
97+
98+
1. Navigate to the following link: [<i class="fas fa-external-link fa-xs"></i> Semgrep GitHub app](https://github.com/marketplace/semgrep-dev) and install the Semgrep GitHub app onto the GitHub org you want to connect to.
99+
1. Sign in to [<i class="fas fa-external-link fa-xs"></i> Semgrep AppSec Platform](https://semgrep.dev/login) using SSO.
100+
1. Optional: If you have created more than one Semgrep account, select the account you want to make a connection for by clicking on the **Navigation bar > Your account name > The account you want to connect**.<br />
101+
<img src="/docs/img/more-accounts-dropdown.png" height="350px" />
102+
1. From the **Navigation bar**, click **<i class="fa-solid fa-gear"></i> Settings > Source code managers**.
103+
1. Click **Add > GitHub**.
104+
1. In the **Name of your GitHub Organization** field, enter the slug of the org that the app was installed on in step 1. For example, if the GitHub URL of your org is `https://github.com/acme-corp`, then the slug is typically `acme-corp`.
105+
1. Leave the access token field empty.
106+
1. Click **Connect**.
107+
1. Your GitHub org is now listed under **Source Code managers**. Click **Test** to verify that the new connection is installed correctly.
108+
109+
</TabItem>
96110

97-
-->
98111

99112
<TabItem value='gitlab-cloud'>
100113

@@ -106,7 +119,7 @@ If you opted to scan a GitHub or GitLab repository when you initially signed in,
106119
1. Enter the personal access token generated into the **Access token** field.
107120
1. Enter your GitLab group's name into the **Name of your GitLab Group** field. If your repositories are organized in subgroups, you only need to provide the name of the top-level group.
108121
1. Optional, but recommended: if you have multiple GitLab groups in your GitLab account, create a source code manager per group. Repeat steps 1, 3-4 for each GitLab group.
109-
1. The GitLab groups are now listed under **Source code managers**. Click **Test** to verify that the new integration is configured correctly.
122+
1. The GitLab groups are now listed under **Source code managers**. Click **Test** to verify that the new connection is configured correctly.
110123

111124
You have successfully connected an org in Semgrep AppSec Platform with an organization in your source code management tool.
112125

@@ -126,16 +139,21 @@ You have successfully connected an org in Semgrep AppSec Platform with an organi
126139
127140
<TabItem value='bitbucket-data-center'>
128141

142+
143+
1. Create an HTTP Access Token for your project following the steps outlined in [<i class="fas fa-external-link fa-xs"></i> Bitbucket Data Center documentation](https://confluence.atlassian.com/bitbucketserver/http-access-tokens-939515499.html). Ensure that the access token is created with `PROJECT_ADMIN` permissions.
144+
1. Copy the token for use in the next steps.
129145
1. Sign in to [<i class="fas fa-external-link fa-xs"></i> Semgrep AppSec Platform](https://semgrep.dev/login).
130146
1. Optional: If you have created more than one Semgrep account, select the account you want to make a connection for by clicking on the **Navigation bar > Your account name > The account you want to connect**.<br />
131147
<img src="/docs/img/more-accounts-dropdown.png" height="350px" />
132148
1. Go to **<i class="fa-solid fa-gear"></i> Settings** > **Source code managers**, and click **Add > Bitbucket Data Center**.
133149
1. In the **Connect your Bitbucket project (key)** dialog box, provide:
134150
- The **Name of your Bitbucket project (key)**. This must be the project key, which you can find by navigating to `<YOUR_BITBUCKET_DATA_CENTER_BASE_URL>/projects`.
135-
- The **URL** to access your installation of Bitbucket Data Center
136-
- The **Access Token** that [grants Semgrep permission to communicate with your project](https://confluence.atlassian.com/bitbucketserver/http-access-tokens-939515499.html). Semgrep expects a [workspace-level access token](https://support.atlassian.com/bitbucket-cloud/docs/create-a-workspace-access-token/)
137-
2. Click **Connect** to save and proceed.
138-
3. The Bitbucket project is now listed under **Source code managers**. Click **Test** to verify that the new integration was installed correctly.
151+
- The **URL** to access your installation of Bitbucket Data Center; this is your fully-qualified domain name.
152+
- The **Access Token** that grants Semgrep permission to communicate with your project. Semgrep expects an [HTTP access token](https://confluence.atlassian.com/bitbucketserver/http-access-tokens-939515499.html) with `PROJECT_ADMIN` permissions.
153+
1. Click **Connect** to save and proceed.
154+
1. The Bitbucket project is now listed under **Source code managers**. Click **Test** to verify that the new connection was installed correctly.
155+
1. To enable merge request comments, click **<i class="fa-solid fa-toggle-large-on"></i> Incoming webhooks**.
156+
1. Optional: Click **Auto scan** to onboard all current and future repositories under your project to Semgrep Managed Scanning.
139157

140158
</TabItem>
141159
<TabItem value='github-enterprise'>
@@ -214,7 +232,7 @@ Connect Semgrep and GitLab Self-Managed accounts by creating a PAT and providing
214232
1. Enter your GLSM base URL into the **URL** field.
215233
1. Enter your GitLab group's name into the **Name of your GitLab Group** field. If your repositories are organized in subgroups, you only need to provide the name of the top-level group.
216234
1. If you have multiple GitLab groups in your GitLab account, you need to create a source code manager per group. Repeat steps 1, 3-5 for each GitLab group.
217-
1. The GitLab groups are now listed under **Source Code managers**. Click **Test** to verify that the new integration is installed correctly.
235+
1. The GitLab groups are now listed under **Source Code managers**. Click **Test** to verify that the new connection is installed correctly.
218236

219237
</TabItem>
220238
</Tabs>

docs/deployment/create-account-and-orgs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Semgrep organizations can be **connected** to equivalent GitHub, GitLab, and SSO
8080

8181
### Next steps for Bitbucket and Azure Repos users
8282

83-
- Connect your Semgrep org to your Bitbucket Data Center project or your Azure DevOps organization. Refer to [<i class="fa-regular fa-file-lines"></i> Connect a source code manager](/deployment/connect-scm) for steps.
83+
- Connect your Semgrep org to your Bitbucket Data Center project or your Azure DevOps project. Refer to [<i class="fa-regular fa-file-lines"></i> Connect a source code manager](/deployment/connect-scm) for steps.
8484
- To add members to your Semgrep organization, set up [<i class="fa-regular fa-file-lines"></i> SSO authentication](/deployment/sso).
8585
- You can also opt to scan a repository instead.
8686

0 commit comments

Comments
 (0)