Fix runtime image attachment paths

Allow nested /tmp generated images and per-room runtime workspace attachments after realpath/image validation.
This commit is contained in:
Eyejoker
2026-05-02 22:02:13 +09:00
committed by GitHub
parent 6ea4ec5b68
commit 4859c58f48
8 changed files with 66 additions and 40 deletions

View File

@@ -111,6 +111,27 @@ describe('validateOutboundAttachments', () => {
]);
});
it('accepts generated image files in nested temp directories', () => {
const dir = makeTempDir(os.tmpdir(), 'paladin-character-');
const imagePath = writeFile(dir, 'sheet_12x.png', ONE_PIXEL_PNG);
const result = validateOutboundAttachments([
{
path: imagePath,
name: 'sheet_12x.png',
mime: 'image/png',
},
]);
expect(result.rejected).toEqual([]);
expect(result.files).toEqual([
{
attachment: fs.realpathSync(imagePath),
name: 'sheet_12x.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);