Preflight is in private beta, and its behavior may change. To join the beta, contact your Semgrep account team.
Prerequisites
- Semgrep has enabled Preflight for your organization.
- You and your organization meet the prerequisites for Semgrep Agentic Workflows.
- Your organization uses Unified Policies.
- Your repositories are on GitHub, GitHub Enterprise, GitLab, or GitLab Self-Managed. Preflight doesn’t support other source code managers yet.
Enable Preflight on pull requests
1
Add Preflight
Go to Rules & Policies > Policies > Detection, and on the Scheduled workflows card, click Edit. Then click Add workflow.In the Add workflow dialog, under Runs on, click PRs, or search for
Preflight. Then click the Preflight card.2
Choose a review scope
Select a Review scope to set how deep or broad each review goes. The scope applies to every Preflight run in your organization, and you can change it later. Choose one of these options:
- Focused security review (default): Finds security issues only, with the deepest security analysis. It traces likely attack paths, such as injection and broken access control, through your codebase.
- Full code review: Finds security issues and correctness issues, such as logic bugs and performance problems, in one review. Its security analysis is lighter than a focused security review.
3
Select projects and a trigger
In Projects, select the projects for Preflight to review. In When, select what starts a review:
- A PR/MR is opened or updated (default): Preflight reviews the PR or MR when it’s opened and again on every push.
- A PR/MR is ready for review: Preflight reviews the PR or MR when it’s opened, reopened, or marked ready for review, but not on later pushes.
4
Turn on comments and save
Select Also comment on PR/MR so that Preflight comments on your PRs and MRs. To see an example comment first, click Preview comment. Then click Save changes.Semgrep creates a remediation policy named Preflight PR/MR comments. It comments on every Preflight issue in every project, and it doesn’t block merges. If you don’t select Also comment on PR/MR, Preflight issues appear only in Semgrep AppSec Platform. To change which issues get comments or to block merges, see Configure comments and merge blocking.
Semgrep Workflow: preflight status check.
Configure comments and merge blocking
Preflight comments on PRs and MRs through remediation policies. The default Preflight PR/MR comments policy comments on every issue in every project. To change which issues get comments or to block merges, replace the default policy with your own:- Go to Rules & Policies > Policies > Remediation and click Create policy. Enter a Policy name.
- Under Event, select A workflow job finishes.
- Under Scope, select the projects the policy applies to. The default is All projects.
- Under Conditions, set When to Workflow name is any of Preflight. Optional: To narrow the policy, click Add condition and add a Severity or Domain condition.
- Under Actions, click Add action. Under PR/MR, select one of these actions:
- Comment on PR/MR: Preflight comments on matching issues and doesn’t block the merge.
- Block merge and comment on PR/MR: Preflight comments on matching issues and fails the status check.
- Click Create & Enable.
- Turn off the default policy so that it doesn’t keep commenting on every issue. In Rules & Policies > Policies > Remediation, find the Preflight PR/MR comments policy. Click the three-dot menu button on the policy, and select Disable policy. The policy shows a Disabled badge.
Semgrep Workflow: preflight status check fails. The PR or MR shows the check as failed in its list of checks.
To prevent developers from merging until they fix or ignore those issues, make the status check required in your source code manager’s branch protection settings. The check fails open: if a Preflight run fails, the check passes, so a failed run doesn’t block your developers.
Review Preflight issues
When comments are on, Preflight comments on the changed lines for each issue it finds. Each comment includes the issue’s title, severity, a description of what’s wrong and how to fix it, the evidence in your code, and a full analysis. It also links to the issue in Semgrep AppSec Platform. Preflight puts issues on lines outside the change into one Findings outside the diff comment. It updates that comment on every run and strikes through issues it no longer detects. Every issue also appears on the Workflows page in Semgrep AppSec Platform, even when Preflight doesn’t comment on it. Developers can triage an issue by replying to its comment with a command, such as/ar and a reason to ignore it as an acceptable risk. For the full list of commands, see Ignore findings.
Manage credit usage
Each Preflight run uses AI credits. With the default trigger, Preflight runs on every push, so credit usage grows with how often your team opens and updates PRs and MRs. Both review scopes use about the same number of credits per run. To use fewer credits, change either of these settings:- Run Preflight on fewer projects. Start with the repositories where teams want security feedback on every PR, and add more projects after you see how many credits Preflight uses.
- Run Preflight only when a PR or MR is ready for review, so that later pushes don’t start a review.