Free plan available. Set up in minutes with the collectors you already use. Start free
Logthread

Guide

Gate builds on new findings

New to this? See Code and app security: what you get.

Failing a build on every finding a scanner reports blocks every team that has old findings. Logthread fails it only on new findings: the findings that the last full scan of the same service, branch and tool did not report. Old findings stay visible in Code security → Findings for triage and alerts; they do not stop the release.

How it decides#

Every upload to POST /api/scans answers with new_findings (by severity) and gate:

"new_findings": {"critical": 1, "high": 0, "medium": 2, "low": 0, "info": 0, "total": 3},
"gate": {"fail_on": "critical", "failed": true, "count": 1, "reason": "1 new finding at critical or above."}
  • The baseline is the last full scan of the same service, branch, kind and tool. A branch that has none yet (a new pull request branch) is compared with base_branch, by default main then master. A pull request therefore fails only on what it adds.
  • The first scan of a service, branch and tool has nothing to compare with. Every finding in it is new, and the gate passes: that scan becomes the baseline. This includes a pull request whose base branch was never scanned: it is not gated until the base branch has a full scan, so run the pipeline on the default branch first.
  • fail_on is critical (default), high, medium, low or none (report only). The gate counts new findings at that severity or above.
  • Accepted risks and false positives never count. Mark a finding on main, and the same finding on a new branch keeps that status.
  • Partial scans (partial=true, a diff scan of changed files) are gated against the baseline too. They never resolve anything and never become the baseline.

The numbers are the stored ones: the scan's new findings are exactly the findings in Code security → Findings with *Findings of scan*, *Only new*. The answer for a typical report comes back in well under 2 seconds.

Make curl fail the build#

Add gate=fail. When the gate fails, the answer is HTTP 409 with the same body plus error.code: gate_failed, so curl --fail-with-body exits non-zero without any JSON tool. The scan is stored either way.

FAILED=0
curl -sS --fail-with-body -X POST "$LOGTHREAD_URL/api/scans" \
  --url-query "service=checkout-api" --url-query "kind=secrets" --url-query "tool=gitleaks" \
  --url-query "branch=$BRANCH" --url-query "commit=$COMMIT" \
  --url-query "fail_on=high" --url-query "gate=fail" \
  -H "Authorization: Bearer $LOGTHREAD_API_KEY" -H "Content-Type: application/octet-stream" \
  --data-binary @gitleaks.sarif || FAILED=1
# ... one upload per report ...
exit $FAILED

Upload every report first and fail at the end, so one failing tool does not hide the others' results. The pipeline files from Code security → Code scans in CI do exactly this (see Scan your code in CI).

Per CI system#

The guided setup writes the whole file. What each one uses:

CIBranch and commitWhere the key goes
GitHub Actionsgithub.head_ref or github.ref_name, github.shaRepository secret LOGTHREAD_API_KEY
GitLab CICI_COMMIT_REF_NAME, CI_COMMIT_SHA (Docker-in-Docker for the scanner images)Masked CI/CD variable LOGTHREAD_API_KEY
Azure DevOpsSystem.PullRequest.SourceBranch or Build.SourceBranch, Build.SourceVersionSecret pipeline variable LOGTHREAD_API_KEY
JenkinsBRANCH_NAME or GIT_BRANCH, GIT_COMMITSecret text credential logthread-api-key

Uploads need curl 7.87 or later (for --url-query), which the hosted runners of all four have.

Troubleshooting#

  • "First scan of this service, branch and tool" on every run: the tool or branch differs between runs. Pass the same tool= each time, and the branch name without refs/heads/.
  • Everything is new on a pull request: the base branch has no full scan yet. Run the pipeline on main once, or pass base_branch=.
  • kind_required: the tool scans several kinds (Trivy). Add kind=.
  • scan_quota: the plan's uploads per 24 hours are used. Merge reports per tool, or scan pull requests with partial=true and only changed files.

See also Send scan results to Logthread.