-
Notifications
You must be signed in to change notification settings - Fork 9
feat(plugins): api.reservePath — claim protocol-pinned paths (#602) #607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+469
−0
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7422c7f
feat(plugins): api.reservePath — claim protocol-pinned paths (#602)
melvincarvalho 8ff4f9e
review: validate reservePath after normalization — '//' was a WAC wipe
melvincarvalho 25c109f
review: reservePath collision by shape, and tighten param-segment match
melvincarvalho b42c942
review: type-tag reservationKey segments so params can't alias literals
melvincarvalho 31c99b4
review: param class excludes '?'; method-gate before regex
melvincarvalho 8d279b6
review: idempotent same-plugin re-claims — no duplicate matchers
melvincarvalho 9a2b41e
review: literal reservations are read-only by default too (WAC-safe)
melvincarvalho 82743b0
review: fix stale 'all methods' in reservePath example/comment
melvincarvalho 95091a2
review: reject '?' and '#' in reservePath — a reservation is a pathname
melvincarvalho 48bdbf2
review: validate reservePath opts.methods; tolerate null opts
melvincarvalho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,6 +124,10 @@ export function createServer(options = {}) { | |
| // appPaths. The WAC hook reads the array per request, so pushes made | ||
| // during plugin activation are honored. | ||
| const pluginEntries = Array.isArray(options.plugins) ? options.plugins : []; | ||
| // Parameterized reservations from api.reservePath (#602): compiled | ||
| // matchers for path shapes like /:user/did.json that literal appPaths | ||
| // prefixes cannot express. Same per-request read as appPaths. | ||
| const appPathPatterns = []; | ||
| // ActivityPub federation is OFF by default | ||
| const activitypubEnabled = options.activitypub ?? false; | ||
| const apUsername = options.apUsername ?? 'me'; | ||
|
|
@@ -426,6 +430,7 @@ export function createServer(options = {}) { | |
| const { loadPlugins } = await import('./plugins.js'); | ||
| await loadPlugins(instance, pluginEntries, { | ||
| appPaths, | ||
| appPathPatterns, | ||
| root: options.root || process.env.DATA_ROOT || './data', | ||
| log: fastify.log, | ||
| // api.serverInfo inputs (#601). ?? keeps an explicit port 0 — | ||
|
|
@@ -759,6 +764,7 @@ export function createServer(options = {}) { | |
| (terminalEnabled && (request.url === '/.terminal' || request.url.startsWith('/.terminal?'))) || | ||
| (tunnelEnabled && (request.url === tunnelPath || request.url.startsWith(tunnelPath + '?') || request.url.startsWith('/tunnel/'))) || | ||
| appPaths.some(p => request.url === p || request.url.startsWith(p + '/') || request.url.startsWith(p + '?')) || | ||
| appPathPatterns.some(m => m.methods.has(request.method) && m.re.test(request.url)) || | ||
| mashlibPaths.some(p => request.url === p || request.url.startsWith(p + '.'))) { | ||
|
Comment on lines
764
to
768
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both fixed in 31c99b4: param class is now [^/?]+ so a query containing '/' no longer breaks shape matching (test pins /alice/did.json?redirect=/a/b), and the WAC-skip check tests methods before the regex so write traffic skips it entirely. 1045/1045. |
||
| return; | ||
| } | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 95091a2 — reservePath now rejects '?' and '#' at validation (a reservation is a pathname; a query would escape into the matcher and a fragment never reaches request.url). Test boots a '/xrpc?x=1' claimant and asserts the refusal. 1048/1048.