Repository navigation
fix(cli): score cookie and composed auth by credential attachment - #5340
Merged
Merged
Conversation
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>
Contributor
Merge Protections🟢 All 2 merge protections satisfied — ready to merge. Show 2 satisfied protections🟢 require-ready-label-and-ci
🟢 🚦 Auto-queueWhen all merge protections are satisfied and these conditions match, this pull request will be queued automatically.
|
Contributor
[Medium impact] The change affects auth scoring in the pipeline's scorecard. Fix the two false auth passes before merging.
|
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>
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>
Closed
59 of 96 tasks
Contributor
✅ Merged into
|
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.
Intent
Issue: #4327
Closes #4327
auth_protocolscored working cookie and composed printed CLIs at 2/10. The previous check looked for aHeader.Set("<Name>")string. Jar-only cookie clients do not emit that.Newseeds a cookie jar fromcfg.CookieCredential()and passes that jar tonewHTTPClient. Composed auth and header-borne cookie auth stampauthHeaderon the expected header. OpenAPIapiKeyin: cookiesends the credential withAddCookie.Approach
For an
apiKeyscheme carried in a cookie, attachment credit requires one of the shapesclient.go.tmplemits:Cookie: insideNew, aSeedCookieJar*call that takescfg.CookieCredential(), and that same jar identifier passed tonewHTTPClient. A seeded jar does not stand in forAuthorizationor any other header.Header.SetorHeader.Addof the expected header with theauthHeaderidentifier. An empty composed header is alreadyAuthorization.apiKeyin cookie:AddCookieof&http.Cookie{Name: "<expected name>", Value: authHeader}.The check parses
client.goand matches those calls. It does not follow control flow. A dead call, a laterHeader.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.apiKeycookie schemes are still scored from the declared type before scheme-name hints, so a key such asbearerSessionstays 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-varlive-mode selection (already fixed in #4606) andpath_validity.Risk
auth_protocolrises 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 OpenAPIapiKeyin: 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.AI / Automation Disclosure