Set up GitLab merge request comments
- 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.
Semgrep can create merge request (MR) comments in your GitLab repository. These comments provide a description of the issue detected by Semgrep and may offer possible solutions. These comments are a means for security teams, or any team responsible for creating standards to help their fellow developers write safe and standards-compliant code.
Automated comments on GitLab merge requests are displayed as follows:
Figure An inline GitLab merge request comment.
Conditions for MR comment creation
MR 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: |
Software composition analysis (SCA) | Semgrep Supply Chain (SSC) | A comment appears only when the finding is reachable or when Semgrep detects a license violation. | Complete the steps in Confirm account connection and access to receive Supply Chain PR comments and enable dependency search to receive license violation PR comments. |
Secrets | Semgrep Secrets | A comment appears on validated secrets. | This product is in beta. Contact support@semgrep.com to enable comments. |
Comments from Supply Chain scans include the following information:
- Risk
- 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 GitHub Advisory Database and the National Vulnerability Database (NVD), if available.
Pull or merge requests with vulnerabilities detected by SSC are not blocked from merging.
Steps to set up MR comments
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.