mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 14:18:58 +08:00
feat: restrict the rendering of img and form tags in the logs content (#4905)
* feat: restrict the rendering of img tags in the logs content * fix: forbidden tags code cleanup
This commit is contained in:
parent
2dbe598b2c
commit
12be6ce020
@ -16,6 +16,7 @@ import { useCallback, useMemo, useState } from 'react';
|
||||
// interfaces
|
||||
import { IField } from 'types/api/logs/fields';
|
||||
import { ILog } from 'types/api/logs/log';
|
||||
import { FORBID_DOM_PURIFY_TAGS } from 'utils/app';
|
||||
|
||||
// components
|
||||
import AddToQueryHOC, { AddToQueryHOCProps } from '../AddToQueryHOC';
|
||||
@ -50,7 +51,11 @@ function LogGeneralField({
|
||||
}: LogFieldProps): JSX.Element {
|
||||
const html = useMemo(
|
||||
() => ({
|
||||
__html: convert.toHtml(dompurify.sanitize(fieldValue)),
|
||||
__html: convert.toHtml(
|
||||
dompurify.sanitize(fieldValue, {
|
||||
FORBID_TAGS: [...FORBID_DOM_PURIFY_TAGS],
|
||||
}),
|
||||
),
|
||||
}),
|
||||
[fieldValue],
|
||||
);
|
||||
|
@ -21,6 +21,7 @@ import {
|
||||
useMemo,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { FORBID_DOM_PURIFY_TAGS } from 'utils/app';
|
||||
|
||||
import LogLinesActionButtons from '../LogLinesActionButtons/LogLinesActionButtons';
|
||||
import LogStateIndicator from '../LogStateIndicator/LogStateIndicator';
|
||||
@ -144,7 +145,9 @@ function RawLogView({
|
||||
|
||||
const html = useMemo(
|
||||
() => ({
|
||||
__html: convert.toHtml(dompurify.sanitize(text)),
|
||||
__html: convert.toHtml(
|
||||
dompurify.sanitize(text, { FORBID_TAGS: [...FORBID_DOM_PURIFY_TAGS] }),
|
||||
),
|
||||
}),
|
||||
[text],
|
||||
);
|
||||
|
@ -8,6 +8,7 @@ import dompurify from 'dompurify';
|
||||
import { useIsDarkMode } from 'hooks/useDarkMode';
|
||||
import { FlatLogData } from 'lib/logs/flatLogData';
|
||||
import { useMemo } from 'react';
|
||||
import { FORBID_DOM_PURIFY_TAGS } from 'utils/app';
|
||||
|
||||
import LogStateIndicator from '../LogStateIndicator/LogStateIndicator';
|
||||
import { getLogIndicatorTypeForTable } from '../LogStateIndicator/utils';
|
||||
@ -107,7 +108,11 @@ export const useTableView = (props: UseTableViewProps): UseTableViewResult => {
|
||||
children: (
|
||||
<TableBodyContent
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: convert.toHtml(dompurify.sanitize(field)),
|
||||
__html: convert.toHtml(
|
||||
dompurify.sanitize(field, {
|
||||
FORBID_TAGS: [...FORBID_DOM_PURIFY_TAGS],
|
||||
}),
|
||||
),
|
||||
}}
|
||||
linesPerRow={linesPerRow}
|
||||
isDarkMode={isDarkMode}
|
||||
|
@ -31,3 +31,6 @@ export const checkVersionState = (
|
||||
const versionCore = currentVersion?.split('-')[0];
|
||||
return versionCore === latestVersion;
|
||||
};
|
||||
|
||||
// list of forbidden tags to remove in dompurify
|
||||
export const FORBID_DOM_PURIFY_TAGS = ['img', 'form'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user