fix(wechat): enforce current-turn image paths in page delivery
Memind CI / Test, build, and release guards (push) Successful in 6m58s

Materialize wechat-mp uploads into dated public/images paths during vision
preprocessing and fail closed when delivered HTML references stale workspace
images instead of the current turn allowlist.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-08-27 12:54:46 +08:00
parent aecde46ff6
commit 760a1760ae
7 changed files with 442 additions and 9 deletions
+34
View File
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { verifyHtmlImageSourcesAllowed } from '../../chat-image-materialize.mjs';
const STUB_MARKERS = ['临时补出', '服务号兜底', '服务号自动补出简版页面'];
@@ -106,3 +107,36 @@ export function verifyPageArtifactContent(artifact, { minBytes = 512, publishDir
}
return { ok: true, reason: null };
}
export function verifyPageArtifactImageSources(
artifact,
{
publishDir = '',
allowedImageEmbedKeys = null,
} = {},
) {
const allowed = allowedImageEmbedKeys instanceof Set
? allowedImageEmbedKeys
: Array.isArray(allowedImageEmbedKeys)
? new Set(allowedImageEmbedKeys)
: null;
if (!allowed || allowed.size === 0) {
return { ok: true, reason: null, offendingKeys: [] };
}
const localPath = resolveArtifactLocalPath(artifact, publishDir);
if (!localPath) {
return { ok: false, reason: 'missing_file', offendingKeys: [] };
}
let content = '';
try {
content = fs.readFileSync(localPath, 'utf8');
} catch {
return { ok: false, reason: 'missing_file', offendingKeys: [] };
}
const verification = verifyHtmlImageSourcesAllowed(content, allowed);
return {
ok: verification.ok,
reason: verification.reason,
offendingKeys: verification.offendingKeys ?? [],
};
}