fix(typert): validate and mount remote contributions safely
This commit is contained in:
@@ -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`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user