fix(notifier): embedded markdown images are not resolved by octi.markdownToHtml in mail notifiers
Description
When an image is uploaded inside a markdown field (e.g. a Report description), the platform stores the file in the embedded/ storage area and rewrites the markdown destination to a platform-relative, context-dependent URL:
(see opencti-platform/opencti-graphql/src/database/middlewareEmbeddedImages.ts:285, .../database/middleware.ts:3984)
The UI resolves that URL at render time by prefixing the current entity route, so the backend can infer the entity and serve the file (opencti-front/src/components/markdownDisplay/markdownDisplayHelpers.ts, resolveContextualEmbeddedImageUrl).
The notification helper octi.markdownToHtml() does no such resolution. It is a plain marked() call:
// opencti-platform/opencti-graphql/src/utils/NotificationTool.ts
markdownToHtml(markdownText?: string): string | undefined {
if (!markdownText) return undefined;
return marked(markdownText) as string;
}So in the Platform mailer / Simplified mailer notifiers, a template such as:
<%- octi.markdownToHtml(notification_content[0].events[0].message) %>
<%- octi.markdownToHtml(data[0].instance.description) %>produces:
<img src="embedded/markdown-image-b671c4f1.jpg">which is a relative URL with no host and no entity context. In a mail client it resolves to nothing, so every embedded image in the mail is broken.
Environment
- OS: any
- Version: 7.260921.0 (current
master)
Reproducible steps
- Create a Report and paste/upload an image into its
descriptionmarkdown field. The stored markdown becomes. - Create a live trigger on that Report with a Platform mailer notifier whose HTML template renders the description, e.g.
<%- octi.markdownToHtml(data[0].instance.description) %>. - Trigger a notification (update the report).
- Open the received email.
Expected output
The image uploaded in the description is visible in the email body (or, at minimum, degrades to something actionable such as a link to the entity rather than a broken <img>).
Actual output
The email body contains <img src="embedded/markdown-image-<hash>.jpg">, rendered as a broken image placeholder by every mail client. Text and other markdown constructs are converted correctly; only embedded images are affected.
Source: OpenCTI-Platform/opencti