Post Corgea findings to Bitbucket Server pull requests from the pipeline script - #168
Closed
Ibrahimrahhal wants to merge 1 commit into
Closed
Post Corgea findings to Bitbucket Server pull requests from the pipeline script#168Ibrahimrahhal wants to merge 1 commit into
Ibrahimrahhal wants to merge 1 commit into
Conversation
The Fortify upload script customers run in CI now has a step that posts each finding to the Bitbucket Server / Data Center pull request it belongs to: valid findings with an applicable suggestion block, and Corgea's auto-triaged false positives as such, with the reasoning. The Corgea side is unchanged and still goes through the CLI; all the Bitbucket work lives in the script. Co-authored-by: ibrahim <ibrahim@corgea.com>
Ibrahimrahhal
deleted the
cursor/bitbucket-server-pr-comments-script-160d
branch
September 7, 2026 13:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
upload_fpr_and_report.shscript we gave the customer (upload a Fortify.fpr, wait, print the findings) now has one more step: it posts those findings to the Bitbucket Server / Data Center pull request as review comments. The script lives in the repo for the first time, underscripts/pipeline/, so the version we hand out is the version we can review.No CLI code changed. The Corgea side still shells out to
corgea upload,corgea wait,corgea lsandcorgea inspectexactly as before; everything Bitbucket is in the script, and the two existing modes behave identically when theBITBUCKET_*variables are not set.What it posts
Comment shape follows the doghouse convention, adapted to a platform with no
<details>element: Bitbucket Server collapses long comments behind "Show more", so the whole point goes on the first line and the explanation, fix and suggestion come after it.🔴 SQL Injection (Critical · 🔒 Security) — <one-line summary> [View in Corgea ↗], then the issue explanation, the fix explanation, and the fix.✅ False positive — Fortify flagged X here, but Corgea's triage found it is not exploitable: <reason>, then the full reasoning and what the scanner reported.A Corgea fix becomes an applicable
```suggestionblock, so the reviewer applies it from the PR. That only happens when the patch is a single contiguous change and every line it would replace is still in the diff holding the code the patch was computed against — the same guardreject_apply_mismatchgives us in doghouse. Otherwise the fix is shown as a```diffblock. Multi-line suggestions usemultilineMarker+multilineSpanso Apply replaces the whole span rather than the first line (Bitbucket DC 9.3+).Bitbucket API notes
Written against the v1004 (Data Center 10.4) REST API the customer runs:
POST /rest/api/1.0/projects/{key}/repos/{slug}/pull-requests/{id}/commentswith anEFFECTIVE-diff anchor,GET .../changesandGET .../diff/{path}to decide where a finding can be anchored, andGET .../activitiesto recognize comments an earlier run already posted (every comment carries acorgea-issue: <id>marker, so re-runs do not duplicate).Findings whose file the PR does not touch are counted in the summary and otherwise skipped (
POST_OUTSIDE_DIFF=1posts them as plain PR comments). Fortify's build-machine paths are mapped onto repo paths by suffix, withSTRIP_PATH_PREFIXas the explicit override. Credentials go into a0600curl config file rather than the command line, so they stay out of the build agent's process list. Any Bitbucket failure warns and leaves the console report and exit code untouched.Testing
Ran the script end to end against a stub Bitbucket DC server and a stub
corgeaCLI, covering: a fix that becomes a multi-line suggestion (anchorline: 8,multilineMarker.startLine: 7,multilineSpan: 7-8), a false positive, a multi-hunk fix falling back to a diff block, a fix whose patch no longer matches the file being rejected as a suggestion, a finding outside the diff, PR auto-detection from the branch, a re-run posting nothing, absolute Fortify paths resolving to repo paths, everyPOST_*toggle,DRY_RUN, and the 404 / unreachable-server paths.shellcheck -S styleis clean.Both
--report-onlyand the upload path were exercised; neither changed behavior.