fix(GOV-009): 封堵外部脚本边界绕过
This commit is contained in:
@@ -108,19 +108,25 @@ const value: Internal | undefined = undefined;
|
||||
assert.match(result.stderr, /IllegalView\.vue/);
|
||||
});
|
||||
|
||||
test('拒绝 Vue 外部 script src 绕过源码边界', async () => {
|
||||
const repositoryRoot = await createFixture();
|
||||
await writeFile(
|
||||
path.join(repositoryRoot, 'web/src/ExternalScript.vue'),
|
||||
`<script setup lang="ts" src="../../server/libs/internal.ts"></script>\n<template><main /></template>\n`,
|
||||
);
|
||||
for (const [name, scriptTag] of [
|
||||
['双引号', '<script lang="ts" src="../../server/libs/internal.ts">'],
|
||||
['单引号', "<script src='../../server/libs/internal.ts' lang='ts'>"],
|
||||
['无引号且属性换序', '<script lang=ts src=../../server/libs/internal.ts>'],
|
||||
]) {
|
||||
test(`拒绝 Vue 外部 script src 通过${name}绕过源码边界`, async () => {
|
||||
const repositoryRoot = await createFixture();
|
||||
await writeFile(
|
||||
path.join(repositoryRoot, 'web/src/ExternalScript.vue'),
|
||||
`${scriptTag}</script>\n<template><main /></template>\n`,
|
||||
);
|
||||
|
||||
const result = await runChecker(repositoryRoot);
|
||||
const result = await runChecker(repositoryRoot);
|
||||
|
||||
assert.equal(result.exitCode, 1);
|
||||
assert.match(result.stderr, /禁止使用外部 script src/);
|
||||
assert.match(result.stderr, /ExternalScript\.vue/);
|
||||
});
|
||||
assert.equal(result.exitCode, 1);
|
||||
assert.match(result.stderr, /禁止使用外部 script src/);
|
||||
assert.match(result.stderr, /ExternalScript\.vue/);
|
||||
});
|
||||
}
|
||||
|
||||
test('接受只消费公开 OpenAPI 类型的 Web 工程', async () => {
|
||||
const repositoryRoot = await createFixture();
|
||||
|
||||
Reference in New Issue
Block a user