You can configure PR scans while creating a new Bitbucket Cloud App installation or for existing Bitbucket Cloud App integrations. Endor Labs automatically configures webhooks to scan your pull requests.
You can also choose to receive PR comments on your pull requests. After you configure PR comments, Endor Labs posts a comment on the pull request if any issues are detected during the PR scan. See Bitbucket Cloud PR comments for more information.
Create an access token
To enable PR scans and PR comments, you must provide an access token with read and write permissions for Webhooks and Pull requests, and read access for Projects. This access token allows Endor Labs to automatically configure webhooks for PR scanning functionality.
To create an access token:
-
Sign in to Bitbucket Cloud and navigate to your workspace or project.
-
Create a workspace access token or project access token. Ensure that you have a Bitbucket Cloud Premium account to create an access token at the workspace or project level.
-
When creating the access token, ensure you select the following permissions:
- Projects: Read
- Webhooks: Read and Write
- Pull requests: Read and Write
- Repository: Read and Write
-
Copy the generated access token and store it in a secure location. You need it when configuring the Bitbucket Cloud App integration in Endor Labs.
Configure PR scans during a Bitbucket Cloud App installation
After you complete the initial installation of the Bitbucket Cloud App in Endor Labs, you can configure PR scans. At this point, the Bitbucket Cloud App will be operational.
You can also choose to apply PR scans to specific projects rather than all the projects in the workspace through a scan profile. See Scan profiles for more information.
-
Select Pull Request Scans and enable it for automatic scanning of PRs submitted by users.
-
Set the Scanning Preferences to:
- Quick Scan for dependency resolution without reachability analysis. This provides rapid visibility into potential vulnerabilities for faster merges.
- Full Scan (Reachability) for dependency resolution, reachability analysis, and call graph generation for supported languages. This provides full visibility but may take longer to complete.

-
Optionally, select Pull Request Comments to allow Endor Labs to comment on PRs for policy violations.
When you enable PR comments, Endor Labs will post a comment on the pull request if any issues are detected during the PR scan. You need to set up PR comments in Endor Labs to receive the comments. See Bitbucket Cloud PR comments for more information.
-
Click Save to save PR scan configuration.
Configure PR scans for existing Bitbucket Cloud integrations
You can configure PR scans for existing Bitbucket Cloud integrations or after creating a new Bitbucket Cloud integration.
- Sign in to Endor Labs and select Integrations from the left sidebar.
- Click Manage in Bitbucket Cloud under Source Control Managers.
- Click the three dots menu next to the Bitbucket Cloud integration that you want to update.
- Select Edit Integration.
- Select Pull Request Scans in Integration Settings.

-
Select Pull Request Scans to enable PR scans.
-
Optionally, select Pull Request Comments to enable PR comments.
Ensure that you complete the PR comments configuration in Endor Labs to receive the comments. See Bitbucket Cloud PR comments for more information.
-
Click Save to save the changes.
The changes are applied from the next scanning cycle.
Configure PR scans for specific repositories
You can configure PR scans and PR comments only for specific repositories. If you select the options to configure PR scans in your Bitbucket Cloud App integration, pull requests for all the repositories in your project or workspace are scanned. Instead, you can choose to configure PR scans and PR comments for selected repositories using scan profiles.
-
Enable PR scans and PR comments during the initial Bitbucket Cloud App installation. This ensures that the webhooks are properly configured and recognized by Endor Labs.
-
Edit the Bitbucket Cloud App integration and disable Pull Request Scans and Pull Request Comments. This prevents PR scans from running for all repositories in the workspace.
-
Create a scan profile with Pull Request Scans and optionally Pull Request Comments enabled under Developer Workflow.

-
Associate the scan profile with the specific repository where you want PR scans to run.
This approach allows you to control which repositories have PR scans enabled while ensuring that the webhook is properly configured during the initial installation.
Bitbucket Cloud PR comments
PR comments are automated comments added to pull requests when Endor Labs detects policy violations or security issues during scans. When a PR is raised or updated, Endor Labs runs scans on the proposed changes and adds a comment if any violations are detected based on the configured action policies.
After you enable PR comments, you need to set up an action policy to allow comments to be posted on pull requests.
Configure action policy for PR comments
PR comments template
Endor Labs provides a default template for PR comments that you can use out-of-the-box. You can also create custom templates using Go Templates.
The following section shows the default template for PR comments.
The file /content/includes/bitbucket_cloud_pr_comment_template.txt was not found.
You can create your custom template by editing the default template and saving the changes.
The following specification shows the additional functions that you can use in your custom template. You can access these functions by using their corresponding keys.
The file /content/includes/bitbucket_cloud_pr_comment_func_map.txt was not found.
To edit the default template:
-
Select Manage > Integrations from the left sidebar.
-
Click Edit Template next to Bitbucket Cloud under Template for PR Comments.
Bitbucket Cloud only supports markdown in PR comments and does not support HTML tags.
-
Update the template with the required changes.
-
Select Propagate this template to all child namespaces if you want to apply the template to all child namespaces.
- Click Save Template to save the changes.
PR scan comments in Bitbucket Cloud
After you enable PR comments, Endor Labs posts a comment on the pull request if any issues are detected during the PR scan based on the action policies.
The following example shows a comment on the pull request as a result of the action policy for identifying leaked secrets.
You can expand and view the details of the finding.
Click Link to Finding to view the details of the finding in Endor Labs.
For secrets, Endor Labs also generates a comment with the line number where the secret is detected.
View PR scan findings
When you create a new pull request, the Endor Labs Bitbucket Cloud App scans the pull request. Endor Labs generates findings based on the finding policy.
-
Sign in to Endor Labs and select Projects from the left sidebar.
-
Select the project for which you want to view the PR scan findings.
-
Select PR runs to view the PR scan findings.

-
Select the PR for which you want to view the findings.

-
Click View Findings to view the findings on the PR.

See View Findings for more information on Findings in Endor Labs.
The action policy that you create triggers the posting of comments on your pull request after a scan is complete. See Action policy for more information. You can create multiple action policies based on your requirements, which the PR scan can trigger. If you create action policy with the
Secrettemplate, you get an inline comment with the line number where the secret is detected.Ensure that you configure the following important settings in the action policy:
Choose an appropriate action policy template or create a custom action policy.
You can choose an action policy template like Containers or create a custom action policy.
Under Action, select Enforce Policy, then choose:
Define the scope of the policy using tags. Only projects that match the specified tags will receive PR comments.
Select Propagate this policy to all child namespaces if you want to apply the policy to all child namespaces.