Skip to content

Commit fbb5a4e

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(oracle-epm): reject malformed returned-link entries
1 parent 7840639 commit fbb5a4e

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

apps/sim/lib/internal/oracle-epm/client.server.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,31 @@ describe('Oracle EPM guarded client', () => {
435435
})
436436
})
437437

438+
it.each([null, undefined, 'invalid-link', 123, true, [], {}, { rel: 'download' }])(
439+
'rejects malformed returned-link entry %j with a safe error',
440+
(entry) => {
441+
const policy = routes.defineReturnedLinkPolicy({
442+
relation: 'download',
443+
method: 'GET',
444+
endpoint: getJob,
445+
preserveGatewayBasePath: true,
446+
})
447+
const client = createOracleEpmClient({
448+
instanceUrl: 'https://epm.example.com/gateway',
449+
accessToken: Buffer.from('u:p').toString('base64'),
450+
})
451+
452+
expect(() =>
453+
client.validateReturnedLink(
454+
policy,
455+
entry as unknown as Parameters<typeof client.validateReturnedLink>[1]
456+
)
457+
).toThrowError(expect.objectContaining({ name: 'OracleEpmError', category: 'invalid_input' }))
458+
expect(mockValidateUrl).not.toHaveBeenCalled()
459+
expect(mockSecureFetch).not.toHaveBeenCalled()
460+
}
461+
)
462+
438463
it.each(['download', 'Job Status'])(
439464
'keeps %s links opaque and client-owned',
440465
async (relation) => {

apps/sim/lib/internal/oracle-epm/client.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ export function createOracleEpmClient(input: {
551551
) {
552552
const policy = getOracleEpmReturnedLinkPolicy(policyValue)
553553
if (
554+
typeof link !== 'object' ||
555+
link === null ||
554556
link.rel !== policy.relation ||
555557
(link.method !== undefined && link.method !== policy.method) ||
556558
typeof link.href !== 'string' ||

0 commit comments

Comments
 (0)