> ## Documentation Index
> Fetch the complete documentation index at: https://semgrep-ee9d73d8-abhijna-fix-slugs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Enable source code manager code access

Some Semgrep features require additional levels of code access. You can grant these permissions to Semgrep by assigning additional scopes to the access token that facilitates communication between Semgrep and the source code manager (SCM). The following table shows the minimum scope needed to enable the required code access level.

#### Required SCM code access scopes

| SCM                              | Read access scope                         | Write access scope                          |
| :------------------------------- | :---------------------------------------- | :------------------------------------------ |
| Azure DevOps                     | `code:read`                               | `code:write`                                |
| Bitbucket Cloud                  | `repository:read`<br />`pullrequest:read` | `repository:write`<br />`pullrequest:write` |
| Bitbucket Data Center            | `repository:read`                         | `repository:write`                          |
| GitHub.com and Github Enterprise | `contents:read`                           | `contents:write`                            |
| GitLab and Gitlab Self-Managed   | `read_repository`                         | `write_repository`                          |

## Grant code access to Semgrep with a private GitHub app

If you already have a private Semgrep GitHub app set up and configured for your deployment that **doesn't** have code access enabled, follow these steps to update the app and grant code access to Semgrep.

<Tip>
  **APP SLUG**

  To find the name of your app slug:

  1. Go to [**Settings > Source code managers**](https://semgrep.dev/orgs/-/settings/source-code).
  2. Find the panel for your source code manager. The app slug is listed immediately following the name of the source code manager.
</Tip>

<Steps>
  <Step>
    Navigate to the GitHub Application permissions and events page. GitHub Enterprise users must replace the `https://github.com` base URL with the base URL of the GitHub Enterprise instance.<br />
    i. For organization accounts, go to <code>[https://github.com/organizations/ORGANIZATION\_NAME/settings/apps/APP\_SLUG/permissions](https://github.com/organizations/ORGANIZATION_NAME/settings/apps/APP_SLUG/permissions)</code>.<br />
    ii. For user accounts, go to <code>[https://github.com/settings/apps/APP\_SLUG/permissions](https://github.com/settings/apps/APP_SLUG/permissions)</code>
  </Step>

  <Step>
    Expand **Repository Permissions**.
  </Step>

  <Step>
    Under **Contents**, change the access level to **Read and write**. If you don't want to grant write permissions, change the access level to **Read**.
  </Step>

  <Step>
    Click **Save Changes**.
  </Step>

  <Step>
    At this point, GitHub sends you or your GitHub admin an email to approve the permissions changes. Once approved, Semgrep has code access to your GitHub instance.
  </Step>
</Steps>

## Grant code access to Semgrep with an access token

If you onboarded your repositories using an access token, then you can follow these steps to grant code access to Semgrep.

<Tabs>
  <Tab title="Azure DevOps Cloud">
    <Steps>
      <Step>
        Navigate to the Azure DevDps access token settings page: <code>[https://dev.azure.com/ORGANIZATION\_NAME/\_usersSettings/tokens](https://dev.azure.com/ORGANIZATION_NAME/_usersSettings/tokens)</code>.
      </Step>

      <Step>
        Click **New token** to launch the **Create a new personal access token** dialog. Ensure that you assign the `Code: Read` and `Code: Write` scopes to the token, in addition to [any other scopes you may need](/deployment/managed-scanning/azure#prerequisites-and-permissions) for other features you've enabled for your Semgrep deployment. Create the token, and copy its value.
      </Step>

      <Step>
        Return to Semgrep AppSec Platform, and go to [**Settings > Source code managers**](https://semgrep.dev/orgs/-/settings/source-code).
      </Step>

      <Step>
        Find the connection associated with your organization, and click **Update access token**.
      </Step>

      <Step>
        Paste in your new access token.
      </Step>

      <Step>
        Click **Save**.
      </Step>
    </Steps>
  </Tab>

  <Tab title="Bitbucket Cloud">
    <Steps>
      <Step>
        Navigate to the Bitbucket Cloud access token settings page: <code>[https://bitbucket.org/WORKSPACE/workspace/settings/access-keys](https://bitbucket.org/WORKSPACE/workspace/settings/access-keys)</code>.
      </Step>

      <Step>
        Create a new access token and ensure that you assign the `repository:read`, `pullrequest:read`, `repository:write`, and `pullrequest:write` scopes to the token, in addition to [any other scopes you may need](/deployment/managed-scanning/bitbucket#bitbucket-cloud) for other features you've enabled for your Semgrep deployment. Create the token, and copy the token's value.
      </Step>

      <Step>
        Return to Semgrep AppSec Platform, and go to [**Settings > Source code managers**](https://semgrep.dev/orgs/-/settings/source-code).
      </Step>

      <Step>
        Find the Bitbucket connection associated with your workspace, and click **Update access token**.
      </Step>

      <Step>
        Paste in your new access token.
      </Step>

      <Step>
        Click **Save**.
      </Step>
    </Steps>
  </Tab>

  <Tab title="Bitbucket Data Center">
    <Steps>
      <Step>
        Navigate to the Bitbucket Data Center access token settings page: <code>BITBUCKET\_BASE\_URL/plugins/servlet/access-tokens/projects/PROJECT</code>.
      </Step>

      <Step>
        Create a new HTTP access token, ensuring that you assign the `repository:read` and `repository:write` scopes to the token, along with [any other scopes or permissions you may need](/deployment/managed-scanning/bitbucket#bitbucket-data-center) for other features you've enabled for your Semgrep deployment. Copy the token's value.
      </Step>

      <Step>
        Return to Semgrep AppSec Platform, and go to [**Settings > Source code managers**](https://semgrep.dev/orgs/-/settings/source-code).
      </Step>

      <Step>
        Find the Bitbucket connection associated with your workspace, and click **Update access token**.
      </Step>

      <Step>
        Paste in your new access token.
      </Step>

      <Step>
        Click **Save**.
      </Step>
    </Steps>
  </Tab>

  <Tab title="GitHub">
    <Steps>
      <Step>
        Navigate to the GitHub personal access token settings page: `https://github.com/settings/personal-access-tokens`. GitHub Enterprise users must replace the `https://github.com` base URL with the base URL of the GitHub Enterprise instance.
      </Step>

      <Step>
        Click **Generate new token**.
      </Step>

      <Step>
        Under **Repository access**, select either **All repositories** or **Only select repositories**. If you choose **Only select repositories**, select the repositories that this token is used with.
      </Step>

      <Step>
        Under **Contents**, set the access level to **Read and write**.
      </Step>

      <Step>
        Click **Generate token** and copy its value.
      </Step>

      <Step>
        Return to Semgrep AppSec Platform, and go to [**Settings > Source code managers**](https://semgrep.dev/orgs/-/settings/source-code).
      </Step>

      <Step>
        Find the GitHub connection associated with your org, and click **Update access token**.
      </Step>

      <Step>
        Paste in your new access token.
      </Step>

      <Step>
        Click **Save**.
      </Step>
    </Steps>
  </Tab>

  <Tab title="GitLab">
    <Steps>
      <Step>
        Navigate to the GitLab access token settings page: <code>[https://gitlab.com/groups/GROUP/-/settings/access\_tokens](https://gitlab.com/groups/GROUP/-/settings/access_tokens)</code>.
      </Step>

      <Step>
        Create a new access token, ensuring that you add the `read_repository` and `write_repository` scopes, along with [any other scopes or permissions you may need](/deployment/managed-scanning/gitlab#prerequisites-and-permissions) for other features you've enabled for your Semgrep deployment. Copy the token's value. Copy the token's value.
      </Step>

      <Step>
        Return to Semgrep AppSec Platform, and go to [**Settings > Source code managers**](https://semgrep.dev/orgs/-/settings/source-code).
      </Step>

      <Step>
        Find the GitLab connection associated with your group, and click **Update access token**.
      </Step>

      <Step>
        Paste in your new access token.
      </Step>

      <Step>
        Click **Save**.
      </Step>
    </Steps>
  </Tab>
</Tabs>
