fix(typert): validate and mount remote contributions safely

This commit is contained in:
imccyu
2026-08-07 14:07:19 +08:00
parent 737c12935a
commit 2fe4a53557
9 changed files with 173 additions and 25 deletions

View File

@@ -600,7 +600,7 @@ function validateCodec(codec: InvocationDescriptor['result'], subject: string):
}
function validateWireName(subject: string, value: string): void {
if (!/^[A-Za-z0-9_$.-]+$/.test(value)) {
if (value === '.' || value === '..' || !/^[A-Za-z0-9_$.-]+$/.test(value)) {
throw new Error(`typert: invalid ${subject} "${value}" — must contain only RPC endpoint segment characters`)
}
}

View File

@@ -247,7 +247,7 @@ describe('TypertRegistry', () => {
})).toThrow('endpoint "goals/create" is already registered')
})
it.each(['create#v2', 'create goal'])('rejects untransportable invocation method %s', async (method) => {
it.each(['create#v2', 'create goal', '.', '..'])('rejects untransportable invocation method %s', async (method) => {
const ctx = await makeCtx()
expect(() => ctx.typert.remotes.register({
package: '@fixture/invalid-endpoint',