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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user