fix: harden portfolio input boundary
This commit is contained in:
@@ -62,6 +62,22 @@ describe('production inputs', () => {
|
||||
it('resolves only an exact manifest asset ID to an encoded deterministic URL', () => {
|
||||
const manifest = parsePublicAssetManifest(JSON.parse(readFileSync(fixtureUrl('asset-manifest.valid.json'), 'utf8')));
|
||||
expect(assetUrl(manifest, 'selected-build-one')).toBe('/assets/selected-build-one.webp');
|
||||
expect(assetUrl(manifest, 'selected-build-one', '/assets/cards')).toBe('/assets/cards/selected-build-one.webp');
|
||||
expect(() => assetUrl(manifest, 'missing')).toThrow(/unknown asset/i);
|
||||
});
|
||||
|
||||
it('rejects asset URL base traversal and origin escapes', () => {
|
||||
const manifest = parsePublicAssetManifest(JSON.parse(readFileSync(fixtureUrl('asset-manifest.valid.json'), 'utf8')));
|
||||
for (const base of [
|
||||
'//cdn.example.test/assets/',
|
||||
'/assets/../private/',
|
||||
'/assets\\private/',
|
||||
'/assets/%2e%2e/private/',
|
||||
'/assets/%2fprivate/',
|
||||
'/assets/?query=1',
|
||||
'/assets/#fragment',
|
||||
]) {
|
||||
expect(() => assetUrl(manifest, 'selected-build-one', base)).toThrow(/asset url base/i);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user