Add page data delivery and publication guards

This commit is contained in:
john
2026-07-08 21:10:47 +08:00
parent 8d629e7a4e
commit eea14c1855
66 changed files with 3035 additions and 413 deletions
+16
View File
@@ -51,6 +51,22 @@ test('scanContent can allow active html as acknowledgeable publication warnings'
);
});
test('scanContent can allow interactive html forms as acknowledgeable warnings', () => {
const result = scanContent(
'<form id="survey"><input name="q1"></form><script src="/assets/page-data-client.js"></script>',
{ format: 'html', allowHtmlActiveContent: true },
);
assert.equal(result.status, 'warned');
assert.equal(result.allowed, true);
assert.deepEqual(
result.findings.map((finding) => [finding.type, finding.blocking]),
[
['html_script', false],
['html_form_action', false],
],
);
});
test('redactContent masks secrets and strips unsafe html', () => {
const result = redactContent(
'手机号 13800138000\n邮箱 john@example.com\n<script>alert(1)</script>\nkey=sk_test_1234567890abcdef',