Skip to content

feat(gocd): Add generic GoCD plugin with host egress auth - #1570

Open
sentry-junior[bot] wants to merge 1 commit into
mainfrom
feat/gocd-api-access
Open

feat(gocd): Add generic GoCD plugin with host egress auth#1570
sentry-junior[bot] wants to merge 1 commit into
mainfrom
feat/gocd-api-access

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Adds host-agnostic @sentry/junior-gocd with read-only pipeline history.

Design

  • tools call GoCD through ctx.egress.fetch
  • host supplies baseUrl / GOCD_URL
  • default path: static apiHeaders with Authorization: bearer ${GOCD_ACCESS_TOKEN}
  • advanced path: host passes hooks.grantForEgress + hooks.issueCredential for extra headers (for example IAP Proxy-Authorization)
  • no Sentry deploy host defaults, service accounts, or Google auth deps in this package

API contract

Checked against GoCD 25.2.0:

  • GET /go/api/pipelines/:name/history
  • Accept: application/vnd.go.cd.v1+json
  • page_size clamped to 10..100

Follow-up

Sentry IAP/WIF wiring and deploy topology skill live in a junior-prod host PR after this package publishes.

Requested by Joshua Li.

--

View Junior Session [Sentry]

@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview Aug 14, 2026 7:41pm

Request Review

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown

Dashboard visual evidence

No matching dashboard scenarios for this diff.

Add @sentry/junior-gocd as a host-agnostic read-only GoCD package.
Tools call through ctx.egress.fetch. Hosts supply base URL and either
static bearer apiHeaders or grantForEgress/issueCredential hooks.
Keep Sentry deploy topology and IAP defaults out of the OSS package.

Co-Authored-By: Joshua Li <joshua.li@sentry.io>
@sentry-junior
sentry-junior Bot force-pushed the feat/gocd-api-access branch from 9e14cdf to c8b9f07 Compare August 14, 2026 19:40
@sentry-junior sentry-junior Bot changed the title feat(gocd): Add read-only API access scaffolding feat(gocd): Add generic GoCD plugin with host egress auth Aug 14, 2026
@joshuarli
joshuarli requested a review from dcramer August 14, 2026 19:46
@joshuarli
joshuarli marked this pull request as ready for review August 14, 2026 19:46
@github-actions github-actions Bot added the risk: high PR risk score: high label Aug 14, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c8b9f07. Configure here.

throw new Error("GoCD base URL must use https");
}
return url.host;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Egress domains include non-default ports

High Severity

hostFromBaseUrl returns url.host, so a GoCD origin with a non-default HTTPS port becomes a domain like gocd.example.com:8154. Junior egress matches manifest.domains against URL.hostname, which never includes the port. Default GoCD (:8154) therefore fails domain ownership and never injects auth headers.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c8b9f07. Configure here.

Comment on lines +64 to +65
throw new Error(
"GoCD base URL is required. Pass baseUrl, configure gocdPlugin({ baseUrl }), or set GOCD_URL.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolveGocdTarget skips base URL validation when options.host is set

When options.host is provided, hostFromBaseUrl is never called, so the https protocol check and URL validation it enforces are bypassed for the resolved baseUrl. This allows http:// URLs or invalid strings from plugin options or GOCD_URL to reach new Request or the egress fetch, violating the package's explicit https requirement.

Evidence
  • resolveGocdTarget resolves host as input.options?.host ?? hostFromBaseUrl(baseUrl) on line 68.
  • When options.host is truthy, hostFromBaseUrl is short-circuited, so its new URL parse and url.protocol !== "https:" checks never run on baseUrl.
  • This allows an http:// or malformed baseUrl from options.baseUrl or GOCD_URL to proceed. An http:// baseUrl reaches ctx.egress.fetch via new Request; an invalid string crashes there with a TypeError.
  • input.baseUrl is validated by Zod .url(), but that still accepts http:// schemes and does not enforce https.
  • Tests assert hostFromBaseUrl rejects http://, yet no guard validates baseUrl independently when options.host overrides host extraction.

Identified by Warden · code-review · FC8-K53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants