Documentation Index
Fetch the complete documentation index at: https://docs.semgrep.dev/llms.txt
Use this file to discover all available pages before exploring further.
YOUR DEPLOYMENT JOURNEY
- You have gained the necessary resource access and permissions required for deployment.
- You have created a Semgrep account and organization.
- You have connected your source code manager.
- Optionally, you have set up SSO.
- You have successfully added a Semgrep job to your CI workflow with diff-aware scanning.

Conditions for PR comment creation
PR comments appear for the following types of scans under these conditions:| Type of scan | Product name | Trigger condition | How to set up |
|---|---|---|---|
| Static application security testing (SAST) | Semgrep Code | A comment appears when a finding is generated by a rule in Comment or Block mode. This means you can fully customize what comments your developers receive. | Complete the steps in the following sections: 1. Confirm your Semgrep account’s connection and access to your source code manager. 2. Configure comments for Semgrep Code. |
| Software composition analysis (SCA) | Semgrep Supply Chain (SSC) | A comment appears based on the conditions you explicitly set in a Supply Chain policy or when Semgrep detects a license violation. | To receive Supply Chain comments, complete the steps in Confirm account connection and access and set up a policy. To receive license violation comments, enable dependency search. |
| Secrets | Semgrep Secrets | A comment appears when a finding is generated by a rule in Comment or Block mode. A comment also appears for invalid findings and validation errors if these conditions are set to Comment or Block mode. | Complete the steps in the following sections: 1. Confirm your Semgrep account’s connection and access to your source code manager. 2. Configure comments for Semgrep Secrets. |
A description of the vulnerability, including the types of attack it is vulnerable to. Fix
Indicates what versions to upgrade to, if any, that resolves or eliminates the vulnerability. Reference
A link to additional information about the vulnerability from its source, such as the GitHub Advisory Database and the National Vulnerability Database (NVD), if available.
Supported Bitbucket plans
- Any of the following Bitbucket plans are supported:
- Cloud Free
- Standard
- Premium
- Workspace access token: If you use the Bitbucket Cloud Premium plan, you can create a workspace access token. This option saves time because you can create one access token for all repositories in the workspace. With one workspace access token, you can bulk-onboard more repositories at once from a whole workspace. However, you can also use the option of a repository access token to onboard repositories one by one.
- Repository access token: If you do not have the Bitbucket Cloud Premium plan, create a separate repository access token for each repository where you want to use Semgrep. This configuration option is also useful if you have the Bitbucket Cloud Premium plan, but prefer to onboard repositories one by one instead of bulk onboarding.
- Creating and adding a workspace access token
- Creating and adding a repository access token
Create and add a workspace access token
PREREQUISITE
- Bitbucket Cloud Premium plan. If you do not have a Bitbucket Cloud Premium plan, create a repository access token.
Create a workspace access token in Bitbucket with Read and Write permissions for the Pull requests scope. Follow the instructions in Create a workspace Access Token in Bitbucket documentation.
Enable PR comments in Bitbucket
Prerequisites
- In addition to finishing the previous steps in your deployment journey, it is recommended to have completed a full scan on your default branch for the repository in which you want to receive comments.
- You must have a Bitbucket Cloud workspace access token or a repository access token.
Confirm your Semgrep account’s connection
Confirm that you have the correct connection and access:Triage through PR comments
Developers can triage Semgrep findings without leaving Bitbucket by responding to the PR comments authored by Semgrep. To use this feature, you must have a paid Bitbucket Cloud plan, and must update your source code manager (SCM) connection to use a workspace access token. This allows you to enable webhooks, which Semgrep requires for the triage through PR comments feature. To update your connection between Semgrep and Bitbucket:Create a workspace access token. Ensure that you assign the following scopes to the token:
webhook (read and write)repository (read and write)pullrequest (read and write)project (admin)account (read)
Return to Semgrep and sign in.
In the Update access token dialog that appears, provide the new token you created. Click Update to save and proceed.
Set up the configuration file
The logic to determine whether Semgrep runs a full scan or a diff-aware scan on a pull request is defined in thebitbucket-pipelines.yml file.
For PR comments and accurate diff-aware scan analysis to work, you must set SEMGREP_BASELINE_REF, which defines the repository’s default branch used as the comparison baseline, such as main or master. Specifying the default branch helps Semgrep understand the differences between the current branch and the main line of development and to generate meaningful results and PR comments.
Click to see a sample workflow file
Click to see a sample workflow file
Configure comments for Semgrep Code
In addition to setting up the connection between Semgrep and Bitbucket, you must assign rules to Comment or Block mode. This customization enables you to:- Manage the amount of PR comments your developers receive.
- Ensure that only rules that meet your criteria, such as high severity or high confidence rules, produce comments visible to developers, reducing noise.
Set rules to Comment or Block mode
The following instructions let you customize what findings or security issues your developers see as comments in their PRs:In your Semgrep AppSec Platform account, click Rules > Policies to enter the Policies page. Under Modes , you can quickly see if you have existing rules in either Comment or Block mode.
Configure comments for Semgrep Secrets
In addition to setting up the connection between Semgrep and Bitbucket, you must assign rules to Comment or Block mode. This customization enables you to:- Manage the amount of PR comments your developers receive.
- Ensure that only rules that meet your criteria, such as high severity or high confidence rules, and result in findings involving valid secrets produce comments visible to developers, reducing noise.
Set rules to Comment or Block mode
The following instructions let you customize what findings or security issues your developers see as comments in their PRs:Under Modes , you can see if you have existing rules in either Comment or Block mode. You can also use the filters to find rules you want to set to Comment or Block.
Validation state policies
Validation state policies allow you to define how Semgrep handles the following issues:- Invalid findings: the secret has been revoked, was never functional, or used for a custom or private endpoint that Semgrep can’t communicate with. For example, a Semgrep rule that tests GitHub credentials may return an invalid finding if Semgrep can’t communicate with an on-premise deployment.
- Validation errors: Semgrep was unable to reach the secrets provider to test the validity of the credential, or Semgrep received an unexpected response from the API
Configure comments for Semgrep Supply Chain
To configure comments for Supply Chain, you must define a Supply Chain policy. This policy lets you set the specific conditions, such as transitivity and reachability, that trigger a comment. These conditions are unique to Supply Chain findings. See the Policies documentation for more information.Receive comments in an access-controlled Bitbucket account
Bitbucket Premium provides access control features for content that your individual account owns. If you use this feature, you need to add several IP addresses into your allowlist. If you are behind a firewall, are using a virtual private network (VPN), or have network restrictions regarding access, you may need to add the following IP addresses to the ingress allowlist and egress allowlist:Additional egress IP addresses
You must also add CloudFront IP addresses to your egress allowlist. Refer to Locations and IP address ranges of CloudFront edge servers for a list of IP addresses.Test your configuration
Test that you are able to receive findings by manually triggering a scan through your CI provider. Receiving PR or MR comments may require additional steps depending on the custom configuration of your VPN or SCM (for example, if you use a static IP without a hostname). Reach out to Semgrep Support with any concerns.INFOOnly rules set to the Comment and Block rule modes in the Policies page create PR comments.
Optional features
Customize PR comments
You can customize the comments Semgrep leaves on your PR. Custom comments allow you to direct your teams to the resources they need to handle the vulnerabilities Semgrep identifies in their code.
Sign in to Semgrep AppSec Platform.
Provide a custom comment for each Semgrep product whose findings you want to generate a PR comment. Semgrep supports Markdown and plaintext links in your message.
Enable Rule-defined fix in Bitbucket Cloud repositories
Autofix is a Semgrep feature in which rules contain suggested fixes to resolve findings. To enable Rule-defined fix for all projects in your Semgrep AppSec Platform organization, follow these steps:Next steps
You’ve finished setting up a core deployment of Semgrep 🎉.- Explore recommended tasks after deployment in Beyond core deployment.
