A Security Gate in CI: Fail the Deploy Before It Ships

A security gate gives your pipeline one question to answer: is this site still clean enough to ship? Here is how the Dr. Security gate works, what it needs and a safe way to roll it out.

Dr. Security3 MIN READ

๐Ÿ’ก The short version: a security gate is a pipeline step that starts a scan of your site, waits, and fails the job if anything at or above a severity you choose is wrong. On a plan that includes API access and CI, it takes a short shell snippet to add one.

Most security problems arrive quietly in an ordinary change: a new environment variable, a debug route, a header someone removed while fixing something else. A gate turns "someone should have noticed" into "the build said no". ๐Ÿšฆ

โš™๏ธ How it works

  1. Start a scan of a site in your account, through the API.
  2. Wait for it to finish. While it's running, asking for the verdict answers "not found", so you poll until it's ready.
  3. Ask for the verdict. The gate fails when any failed check is at or above the severity you set (low, medium, high or critical, with high as the default). A check that errored is not counted as a finding.
  4. Fail the job if it didn't pass.

๐Ÿงช The step itself

This is the snippet the product shows when you create a token. The token belongs in your CI's secret store, never in the file:

SCAN=$(curl -sf -X POST -H "Authorization: Bearer $DRSECURITY_TOKEN" \
  https://api-portal.getdrsecurity.com/api/v1/sites/SITE_ID/scans | jq -r .scanId)

for i in $(seq 1 60); do
  curl -sf -H "Authorization: Bearer $DRSECURITY_TOKEN" \
    "https://api-portal.getdrsecurity.com/api/v1/scans/$SCAN/gate?failOn=high" \
    -o gate.json && break
  sleep 10
done

jq -e .passed gate.json

๐Ÿ”‘ What you need

  • A plan with the API feature to create a token. The plan is checked again on every call, so a lapsed plan stops the token straight away.
  • A token that can start scans. Tokens are either read-only or read and start scans, and the second kind also needs the CI feature.
  • The site's id, from your sites list (GET /api/v1/sites).

Tokens start with drsc_, are shown once, and are stored only as a hash. A token works on the public API alone. It can't be used to sign in to the portal or to create more tokens.

๐Ÿชœ A safe rollout

  1. Start report-only. Run the step, print the result, and don't fail the job for a week. Learn what your normal looks like.
  2. Fix the standing items, or accept them knowingly.
  3. Gate on critical, then high, then lower if you want to.
  4. Run it after deploy, against the live address, since that's what a stranger sees. A scan of a preview shows a preview.

โš ๏ธ Things to know

  • Normal limits apply. A scan started through the API goes through the same cooldown and daily limit as one started in the portal, so a pipeline that scans very often may be refused.
  • It checks the outside. It won't replace tests for your own code. (What an outside scan covers.)
  • Some checks only run for verified sites. Verify ownership of the site first so the gate sees everything your plan includes.

New to a pre-launch routine? Start with the 30-minute check, then automate the parts that repeat.

๐Ÿš€ See what the gate would say today. Run a free scan.

  • security gate ci
  • ci security check
  • fail build on vulnerability
  • devsecops for startups
  • security scan api

FIND OUT WHAT YOU'RE EXPOSING.