The pull request is the best security checkpoint you have, and most teams underuse it. It is the one moment where a specific, bounded change is sitting still, the author is fully in context, and nothing has shipped yet. A security issue caught here is a one-line edit in an open PR. The same issue caught after merge is a tracked ticket; after deploy, an incident. The cost of fixing a flaw rises steeply the further it travels from the pull request — which is exactly why the PR is where you want your checks.
This guide is about doing that well in practice: what to scan on every pull request, how to surface findings so developers actually act on them, when to block a merge versus warn, and how to keep the whole thing fast enough that your team does not quietly route around it. For the formal definition of the enforcement mechanism, see what is a PR quality gate; this piece is the operational how-to.
Why the pull request is the right checkpoint
Three things make the PR uniquely well-suited to security scanning, and understanding them shapes how you set it up:
- The change is bounded. You are evaluating a diff, not an entire codebase. Scanning what changed is faster and makes findings far easier to attribute — you know exactly which change introduced the problem.
- The author is in context. The developer wrote this code minutes or hours ago. They understand the intent, they can fix it immediately, and the feedback lands while it is still cheap to act on. A finding delivered three weeks later in a separate dashboard lands on someone who has mentally moved on.
- Nothing has shipped. The PR is upstream of merge, build, and deploy. A problem stopped here never becomes a problem in production. This is the literal mechanism of shift-left security — moving the check to the earliest practical point.
The implication: a scanner that only runs nightly, or only produces a report somewhere, is leaving the best checkpoint on the table. The goal is to make security a native part of code review, in the same surface where developers already work.
What to scan on every pull request
A good PR security check looks at several classes of issue at once, because they fail in different ways and a change can introduce more than one:
- Static analysis (SAST) — vulnerability patterns in the first-party code the PR changes: injection flaws, weak crypto, missing authorization checks, unsafe deserialization. Scanning the diff keeps this fast and relevant.
- Dependency analysis (SCA) — whether the PR adds or upgrades a dependency to a version with a known vulnerability, including transitive ones. A single new line in a lockfile can introduce hundreds of transitive packages.
- Secret detection — hardcoded credentials, API keys, and private keys in the diff. This one deserves special treatment, discussed below.
- IaC scanning — misconfigurations in any Terraform, CloudFormation, or Kubernetes manifests the PR touches, so an over-permissive role or a public bucket is caught in review rather than discovered in production posture. See infrastructure as code security.
Scanning all of these on the same PR, in one pass, is what gives reviewers a complete picture of the risk a change introduces — rather than four separate tools each reporting a slice.
Turn findings into inline review comments
Where a finding appears matters as much as whether it is found. The pattern that works: findings surface as inline comments on the exact changed line, inside the pull request, as part of the normal review — not as a link to a separate dashboard the developer has to go find.
The reason is behavioral. Context-switching is friction, and friction is where security steps quietly die. If acting on a finding means leaving the review, opening another tool, locating the finding, and mapping it back to a line, most developers will deprioritize it. If the finding is a comment on the line they are already looking at, with a clear explanation and a suggested fix, acting on it is the path of least resistance. Meeting developers in their existing workflow is the difference between a check that gets used and one that gets ignored.
Each finding should carry enough to act without further research: what the issue is, why it matters, and a concrete remediation — for a dependency, which version to move to and whether the upgrade is breaking; for a SAST finding, the risky pattern and the safe alternative; for a secret, where it is and that it must be rotated.
When to block a merge, and when to warn
A quality gate reports pass or fail on the PR, but not every finding should hard-block. Getting this calibration right is what keeps the gate credible. A reasonable policy:
- Hard-fail (block the merge): any confirmed secret, and vulnerabilities at or above a severity threshold you set — ideally weighted by exploitability, not raw CVSS. These are the issues where “merge now, fix later” is not an acceptable trade.
- Warn (surface, but allow merge): lower-severity findings, informational issues, and anything where a human judgment call is reasonable. Visible, tracked, but not a wall.
Two calibration principles keep the gate trusted:
- Secrets should almost always be a hard-fail. A leaked credential is rarely a judgment call, and it is permanent once in history. This is the one category where a blanket block is the right default. The reasoning is in how to stop secrets leaking in git.
- False positives are a tax on trust. A gate that cries wolf gets disabled, formally or informally. Favor a scanner whose findings are high-signal and whose severity reflects your actual environment, and provide a clean, auditable path to accept a reviewed risk — so the gate stays respected rather than resented.
Keep it fast, or developers will route around it
A PR check competes with a developer’s attention and momentum. If it takes too long, it becomes the thing people learn to bypass. Practical ways to keep it fast and sustainable:
- Scan the diff, not the world, on each PR. Evaluating what changed is far quicker than re-scanning the whole repository every time, and it is what makes sub-review-cycle feedback possible.
- Run checks in parallel with human review, not as a serial gate the author stares at. The scan should be finishing while the reviewer reads.
- Make the accept-risk path clean. When a finding is a genuine false positive or an accepted risk, suppressing it should be quick and leave an auditable record. A gate with no escape valve gets disabled wholesale, which is far worse than a tracked exception.
- Don’t make developers configure four tools. Every separate scanner is its own setup, output format, and failure mode. One integration that covers SAST, SCA, secrets, and IaC on the PR is dramatically more likely to stay enabled than four bolted together.
Rolling it out without a developer revolt
The fastest way to kill a PR security program is to switch on hard-blocking everywhere on day one and bury developers in findings for code they did not write. A staged rollout earns the trust that makes the gate stick:
- Start in warn-only mode. For the first few weeks, surface findings as comments without blocking any merges. This lets developers see the signal, learn the format, and build confidence that it is accurate — without the gate ever standing between them and a release. It also lets you measure the false-positive rate before it can cause friction.
- Tune out the noise. Use the warn-only period to suppress rule classes that are consistently false in your codebase and to confirm severity is landing sensibly. A gate’s credibility is set in its first two weeks; spend them earning it.
- Turn on hard-fail for the unambiguous categories first. Secrets are the natural starting point for blocking — a committed credential is almost never a judgment call, and developers readily accept that it should stop a merge. Expand to high-severity, high-exploitability findings once the team trusts the ranking.
- Scope blocking to new findings, not the existing backlog. Blocking a PR because of a pre-existing issue the author did not touch is the fastest route to resentment. Gate on what the change introduces; handle the historical backlog as a separate, planned effort. This keeps the PR gate about the diff in front of the developer.
- Give feedback where developers already are. Reinforce that findings appear in the PR, with a clear fix, and that the accept-risk path is quick and auditable. The more the gate feels like a helpful reviewer and the less it feels like a bureaucratic wall, the more it gets used rather than bypassed.
Done this way, the gate becomes something developers rely on rather than resent — a safety net that catches their mistakes early, in context, before those mistakes become anyone else’s problem.
Measuring whether it’s working
Track a few signals to know the program is healthy: the share of security issues caught at PR versus discovered later (should rise), the false-positive rate on blocking rules (should stay low), and time-to-fix for blocked findings (should be short, because the author is in context). If blocked findings sit for days, that is a signal the gate is firing on things developers do not believe matter — revisit the thresholds rather than letting the gate lose credibility.
A note on scope
PR-time scanning is powerful but it is not the whole program. It evaluates a change at the moment it is proposed; it does not replace deeper, point-in-time assessment of the running application such as dynamic testing or penetration testing, which look at the system from the outside and catch issues static analysis cannot. The right mental model is complementary: PR checks catch known patterns and risky changes continuously and early, and dynamic testing adds depth on the running application. A team with only one of the two has a gap.
How Cloudanix catches issues at the pull request
Cloudanix Code Security is built around the pull request as the primary checkpoint, with enforcement running server-side so it holds consistently across the team.
- Auto-scan on every PR. When a pull request is opened or updated, Cloudanix runs SAST, SCA, secrets, and IaC analysis on the change automatically — no pipeline rewrite required for the core scanning.
- Inline findings in review. Results post as comments on the relevant line and as a status check on the PR, so developers see and fix issues inside their existing review flow rather than in a separate tool.
- A quality gate that can block the merge. A PR quality gate can hard-fail the merge on a leaked secret or a finding above your chosen severity, with triage controls (pause / acknowledge / accept risk) for the cases that need a human decision.
- Severity from real exposure. Because code and cloud sit on one asset graph, a PR finding can be weighed against where the affected code actually runs — so the gate blocks on what is exploitable, not merely on what is flagged. The mechanics are in how code-to-cloud correlation works.
- Broad SCM coverage. PR scanning runs across GitHub, GitLab, Bitbucket, and Azure DevOps, so a multi-SCM organization gets one consistent gate.
To see Cloudanix annotate your own pull requests, book a free assessment or explore the interactive demo on the Code Security page.