Connect a source code manager
- You have gained the necessary resource access and permissions required for deployment.
- You have created a Semgrep account and organization.
Linking a source code manager provides the following benefits:
- Allows the Semgrep org membership to be managed by GitHub or GitLab.
- For GitHub users:
- Provides Semgrep access to post PR or MR comments.
- For GitHub Actions users: Enables you to add a Semgrep CI job to repositories in bulk.
You can only connect your Semgrep organization to the source code manager that you originally logged in with. If your organization uses both GitHub and GitLab to manage source code, log in with the source code manager that you would prefer to use to manage Semgrep org membership. You can still scan repositories from other sources.
The process to connect a source code manager depends on whether your SCM tool is cloud-hosted by the service provider, hosted on-premise, or hosted as a single tenant by the service provider.
Connect to cloud-hosted orgs
If you opted to scan a GitHub or GitLab repository when you initially signed in, you may have already performed these steps and can skip to Next steps.
GitHub Cloud
- Sign in to Semgrep AppSec Platform.
- On the sidebar, click the organization account you want to make a connection for.
- Click Settings > Source Code Managers.
- Click Connect to GitHub.
- Review the permissions requested by Semgrep, then click Continue.
- Click the organization you want to install Semgrep on.
- Choose to authorize and install Semgrep for All repositories or Only select repositories.
- Click Install and authorize.
- After a successful link, you are signed out of Semgrep AppSec Platform automatically, as your credentials have changed after linking an organization.
- Sign back in to Semgrep AppSec Platform.
You have successfully connected an org in Semgrep AppSec Platform with an organization in your source code management tool.
GitLab Cloud
For users of GitLab cloud-hosted plans, a connection to GitLab is created automatically after adding a Semgrep job to GitLab CI/CD. No other steps are needed.
Connect to on-premise orgs
GitHub Enterprise Server
This section is applicable to users on a GitHub Enterprise Server plan.
The Semgrep App for GitHub Enterprise (GHE) creates a connection between Semgrep and orgs in your GHE deployment. There are two primary installation steps:
- Install the Semgrep App for the first time using the GHE organization (org) that "owns" the app.
- Install the app for additional GHE orgs.
Initial Semgrep App installation
If your deployment contains many orgs, you must choose an org in the deployment that acts as the owner of the Semgrep App. As the owner, this org controls the settings and permissions granted to the app.
- Log in to Semgrep AppSec Platform.
- Click Settings** > Source Code Managers, and click Add GitHub Enterprise.
- In the Connect your GitHub Organization dialog box, provide:
- The Name of your GitHub Organization
- The URL to access your deployment
- Click Connect to save your changes.
- Refresh your browser. You should see a new entry under Source code managers that displays the GHE org and instance URL you entered. Click Register app.
- In the Add GitHub App page, ensure that:
- You've selected Organization.
- The GitHub Organization name is populated; if not, enter the name of your org.
- You've selected the Use for multiple GitHub orgs (Enterprise-public app) checkbox.
- Review the permissions for the app; as the app owner, note that you can change these permissions later.
- Click Register GitHub App to proceed.
- You are taken to your GHE instance and asked to name your app. You can choose whatever name you'd like, but Semgrep recommends that you name it something that indicates that this is the Semgrep GHE app.
- After you name your app, choose the GHE org to which you want it installed.
- Select the org that you want to act as the owner of the app, and click Install.
- Wait for the installation to complete. When done, you will be redirected to Semgrep.
- Verify the installation by navigating to Settings > Source Code Managers. Ensure that the entry for your SCM shows a Connected badge.
- In GHE, you should see the app listed as installed on the GitHub Apps page. You can click Configure to choose the repositories to which the app has access. Additionally, you can go to App settings to customize the permissions granted to the app.
At this point, you've successfully installed the GHE Semgrep App on the owner GHE org. In the future, other members of your GHE instance can install the app on their GHE orgs using the public link if they have the proper permissions. You can get the public link from GHE by going to GitHub Apps > App settings.
Install the app for subsequent GHE orgs
You can install the Semgrep app onto additional GHE orgs at any time. To do so:
- Go to the public link for the app shared with you by your admin. Click Install.
- Choose the GHE org to which you want the app installed, and click Install.
- In the popup confirmation message, click Install.
- The GHE org should now be listed under Source code organizations.
You have successfully connected Semgrep to your GitHub Enterprise Server.
GitLab Self-Managed Plans
This section is applicable to users with subscriptions to any GitLab self-managed plan.
Connect Semgrep and GitLab Self-Managed by creating a PAT and setting it in Semgrep AppSec Platform:
- Create a PAT by following the steps outlined in this guide to creating a PAT. Ensure that the PAT is created with the required
api
scope. - Sign in to Semgrep AppSec Platform.
- Click Settings > Source Code Managers > Add GitLab Self-Managed and enter the personal access token generated into the Access token field.
- Enter your GLSM base URL into the URL field.
- Ensure that your SCM integration successfully detects repositories by setting up a CI job. Do the following steps for each repository you want to scan:
- Create or edit your
.gitlab-ci.yml
configuration file to add Semgrep as part of your GitLab CI/CD pipeline. Refer to Sample CI configurations for a template you can copy and customize. - Commit the updated
.gitlab-ci.yml
file. - The CI job starts automatically to establish a connection with Semgrep AppSec Platform. Alternatively, if it does not start automatically, start the job from the GitLab CI/CD interface. Upon establishing a connection, your repository appears in Semgrep AppSec Platform > Projects page.
- Create or edit your
Next steps
- Optional: If you want to set up SSO to manage your users, see SSO authentication.
- You are ready to scan your org's repositories with Semgrep.
Not finding what you need in this doc? Ask questions in our Community Slack group, or see Support for other ways to get help.