Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 449bdc9

Browse files
authored
Merge pull request from GHSA-3hjm-9277-5c88
* Fix XSS vulnerabilities * remove console.log
1 parent 4d41106 commit 449bdc9

File tree

5 files changed

+37
-11
lines changed

5 files changed

+37
-11
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "querybook",
3-
"version": "3.31.1",
3+
"version": "3.31.2",
44
"description": "A Big Data Webapp",
55
"private": true,
66
"scripts": {
@@ -50,6 +50,7 @@
5050
"core-js": "^3.19.1",
5151
"cron-parser": "^4.7.0",
5252
"dagre": "^0.8.5",
53+
"dompurify": "^3.0.9",
5354
"draft-js": "0.11.7",
5455
"draft-js-export-html": "^1.4.1",
5556
"draft-js-import-html": "^1.4.1",

querybook/webapp/components/DataDocStatementExecution/StatementLog.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import clsx from 'clsx';
2+
import DOMPurify from 'dompurify';
23
import { debounce } from 'lodash';
34
import React from 'react';
45
import { useDispatch, useSelector } from 'react-redux';
@@ -103,7 +104,9 @@ export const StatementLog: React.FunctionComponent<IStatementLogProps> = ({
103104
}}
104105
className="statement-execution-log-container"
105106
dangerouslySetInnerHTML={{
106-
__html: logText,
107+
__html: DOMPurify.sanitize(logText, {
108+
USE_PROFILES: { html: true },
109+
}),
107110
}}
108111
/>
109112
);

querybook/webapp/components/Search/SearchResultItem.tsx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import DOMPurify from 'dompurify';
12
import { escape, escapeRegExp } from 'lodash';
23
import React, { useMemo, useRef, useState } from 'react';
34
import { useSelector } from 'react-redux';
@@ -55,7 +56,9 @@ const HighlightTitle: React.FunctionComponent<{
5556
<div
5657
className="result-item-title"
5758
dangerouslySetInnerHTML={{
58-
__html: highlightedTitle,
59+
__html: DOMPurify.sanitize(highlightedTitle, {
60+
USE_PROFILES: { html: true },
61+
}),
5962
}}
6063
/>
6164
</AccentText>
@@ -166,8 +169,9 @@ export const QueryItem: React.FunctionComponent<IQueryItemProps> = ({
166169
{!isQueryTextExpanded ? (
167170
<span
168171
dangerouslySetInnerHTML={{
169-
__html: formatHighlightStrings(
170-
queryTextHighlightedContent
172+
__html: DOMPurify.sanitize(
173+
formatHighlightStrings(queryTextHighlightedContent),
174+
{ USE_PROFILES: { html: true } }
171175
),
172176
}}
173177
/>
@@ -281,7 +285,10 @@ export const DataDocItem: React.FunctionComponent<IDataDocItemProps> = ({
281285
<span
282286
className="result-item-description"
283287
dangerouslySetInnerHTML={{
284-
__html: formatHighlightStrings(dataDocContent),
288+
__html: DOMPurify.sanitize(
289+
formatHighlightStrings(dataDocContent),
290+
{ USE_PROFILES: { html: true } }
291+
),
285292
}}
286293
/>
287294
);
@@ -381,7 +388,10 @@ export const DataTableItem: React.FunctionComponent<IDataTableItemProps> = ({
381388
const descriptionDOM = highlightedDescription ? (
382389
<span
383390
dangerouslySetInnerHTML={{
384-
__html: formatHighlightStrings(highlightedDescription),
391+
__html: DOMPurify.sanitize(
392+
formatHighlightStrings(highlightedDescription),
393+
{ USE_PROFILES: { html: true } }
394+
),
385395
}}
386396
/>
387397
) : (
@@ -484,7 +494,10 @@ export const BoardItem: React.FunctionComponent<{
484494
const descriptionDOM = highlightedDescription ? (
485495
<span
486496
dangerouslySetInnerHTML={{
487-
__html: formatHighlightStrings(highlightedDescription),
497+
__html: DOMPurify.sanitize(
498+
formatHighlightStrings(highlightedDescription),
499+
{ USE_PROFILES: { html: true } }
500+
),
488501
}}
489502
/>
490503
) : (

querybook/webapp/lib/sql-helper/sql-autocompleter.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { getLanguageSetting, ILanguageSetting } from './sql-setting';
2+
import DOMPurify from 'dompurify';
3+
import { bind } from 'lodash-decorators';
24

35
import CodeMirror from 'lib/codemirror';
46
import { ICodeAnalysis, TableToken } from 'lib/sql-helper/sql-lexer';
57
import { reduxStore } from 'redux/store';
68
import { SearchTableResource } from 'resource/search';
7-
import { bind } from 'lodash-decorators';
89

910
interface ILineAnalysis {
1011
statementNum: number;
@@ -408,14 +409,17 @@ export class SqlAutoCompleter {
408409

409410
const div = document.createElement('div');
410411
div.className = 'code-editor-autocomplete-wrapper';
411-
div.innerHTML = `
412+
div.innerHTML = DOMPurify.sanitize(
413+
`
412414
<span class="code-editor-autocomplete-span code-editor-text-span">
413415
${text}
414416
</span>
415417
<span class="code-editor-autocomplete-span code-editor-tooltip-span">
416418
${tooltip}
417419
</span>
418-
`;
420+
`,
421+
{ USE_PROFILES: { html: true } }
422+
);
419423

420424
element.appendChild(div);
421425
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9345,6 +9345,11 @@ domhandler@^4.0.0, domhandler@^4.2.0:
93459345
dependencies:
93469346
domelementtype "^2.2.0"
93479347

9348+
dompurify@^3.0.9:
9349+
version "3.0.9"
9350+
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.0.9.tgz#b3f362f24b99f53498c75d43ecbd784b0b3ad65e"
9351+
integrity sha512-uyb4NDIvQ3hRn6NiC+SIFaP4mJ/MdXlvtunaqK9Bn6dD3RuB/1S/gasEjDHD8eiaqdSael2vBv+hOs7Y+jhYOQ==
9352+
93489353
93499354
version "1.1.6"
93509355
resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.1.6.tgz#bddc3de099b9a2efacc51c623f28f416ecc57485"

0 commit comments

Comments
 (0)