Files
tkmind_go/ui/h5/mindspace-content-scan.test.mjs
john 4e21ca937a
Deploy Documentation / deploy (push) Has been cancelled
Canary / Prepare Version (push) Has been cancelled
Canary / build-cli (push) Has been cancelled
Canary / Upload Install Script (push) Has been cancelled
Canary / bundle-desktop (push) Has been cancelled
Canary / bundle-desktop-intel (push) Has been cancelled
Canary / bundle-desktop-linux (push) Has been cancelled
Canary / bundle-desktop-windows (push) Has been cancelled
Canary / bundle-desktop-windows-cuda (push) Has been cancelled
Canary / Release (push) Has been cancelled
Unused Dependencies / machete (push) Has been cancelled
CI / changes (push) Has been cancelled
CI / Check Rust Code Format (push) Has been cancelled
CI / Build and Test Rust Project (push) Has been cancelled
CI / Build Rust Project on Windows (push) Has been cancelled
CI / Check MSRV (push) Has been cancelled
CI / Lint Rust Code (push) Has been cancelled
CI / Check Generated Schemas are Up-to-Date (push) Has been cancelled
CI / Test and Lint Electron Desktop App (push) Has been cancelled
CI / H5 Plaza Tests and Build (push) Has been cancelled
Live Provider Tests / check-fork (push) Has been cancelled
Live Provider Tests / changes (push) Has been cancelled
Live Provider Tests / Build Binary (push) Has been cancelled
Live Provider Tests / Smoke Tests (push) Has been cancelled
Live Provider Tests / Smoke Tests (Code Execution) (push) Has been cancelled
Live Provider Tests / Compaction Tests (push) Has been cancelled
Live Provider Tests / goose server HTTP integration tests (push) Has been cancelled
Publish Ask AI Bot Docker Image / docker (push) Has been cancelled
Publish Docker Image / docker (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Add TKMind platform extensions, H5/MindSpace stack, and deployment tooling.
Fork goose with custom MCP widgets, platform extensions (aider, git, web, search),
MindSpace H5 backend/frontend, Plaza/Ops UIs, and deploy scripts for tkmind.cn.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-14 21:30:20 +08:00

49 lines
1.8 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { redactContent, scanContent } from './mindspace-content-scan.mjs';
test('scanContent warns on phone numbers', () => {
const result = scanContent('联系电话 13800138000');
assert.equal(result.status, 'warned');
assert.equal(result.allowed, true);
assert.equal(result.findings[0].type, 'phone');
});
test('scanContent ignores trusted google font hosts', () => {
const result = scanContent(
"@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC&display=swap');",
);
assert.equal(result.findings.length, 0);
assert.equal(result.allowed, true);
});
test('scanContent blocks id cards', () => {
const result = scanContent('身份证 11010119900307888X');
assert.equal(result.status, 'blocked');
assert.equal(result.allowed, false);
});
test('scanContent blocks html active content and private references', () => {
const result = scanContent(
'<script>alert(1)</script><a href="javascript:alert(1)">x</a><img src="/api/mindspace/v1/assets/abc/preview">',
{ format: 'html' },
);
assert.equal(result.allowed, false);
assert.deepEqual(
result.findings.map((finding) => finding.type),
['html_script', 'html_javascript_url', 'private_resource_reference'],
);
});
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',
{ format: 'html' },
);
assert.equal(result.changed, true);
assert.doesNotMatch(result.content, /13800138000/);
assert.doesNotMatch(result.content, /john@example.com/);
assert.doesNotMatch(result.content, /<script>/);
assert.doesNotMatch(result.content, /sk_test_1234567890abcdef/);
});