-
Notifications
You must be signed in to change notification settings - Fork 37
chore(gastown): promote gastown-staging to main #2974
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
Open
jrf0110
wants to merge
13
commits into
main
Choose a base branch
from
gastown-staging
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
21a14d0
fix(gastown): point dev GIT_TOKEN_SERVICE binding at git-token-servic…
jrf0110 c532f40
fix(gastown): push new model onto resumed mayor session on hot-swap (…
jrf0110 db58406
fix(gastown): stop reconciler log spam from orphaned bead_cancelled e…
jrf0110 47e95a8
feat(gastown-container): add crash visibility + per-agent start mutex…
jrf0110 0ebac0f
chore(gastown): fix format and lint CI failures (#3072)
jrf0110 e20d04f
chore(gastown): drop unused promise param from unhandledRejection han…
jrf0110 62e1f13
feat(gastown): add proactive idle-container stop in TownDO alarm (#3113)
jrf0110 4793373
fix(onboarding): redirect back to onboarding after GitHub app install…
jrf0110 9ca3034
feat(gastown): speed up mayor session startup (#3122)
jrf0110 c5d416d
feat(gastown): stop convoy landing-MR respawn loop when PR awaiting a…
jrf0110 4bb228a
chore(gastown): merge main into gastown-staging (resolve callback rou…
9838ff6
Merge remote-tracking branch 'origin/main' into fix/staging-merge-con…
6ea2930
chore(gastown): fix CI failures after staging merge from main
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
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
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
110 changes: 110 additions & 0 deletions
110
apps/web/src/lib/integrations/validate-return-path.test.ts
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 |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| import { validateReturnPath, parseStateReturn } from './validate-return-path'; | ||
|
|
||
| describe('validateReturnPath', () => { | ||
| it('accepts a simple internal path', () => { | ||
| expect(validateReturnPath('/gastown/onboarding')).toBe('/gastown/onboarding'); | ||
| }); | ||
|
|
||
| it('accepts a path with query params', () => { | ||
| expect(validateReturnPath('/gastown/onboarding?step=repo&orgId=123')).toBe( | ||
| '/gastown/onboarding?step=repo&orgId=123' | ||
| ); | ||
| }); | ||
|
|
||
| it('rejects protocol-relative URLs', () => { | ||
| expect(validateReturnPath('//evil.com')).toBeNull(); | ||
| }); | ||
|
|
||
| it('rejects absolute URLs', () => { | ||
| expect(validateReturnPath('https://evil.com')).toBeNull(); | ||
| }); | ||
|
|
||
| it('rejects backslash-prefixed paths', () => { | ||
| expect(validateReturnPath('/\\evil.com')).toBeNull(); | ||
| }); | ||
|
|
||
| it('rejects paths with carriage return', () => { | ||
| expect(validateReturnPath('/foo\rbar')).toBeNull(); | ||
| }); | ||
|
|
||
| it('rejects paths with newline', () => { | ||
| expect(validateReturnPath('/foo\nbar')).toBeNull(); | ||
| }); | ||
|
|
||
| it('rejects paths without leading slash', () => { | ||
| expect(validateReturnPath('foo/bar')).toBeNull(); | ||
| }); | ||
|
|
||
| it('rejects empty string', () => { | ||
| expect(validateReturnPath('')).toBeNull(); | ||
| }); | ||
|
|
||
| it('accepts root path', () => { | ||
| expect(validateReturnPath('/')).toBe('/'); | ||
| }); | ||
|
|
||
| it('rejects triple-slash paths', () => { | ||
| expect(validateReturnPath('///foo')).toBeNull(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('parseStateReturn', () => { | ||
| it('parses state with return suffix', () => { | ||
| const encoded = encodeURIComponent('/gastown/onboarding?step=repo'); | ||
| const result = parseStateReturn(`user_abc|return=${encoded}`); | ||
| expect(result).toEqual({ | ||
| ownerToken: 'user_abc', | ||
| returnTo: '/gastown/onboarding?step=repo', | ||
| }); | ||
| }); | ||
|
|
||
| it('parses org state with return suffix', () => { | ||
| const encoded = encodeURIComponent('/gastown/onboarding?step=repo&orgId=123'); | ||
| const result = parseStateReturn(`org_123|return=${encoded}`); | ||
| expect(result).toEqual({ | ||
| ownerToken: 'org_123', | ||
| returnTo: '/gastown/onboarding?step=repo&orgId=123', | ||
| }); | ||
| }); | ||
|
|
||
| it('parses state without return suffix (backwards compat)', () => { | ||
| const result = parseStateReturn('user_abc'); | ||
| expect(result).toEqual({ | ||
| ownerToken: 'user_abc', | ||
| returnTo: null, | ||
| }); | ||
| }); | ||
|
|
||
| it('parses org state without return suffix', () => { | ||
| const result = parseStateReturn('org_123'); | ||
| expect(result).toEqual({ | ||
| ownerToken: 'org_123', | ||
| returnTo: null, | ||
| }); | ||
| }); | ||
|
|
||
| it('returns null returnTo when return path is invalid', () => { | ||
| const encoded = encodeURIComponent('//evil.com'); | ||
| const result = parseStateReturn(`user_abc|return=${encoded}`); | ||
| expect(result).toEqual({ | ||
| ownerToken: 'user_abc', | ||
| returnTo: null, | ||
| }); | ||
| }); | ||
|
|
||
| it('handles null state', () => { | ||
| const result = parseStateReturn(null); | ||
| expect(result).toEqual({ | ||
| ownerToken: '', | ||
| returnTo: null, | ||
| }); | ||
| }); | ||
|
|
||
| it('returns null returnTo when return suffix has malformed percent-encoding', () => { | ||
| const result = parseStateReturn('user_abc|return=%ZZ'); | ||
| expect(result).toEqual({ | ||
| ownerToken: 'user_abc', | ||
| returnTo: null, | ||
| }); | ||
| }); | ||
| }); |
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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| const RETURN_PATH_RE = /^\/(?![/\\])[^\r\n]*$/; | ||
|
|
||
| export function validateReturnPath(candidate: string): string | null { | ||
| if (!RETURN_PATH_RE.test(candidate) || candidate.startsWith('//')) { | ||
| return null; | ||
| } | ||
| return candidate; | ||
| } | ||
|
|
||
| export function parseStateReturn(rawState: string | null): { | ||
| ownerToken: string; | ||
| returnTo: string | null; | ||
| } { | ||
| let ownerToken = rawState ?? ''; | ||
| let returnTo: string | null = null; | ||
|
|
||
| if (rawState) { | ||
| const sepIdx = rawState.indexOf('|return='); | ||
| if (sepIdx !== -1) { | ||
| ownerToken = rawState.slice(0, sepIdx); | ||
| try { | ||
| const candidate = decodeURIComponent(rawState.slice(sepIdx + '|return='.length)); | ||
| returnTo = validateReturnPath(candidate); | ||
| } catch { | ||
| returnTo = null; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return { ownerToken, returnTo }; | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.