Fix structured IPC envelope leakage

Normalize EJClaw structured send_message envelopes, preserve attachments, unwrap stored room payloads, and add regression tests.
This commit is contained in:
Eyejoker
2026-04-28 01:35:26 +09:00
committed by GitHub
parent 20e1a1e5e1
commit 8bb77ffaa3
11 changed files with 291 additions and 14 deletions

View File

@@ -12,6 +12,7 @@ const ONE_PIXEL_PNG = Buffer.from(
);
const cleanupDirs: string[] = [];
const cleanupFiles: string[] = [];
function makeTempDir(baseDir: string, prefix: string): string {
const dir = fs.mkdtempSync(path.join(baseDir, prefix));
@@ -33,6 +34,9 @@ afterEach(() => {
for (const dir of cleanupDirs.splice(0)) {
fs.rmSync(dir, { force: true, recursive: true });
}
for (const file of cleanupFiles.splice(0)) {
fs.rmSync(file, { force: true });
}
});
describe('validateOutboundAttachments', () => {
@@ -57,6 +61,31 @@ describe('validateOutboundAttachments', () => {
]);
});
it('accepts direct EJClaw screenshot files under the temp directory', () => {
const imagePath = path.join(
os.tmpdir(),
`ejclaw-room-mobile-list-${Date.now()}.png`,
);
fs.writeFileSync(imagePath, ONE_PIXEL_PNG);
cleanupFiles.push(imagePath);
const result = validateOutboundAttachments([
{
path: imagePath,
name: 'room-list.png',
mime: 'image/png',
},
]);
expect(result.rejected).toEqual([]);
expect(result.files).toEqual([
{
attachment: fs.realpathSync(imagePath),
name: 'room-list.png',
},
]);
});
it('requires workspace paths to be explicitly allowlisted', () => {
const dir = makeTempDir(process.cwd(), '.ejclaw-attachment-');
const imagePath = writeFile(dir, 'workspace-shot.png', ONE_PIXEL_PNG);