Skip to content

fix(cli): score cookie and composed auth by credential attachment - #5340

Merged
mergify[bot] merged 7 commits into
mainfrom
tmchow/score-cookie-composed-auth-ed1c
Nov 5, 2026
Merged

mergify[bot] merged 7 commits into
mainfrom
tmchow/score-cookie-composed-auth-ed1c

Conversation

@tmchow

@tmchow tmchow commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Intent

Issue: #4327

Closes #4327

auth_protocol scored working cookie and composed printed CLIs at 2/10. The previous check looked for a Header.Set("<Name>") string. Jar-only cookie clients do not emit that. New seeds a cookie jar from cfg.CookieCredential() and passes that jar to newHTTPClient. Composed auth and header-borne cookie auth stamp authHeader on the expected header. OpenAPI apiKey in: cookie sends the credential with AddCookie.

Approach

For an apiKey scheme carried in a cookie, attachment credit requires one of the shapes client.go.tmpl emits:

  • Jar-only cookie auth, when the scheme header name is Cookie: inside New, a SeedCookieJar* call that takes cfg.CookieCredential(), and that same jar identifier passed to newHTTPClient. A seeded jar does not stand in for Authorization or any other header.
  • Header-borne cookie auth and composed auth: Header.Set or Header.Add of the expected header with the authHeader identifier. An empty composed header is already Authorization.
  • OpenAPI apiKey in cookie: AddCookie of &http.Cookie{Name: "<expected name>", Value: authHeader}.

The check parses client.go and matches those calls. It does not follow control flow. A dead call, a later Header.Del, or a hand-written client that uses a different shape is not recognized. Bearer and api-key scoring have the same exposure: they match an emitted literal. Hand-written clients that miss these shapes stay on the low side.

apiKey cookie schemes are still scored from the declared type before scheme-name hints, so a key such as bearerSession stays on this path. Internal cookie and composed specs still keep the header the client stamps.

Scope

Primary area: scorer (auth_protocol)

Why this belongs in this repo: the false 2/10 is in the Printing Press scorecard. The generator already emits working cookie and composed clients.

Left out of scope: verify --env-var live-mode selection (already fixed in #4606) and path_validity.

Risk

auth_protocol rises for cookie and composed CLIs that match an emitted attachment shape, and stays low when they do not. No template, manifest, MCP, or command-output change.

Output Contract

N/A. Generator templates and emitted files are unchanged. Regression tests score real Generate() output for cookie, composed, header-carried cookie, and OpenAPI apiKey in: cookie, compile each pristine module, then neuter that output.

Verification

  • go build ./... passed.
  • go vet ./... passed.
  • golangci-lint run ./internal/pipeline/ (v2.11.4) reported 0 issues.
  • go test -count=1 -timeout 900s ./internal/pipeline/... passed.
  • Goldens were not regenerated. Templates and emitted files are unchanged, and non-cookie scoring is unchanged.

AI / Automation Disclosure

  • Fully automated: generated and submitted without human review for this specific change
Open in Web Open in Cursor 

Cookie and composed clients put credentials on the jar or on the
request that is Do'd, not in a Header.Set("Cookie") string.
auth_protocol now credits that wiring and still rejects lookalikes.

Closes #4327

Co-authored-by: Trevin Chow <tmchow@users.noreply.github.com>
@mergify

mergify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 2 merge protections satisfied — ready to merge.

Show 2 satisfied protections

🟢 require-ready-label-and-ci

  • #changes-requested-reviews-by = 0
  • #review-threads-unresolved = 0
  • check-success = build-and-test
  • check-success = generated-test
  • check-success = go-lint
  • check-success = golden
  • check-success = pr-title
  • check-success = test
  • any of:
    • label = ready-to-merge
    • all of:
      • head = release-please--branches--main
      • title ~= ^chore\(main\): release
  • any of:
    • -files ~= ^(\.github/workflows/|\.github/scripts/|scripts/|\.github/CODEOWNERS$)
    • author = tmchow
    • approved-reviews-by = mvanhorn
    • approved-reviews-by = tmchow
    • author = mvanhorn
  • any of:
    • check-success = Greptile Review
    • label = queued
    • check-neutral = Greptile Review
    • check-skipped = Greptile Review
    • head ~= ^mergify/merge-queue/
    • all of:
      • head = release-please--branches--main
      • title ~= ^chore\(main\): release

🟢 🚦 Auto-queue

When all merge protections are satisfied and these conditions match, this pull request will be queued automatically.

  • label = ready-to-merge

@greptile-apps

greptile-apps Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 3/5

[Medium impact] The change affects auth scoring in the pipeline's scorecard.

Fix the two false auth passes before merging.

Fix All in CodexFindings

  1. P1 Missing cookies still pass ▶
  2. P1 Unused auth code passes ▶

Summary

The PR adds cookie and composed-auth scoring and preserves the expected header from internal specs.

  • The auth score credits cookie and composed credentials the client sends.

Reviews (7) · Last reviewed commit: "fix(cli): score cookie auth from emitted..." · Reviewed by Greptile

Comment thread internal/pipeline/scorecard.go Resolved
Jar credit applies only when the scheme sends its credential as cookies.
Header overwrites and deletions, returned Do calls, scoped request
aliases, and the declared apiKey cookie type now decide the score.

Co-authored-by: Trevin Chow <tmchow@users.noreply.github.com>
walkStmt applied both sides of an if, and every switch case, to one
request state, so a later Del cleared a credential a sibling path still
sent. Fork each branch and join only the paths that can reach Do.

Co-authored-by: Trevin Chow <tmchow@users.noreply.github.com>
Joining branch states into one binding let a later delete through an
alias clear a request that alias does not point at on every path. break
was also ignored, so a switch case that returns on another branch never
reached Do. Keep each path's aliases, and carry break out of switch,
select, and loop.

Co-authored-by: Trevin Chow <tmchow@users.noreply.github.com>
Returned paths were marked dead and then revived after a loop, and a
fallthrough replaced a switch case's direct entry. Paths now end on
return, panic, and goto. break and continue target the enclosing
construct. Each case is entered directly and by fallthrough. A loop
joins its breaks with the zero-iteration and one-pass states only when
a condition or range can end it.

Co-authored-by: Trevin Chow <tmchow@users.noreply.github.com>
cursoragent and others added 2 commits November 4, 2026 19:38
A case-local request stayed in scope across fallthrough, so a later
delete or Do hit the shadow instead of the outer request. Each case
now has its own block, dropped before the path is carried forward.
Only an unshadowed bare panic ends a path; selectors and local,
parameter, or package bindings do not.

Co-authored-by: Trevin Chow <tmchow@users.noreply.github.com>
auth_protocol credits cookie and composed attachment when client.go
matches a shape the generator emits, instead of walking control flow.

Co-authored-by: Trevin Chow <tmchow@users.noreply.github.com>
@tmchow tmchow added the ready-to-merge Queue when Mergify passes; scripts/.github PRs also need Approve from tmchow/mvanhorn. label Nov 5, 2026
@mergify mergify Bot added the queued PR is in the Mergify merge queue label Nov 5, 2026
@mergify
mergify Bot merged commit d8124e7 into main Nov 5, 2026
53 of 56 checks passed
@mergify
mergify Bot deleted the tmchow/score-cookie-composed-auth-ed1c branch November 5, 2026 05:54
@mergify

mergify Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

✅ Merged into main as d8124e7 at 05:54 UTC

21 min in the queue, 21 min of it CI.

So far

13 merge conditions met
  • check-success = build-and-test · required by Merge Protections rule require-ready-label-and-ci
  • check-success = generated-test · required by Merge Protections rule require-ready-label-and-ci
  • check-success = go-lint · required by Merge Protections rule require-ready-label-and-ci
  • check-success = golden · required by Merge Protections rule require-ready-label-and-ci
  • check-success = test · required by Merge Protections rule require-ready-label-and-ci
  • github-review-approved · required by GitHub branch protection
  • #changes-requested-reviews-by = 0 · required by Merge Protections rule require-ready-label-and-ci
  • #review-threads-unresolved = 0 · required by Merge Protections rule require-ready-label-and-ci
  • check-success = pr-title · required by Merge Protections rule require-ready-label-and-ci
  • any of · required by Merge Protections rule require-ready-label-and-ci:
    • label = ready-to-merge
    • all of:
      • head = release-please--branches--main
      • title ~= ^chore\(main\): release
  • any of · required by Merge Protections rule require-ready-label-and-ci:
    • -files ~= ^(\.github/workflows/|\.github/scripts/|scripts/|\.github/CODEOWNERS$)
    • author = tmchow
    • approved-reviews-by = mvanhorn
    • approved-reviews-by = tmchow
    • author = mvanhorn
  • any of · required by Merge Protections rule require-ready-label-and-ci:
    • label = queued
    • check-neutral = Greptile Review
    • check-skipped = Greptile Review
    • check-success = Greptile Review
    • head ~= ^mergify/merge-queue/
    • all of:
      • head = release-please--branches--main
      • title ~= ^chore\(main\): release
  • any of · required by GitHub branch protection:
    • check-neutral = Mergify Merge Protections
    • check-skipped = Mergify Merge Protections
    • check-success = Mergify Merge Protections

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot removed the queued PR is in the Mergify merge queue label Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Queue when Mergify passes; scripts/.github PRs also need Approve from tmchow/mvanhorn.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P2] Cookie and composed auth cannot be scored: verify --env-var stays in mock mode and auth_protocol greps for Header.Set

2 participants