Repository navigation
feat(codegen): signInPlace signs Basic, and fakeApi catches a signed token on another host - #643
Merged
Merged
Conversation
…token on another host WordPress application passwords sign in by HTTP Basic. signInPlace returned undefined for a basic scheme, so cli-core kept its own basicPlace and a CLI's fakeApi refused every correctly signed request with 401. - signInPlace returns Authorization: Basic <base64 of user:password> for a basic scheme, marked basic: true, so a caller can keep a token scheme first when a call offers both. Digest stays undefined. - fakeApi's leak check looks for each scheme's signed value too: a Basic header carries the token only in base64, so a request to another host slipped through before. cli-core then drops basicPlace and reads place.basic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… changelog says what callers must do From the review of #643: - SEC-1: the leak check looked for the whole header value, so base64 in a query string or under another prefix slipped through. It now looks for the bare base64 and its URL-encoded form, worked out only when a scheme is Basic. - BUG-1: the changelog said cli-core already reads place.basic. It now says what a caller must do, and what goes wrong until it does. - The test builds the header with Buffer, uses a non-ASCII user and a password with a colon, and adds a query leak. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leemour
added a commit
that referenced
this pull request
Nov 17, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
leemour
added a commit
that referenced
this pull request
Nov 17, 2026
Carries #642 (Attio: union samples, pattern samples, prefixItems, allOf of unions, upsert), #643 (Basic sign-in) and #644 (tracker nouns). Minor: the Unreleased section has Added and Changed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
leemour
added a commit
that referenced
this pull request
Nov 18, 2026
…ion keys from a field's value (#647) ## Task C3 of the content category, cli-base half: read a WordPress site's API from its own index, and give a publishing write a permission key, so the WordPress CLI's raw `api` group cannot publish past a profile that denies it. ## Why WordPress publishes no OpenAPI. And a key that only checks "is this flag true" cannot say "`status` is `publish`": an agent could publish with a plain `POST /wp/v2/posts`, whatever `posts.publish` says (RISK-2323 in the content-category plan). ## What - **`syncWpJson` / `readWpJson` / `wpJsonToOpenApi`.** One call, `GET /wp-json/?context=help`, returns every route with its arguments and its answer's schema. I checked on WordPress 6.9.4 that this schema equals what `OPTIONS` returns, for all 78 routes callable directly. So the snapshot is one file, not one `OPTIONS` call per route as the plan said. - The snapshot drops the site's name, address and links, and keeps provenance with the hash. - The converter writes OpenAPI 3.1, and the existing `adaptOpenApi` reads it. WordPress 6.9.4's `wp/v2` gives 152 operations (`getWpV2Posts`, `postWpV2PostsById`…), and the generated types, schemas and manifest compile. - GET reads and DELETE deletes, with `force` in the query. POST/PUT/PATCH becomes one POST write. - A collection read answers a list. - An array in the query travels comma-separated. Checked on WordPress: `include=1,5` returns both posts, while `include=1&include=5` returns only the last. - A route whose value may hold a slash (templates, plugins, fonts) is left out and listed. So is every namespace not offered. - A route still a pattern, two routes on one path, or an untyped argument stops generation unless `exclude` names it. - **`permissions.valueKeys`.** `{ key: "publish", field: "status", values: ["publish", "future"] }` gives `<group>.publish` to a write whose `status` enum lists those values, through refs and unions too. On WordPress 6.9.4 that covers posts, pages, media, blocks, navigation and menu items. - A field that defaults to such a value makes the key always apply. That's templates, template parts and new menu items, where leaving `status` out publishes. - A read that filters by the value, and a field without such an enum (a comment's `status`), get no key. - `OperationPermission.values` carries it, and the coverage page says "`status` is publish or future". - The plan put this in `overrides`. As a rule beside `deletingFlags`, one entry covers every post type. - `sha256` and `sortKeys` move to `snapshot.ts`. Discovery and GraphQL each had a copy. Not here: cli-core's runtime check of `values` (next PR, on this release); `wp-json` as a config `spec.kind` in cli-template (the WordPress pilot); paging: WordPress pages by headers, so `pagination: true` finds none yet. Basic sign-in in `fakeApi` was already in 0.117.0 (#643); a test here runs the generated WordPress manifest through it. ## Testing - `src/codegen/wp-json.test.ts` runs on an excerpt of WordPress 6.9.4's real index. The excerpt is in `test/fixtures/wp-json/`, with GPL notice. The tests cover: - ids and methods, and where each argument goes; - draft 4 quirks: `required` in both spellings, `bool`, untyped objects, `patternProperties`; - the omissions and the failures; - publish keys, including the default-publish case, refs, unions and reads; - `fakeApi` with an application password; - sync and read, including a password in the URL and a changed hash. - The full 6.9.4 snapshot was converted and its generated code compiled. Full suite: 1,272 tests. Typecheck, lint and docs check pass. - A fresh review found a bypass: templates and menu items default `status` to `publish`. It's fixed with the rest of that review's findings. `_method` / `X-HTTP-Method-Override` can't be sent, because cli-core's `api` group only takes declared parameters. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
The WordPress foundation in the CLI factory plan: WordPress application passwords sign in by HTTP Basic.
signInPlacereturnedundefinedfor abasicscheme, so:basicPlaceinservice-api-manifest.ts(cli-core #3094);fakeApicould not check Basic, and refused every correctly signed request with 401;fakeApi's leak check looked for the raw token only, and a Basic header carries it in base64, so the token sent to another host went unnoticed.What
signInPlacereturnsAuthorization: Basic <base64 of user:password>for abasicscheme and marks the placebasic: true. Digest staysundefined.fakeApialso looks for each scheme's signed value when it checks that the token did not go to another host.undefined. When it bumps to this version, it dropsbasicPlaceand readsplace.basic, so that a token scheme stays first when a call offers both.No overlap with #642: that PR changes
sampleOfinfake.ts(lines 232–280); this one changes the sign-in check (lines 360–410).Testing
fakeApitest: a Basic sign-in passes, a wrong password gets 401, and the Basic header sent to another host is refused. Without the change the first check fails with 401, and without the leak fix the third passes through.🤖 Generated with Claude Code