Repository navigation
Fixes #33500: narrow name/displayName HTML rendering to a highlight-only - #33501
Conversation
…put wrapper Port the DOMPurify-backed SanitizedInput to @openmetadata/ui-core-components, migrate the 17 main-app call sites off the raw Untitled `Input`, and add an ESLint rule that blocks any future PR from re-importing the raw primitive. Also confirm react/no-danger stays at error so dangerouslySetInnerHTML remains gated in production. No behavioural change for well-formed input; typed HTML markup is scrubbed on the way in. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
| selector: | ||
| "ImportDeclaration[source.value='@openmetadata/ui-core-components'] > ImportSpecifier[imported.name='Input']", |
There was a problem hiding this comment.
This selector blocks only named Input imports from the package root. The supported @openmetadata/ui-core-components/components entry point also exports the raw Input, so importing from that path passes lint; a namespace import from either entry point also avoids the rule. Extend the restriction to all public import forms that expose Input, or future raw inputs can pass CI despite this security ratchet.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Follows the EntityHeaderTitle change: sweep every remaining `stringToHTML` call site whose argument is a name/displayName/tag-value string (never a description or a version-diff HTML blob) and swap it to the narrow `renderHighlightedText` util. The three deliberately-skipped call sites stay on `stringToHTML`: `Certification.description` (long-form markdown), `TopicVersion.schemaTypeDiffText` and `DataAssetsVersionHeaderUtils.value` (version-diff HTML that legitimately contains `<ins>/<del>`). The util now returns a bare React element rather than a length-1 array when the whole input is a single wrapper, so mock fixtures written as `<span className="text-highlighter">…</span>` inside `toEqual(...)` keep working without changes. Also updates 14 test files: 5 mocks of `EntitySearchUtils` that were missing `renderHighlightedText`, 2 `stringToHTML`-based assertions retargeted at `renderHighlightedText`, and the 7 `@openmetadata/ui-core-components` inline mocks whose `Input` mock is now also aliased as `SanitizedInput` (follow-up to the earlier SanitizedInput swap PR — same 7 mock factories were pulling in the migrated `SearchBar`/widget components). Full jest suite: 1554 passed / 17,867 tests / 0 failures. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Follow-up commit ( Classified every Also refined Updated 14 test files:
Full jest suite: 1554 suites / 17,867 tests / 0 failures (baseline Net: production still has exactly 4 |
✅ Playwright Results — workflow succeededValidated commit ✅ 4490 passed · ❌ 0 failed · 🟡 6 flaky · ⏭️ 1 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 54m 42s ⏱️ Max setup 5m 26s · max shard execution 19m 56s · max shard-job elapsed before upload 23m 37s · reporting 17s 🌐 221.18 requests/attempt · 2.23 app boots/UI scenario · 38.63% common-shard skew Optimization targets still in progress:
🟡 6 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
…to-core # Conflicts: # openmetadata-ui/src/main/resources/ui/src/components/KnowledgeCenter/KnowledgePageVersion/KnowledgePageVersion.tsx
The initial sweep replaced `stringToHTML` with `renderHighlightedText` in
EntityHeaderTitle, which is used on version-diff pages. That util only
recognized `<span class="text-highlighter">…</span>`, so
`<span data-diff="true" class="diff-added" data-testid="diff-added">…</span>`
markers emitted by `getDiffValue`/`getEntityVersionByField`
(EntityDiffUtils.tsx:257,260) rendered as literal text — breaking
`TestCaseVersionPage.spec.ts` and every other version page's
"entity-header-display-name" diff assertion.
`renderHighlightedText` now scans every `<span ...>` opening tag and
recognizes two wrapper shapes:
- `<span class="text-highlighter">…</span>` — the search-highlight
wrapper the backend Elastic profile and client-side highlighter emit.
- `<span data-diff="true" class="…" data-testid="…">…</span>` — the
version-diff wrapper on version pages.
Only whitelisted `class` and `data-testid` attributes carry through to
the DOM; any other attribute on the outer tag is dropped (added a test
for that: `style` and `onmouseover` on a diff span are ignored).
Unrecognized `<span>` tags still render as literal text. Inner text
remains a plain React child — no HTML parsing, no
`dangerouslySetInnerHTML`. +3 unit tests covering diff wrapper, dropped
attributes, and unrecognized-span fallback.
Also applies the auto-fix output of `yarn ui-checkstyle:changed` across
the 30 files touched by the two earlier sweeps + this commit — prettier
reformatting and organize-imports adjustments only, no functional change.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Push ( Merge conflict ( UI Checkstyle: Playwright ( Remaining check to address (not code): "Validate PR Metadata" is failing because issue #33500 is missing Shipping → Release on its project sidebar. Set the Release field on the issue (or add |
Move DOMPurify sanitization from a separate `SanitizedInput` wrapper into
the core-components `Input` component itself. Every value the user types
now passes through `getSanitizeContent` before bubbling to `onChange` —
so consumers get the security fix without any call-site change or import
change. Net -256 lines across this commit.
Changes:
- `input.tsx`: `TextField` now intercepts `onChange` and pipes the string
through `getSanitizeContent` (via `useCallback` for stable identity).
Comment references GHSA-59gm-6h39-397f.
- Delete `sanitized-input.tsx` + `sanitized-input.test.tsx` and remove the
export from `components/index.ts`. Add sanitize coverage directly on
`Input` in `input.test.tsx` (4 tests: renders, strips <script>,
preserves entity-link syntax, plain text passes through unchanged).
- Revert the 17 call-site swaps back to `Input` — same imports, same JSX,
same prop signatures as before this PR touched them.
- Revert the ESLint `no-restricted-syntax` entry that banned
`Input` imports (no longer needed — `Input` is the sanctioned path).
- Revert the `SanitizedInput` mock additions in 12 test factories that
had aliased `SanitizedInput: Input` (or a copy of the Input mock).
- Un-reflow the `ContextCenterHeader` import back to the original
single-line shape (`{ Button, Input, PageLayout }`).
Left unchanged:
- The legacy AntD-based `common/SanitizedInput/` and its consumer
`utils/formUtils.tsx` — they drive the AntD form path and are
prop-incompatible with the react-aria Input.
- `renderHighlightedText` and its 24 call-site swap — unrelated to this
wrapper cleanup, and still narrows description/name rendering.
Verification:
- Core-components: `yarn type-check`, `yarn lint`, `yarn build`, `yarn test`
(4/4 input.test.tsx pass) — all clean.
- Main app: `yarn ui-checkstyle:changed` — 0 errors. Full jest suite:
17,911 / 17,912 pass (one full-suite XHR flake, passes in isolation).
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Three review comments from the PR's static-analysis pass:
- **CodeQL js/polynomial-redos** (`sanitize.ts:21`): `/<#E::[^>]+>/g` had an
unbounded interior class, so an adversarial input like
`<#E::<#E::<#E::…AAAA` (many starts, no closing `>`) could push the
matcher into polynomial-time backtracking. Bounded the interior to
`[^>]{1,512}` — OpenMetadata FQNs never exceed this in practice, and
the fixed upper bound turns per-start cost into a constant so total
work stays linear in input length. Existing tests still pass.
- **Sonar S6535** ("Use RegExp.exec() instead") on
`EntitySearchUtils.tsx:174,175`: `attrs.match(RE)?.[1]` → `RE.exec(attrs)?.[1]`
for both `CLASS_ATTR_RE` and `DATA_TESTID_ATTR_RE`. Neither regex
carries the `/g` flag, so `exec` is stateless — no `lastIndex` reset
needed. Straight rewrite; 37/37 tests in `EntitySearchUtils.test.tsx`
still pass.
Also folds in the pending `eslint.config.mjs` revert (`no-restricted-syntax`
entry banning `Input` imports from `@openmetadata/ui-core-components`) that
belonged with the previous "bake sanitization into Input" commit but was
left uncommitted.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Review flagged that DOMPurify on Input's onChange corrupts legitimate non-HTML input: `AT&T` gets HTML-entity-encoded to `AT&T`, regex filters like `a&b` or `<tag>` are mangled before being committed, and because these fields are controlled the encoded string is echoed back into the visible input. The reviewer is right — sanitize belongs at the RENDER sink, not the source. This PR already narrows every name/displayName render to `renderHighlightedText` (which recognizes only the highlight + version- diff wrappers and treats everything else as literal text — no HTML parsing, no `dangerouslySetInnerHTML`); description-body renders still go through `stringToHTML` (DOMPurify). Both defenses fire regardless of what lands in the input. Reverts: - Remove the `useCallback` sanitize interceptor from `TextField` in `input.tsx`. Consumers pass raw values through again. - Delete `input.test.tsx` (existed solely for the sanitize interceptor). - Delete the now-unused `utils/sanitize.ts`, remove its export from `utils/index.ts`, and drop `dompurify` from `peerDependencies` / `devDependencies` / vite rollup externals. `yarn install` refreshed `yarn.lock`. Untouched: - `renderHighlightedText` and the 24-file sweep — the render-side narrowing that actually closes GHSA-59gm-6h39-397f. - Legacy AntD `common/SanitizedInput/` (still used by `formUtils.tsx`). - Every main-app `Input` import (already reverted in the previous commit; consumers still import `Input` unchanged, no scrubbing). Verification: core-components `yarn type-check`, `yarn lint`, `yarn build` all clean. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
You're right — thanks for catching this. Pushed `9310672`. Bug you called out: DOMPurify on Input's `onChange` HTML-entity-encodes plain characters (`&` → `&`, bare `<`/`>` → `<`/`>`). Search boxes and regex filters carry those bytes verbatim to the backend / to a regex compiler, so `AT&T` becomes `AT&T`, `a&b` in a regex filter becomes `a&b`, and because the fields are controlled the encoded value gets echoed back into the visible input. Zero XSS benefit for a query field (its value is never rendered as HTML), pure corruption. Fix: sanitize at the render sink, not the source. This PR already does that — every name/displayName render is now `renderHighlightedText` (recognizes only the highlight + version-diff wrappers; everything else is literal React text — no HTML parsing, no `dangerouslySetInnerHTML`), and description bodies still go through `stringToHTML` (DOMPurify). Both defenses fire regardless of what lands in the input, so we can safely stop scrubbing at input. What was removed in this commit:
What stays:
Verification: `yarn type-check`, `yarn lint`, `yarn build` all clean on core-components. |
|
Root cause of the UI Checkstyle failure was not a tw-audit finding on this PR — it was a pre-existing dependency: the workflow's Tailwind Audit step runs `node --test scripts/design-tokens/tw-scanner.test.js` before the actual audit, and that test file only exists on `main` since PR #33254 (chore(ui): verify theme propagation and add audit warnings) — landed after my last merge. The step errored with `Could not find 'scripts/design-tokens/tw-scanner.test.js'` and short-circuited before the file audit ever ran; the bot's summary comment just says "Tailwind Audit failed" without the specific reason (the output goes to the changed-files variable, which is empty when the step dies before the audit prints). Pushed `f1af60f` — a fresh merge of `origin/main` (5 new commits since our last merge, including #33254 and 4 dark-theme + glossary fixes). Locally verified against the merged tree: ``` UntitledUI + Tailwind design-system audit Totals 0 errors 13 warnings 22 info ✔ No hardcoded-value errors. Zero tw-audit errors on my 33 changed `.ts/.tsx` files; `node scripts/design-tokens/{scanner,tw-scanner}.test.js` both pass. CI should now clear this step. |
Review feedback (@ShaileshParmar11): the `react/no-array-index-key` disable on the wrapper span's `key` prop could be avoided by deriving a real stable key. Track each segment's absolute character offset in the input string and use that as the key — every segment occupies a distinct slice of the input, so `offset` is unique across segments and deterministic for a given input. Drops the inline eslint-disable. Verified: `yarn test EntitySearchUtils.test.tsx` — 37/37 pass; `eslint --quiet` — 0 errors. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
| Count | Rule |
|---|---|
| 63 | react-hooks/exhaustive-deps |
| 9 | openmetadata-imports/no-lower-layer-page-imports |
| 8 | openmetadata-imports/no-circular-imports |
| 7 | no-restricted-imports |
| 2 | openmetadata-imports/no-internal-barrel-imports |
| 1 | openmetadata-imports/no-cross-page-imports |
All findings
| Location | Rule | Message | |
|---|---|---|---|
| 🟡 | src/components/Dashboard/DataModel/DataModels/DataModelsTable.tsx:42:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/Dashboard/DataModel/DataModels/DataModelsTable.tsx:131:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has a missing dependency: 'pageSize'. Either include it or remove the dependency array. |
| 🟡 | src/components/Dashboard/DataModel/DataModels/DataModelsTable.tsx:198:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has a missing dependency: 'handlePagingChange'. Either include it or remove the dependency array. |
| 🟡 | src/components/Dashboard/DataModel/DataModels/DataModelsTable.tsx:242:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'searchDataModels'. Either include it or remove the dependency array. |
| 🟡 | src/components/Dashboard/DataModel/DataModels/DataModelsTable.tsx:255:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'fetchDashboardsDataModel'. Either include it or remove the dependency array. |
| 🟡 | src/components/Database/ColumnDetailPanel/ColumnDetailPanel.component.tsx:69:1 |
openmetadata-imports/no-internal-barrel-imports |
Import the internal module directly instead of its index barrel so unrelated siblings do not enter the bundle graph. |
| 🟡 | src/components/Database/ColumnDetailPanel/ColumnDetailPanel.component.tsx:80:1 |
openmetadata-imports/no-internal-barrel-imports |
Import the internal module directly instead of its index barrel so unrelated siblings do not enter the bundle graph. |
| 🟡 | src/components/Database/ColumnDetailPanel/ColumnDetailPanel.component.tsx:622:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 't'. Either include it or remove the dependency array. |
| 🟡 | src/components/Database/ColumnDetailPanel/ColumnDetailPanel.component.tsx:662:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'activeColumn'. Either include it or remove the dependency array. |
| 🟡 | src/components/Database/DatabaseSchema/DatabaseSchemaTable/DatabaseSchemaTable.tsx:64:10 |
no-restricted-imports |
'getPrioritizedViewPermission' import from '../../../../utils/PermissionsUtils' is restricted from being used by a pattern. getPrioritizedEditPermission/getPrio |
| 🟡 | src/components/Database/DatabaseSchema/DatabaseSchemaTable/DatabaseSchemaTable.tsx:172:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has a missing dependency: 'handlePagingChange'. Either include it or remove the dependency array. |
| 🟡 | src/components/Database/DatabaseSchema/DatabaseSchemaTable/DatabaseSchemaTable.tsx:202:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has a missing dependency: 'pageSize'. Either include it or remove the dependency array. |
| 🟡 | src/components/Database/DatabaseSchema/DatabaseSchemaTable/DatabaseSchemaTable.tsx:211:6 |
react-hooks/exhaustive-deps |
React Hook useCallback has missing dependencies: 'handlePageChange' and 'setFilters'. Either include them or remove the dependency array. |
| 🟡 | src/components/Database/DatabaseSchema/DatabaseSchemaTable/DatabaseSchemaTable.tsx:316:5 |
react-hooks/exhaustive-deps |
React Hook useMemo has a missing dependency: 'searchValue'. Either include it or remove the dependency array. |
| 🟡 | src/components/Database/DatabaseSchema/DatabaseSchemaTable/DatabaseSchemaTable.tsx:352:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'fetchDatabaseSchema'. Either include it or remove the dependency array. |
| 🟡 | src/components/Database/SchemaTable/SchemaTable.component.tsx:355:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'fetchTestCaseSummary'. Either include it or remove the dependency array. |
| 🟡 | src/components/Database/SchemaTable/SchemaTable.component.tsx:457:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has a missing dependency: 'tableFqn'. Either include it or remove the dependency array. |
| 🟡 | src/components/Database/SchemaTable/SchemaTable.component.tsx:773:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has missing dependencies: 'handleEditDisplayNameClick' and 't'. Either include them or remove the dependency array. |
| 🟡 | src/components/Database/SchemaTable/SchemaTable.component.tsx:900:5 |
react-hooks/exhaustive-deps |
React Hook useMemo has missing dependencies: 'handleColumnClick' and 't'. Either include them or remove the dependency array. |
| 🟡 | src/components/Database/SchemaTable/SchemaTable.component.tsx:980:5 |
react-hooks/exhaustive-deps |
React Hook useMemo has a missing dependency: 't'. Either include it or remove the dependency array. |
| 🟡 | src/components/DriveService/File/FilesTable/FilesTable.tsx:33:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/DriveService/File/FilesTable/FilesTable.tsx:114:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has a missing dependency: 'setFilters'. Either include it or remove the dependency array. |
| 🟡 | src/components/DriveService/File/FilesTable/FilesTable.tsx:175:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'searchFiles'. Either include it or remove the dependency array. |
| 🟡 | src/components/DriveService/Spreadsheet/SpreadsheetsTable/SpreadsheetsTable.tsx:33:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/DriveService/Spreadsheet/SpreadsheetsTable/SpreadsheetsTable.tsx:116:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has a missing dependency: 'setFilters'. Either include it or remove the dependency array. |
| 🟡 | src/components/DriveService/Spreadsheet/SpreadsheetsTable/SpreadsheetsTable.tsx:177:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'searchSpreadsheets'. Either include it or remove the dependency array. |
| 🟡 | src/components/Entity/EntityHeaderTitle/EntityHeaderTitle.component.tsx:122:5 |
react-hooks/exhaustive-deps |
React Hook useMemo has a missing dependency: 't'. Either include it or remove the dependency array. |
| 🟡 | src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx:42:1 |
openmetadata-imports/no-circular-imports |
This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency. |
| 🟡 | src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx:46:1 |
openmetadata-imports/no-circular-imports |
This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency. |
| 🟡 | src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx:50:1 |
openmetadata-imports/no-circular-imports |
This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency. |
| 🟡 | src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx:51:1 |
openmetadata-imports/no-circular-imports |
This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency. |
| 🟡 | src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx:52:1 |
openmetadata-imports/no-circular-imports |
This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency. |
| 🟡 | src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx:54:1 |
openmetadata-imports/no-circular-imports |
This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency. |
| 🟡 | src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx:56:1 |
openmetadata-imports/no-circular-imports |
This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency. |
| 🟡 | src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx:805:8 |
react-hooks/exhaustive-deps |
React Hook useMemo has a missing dependency: 't'. Either include it or remove the dependency array. |
| 🟡 | src/components/LineageTable/LineageTable.tsx:57:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/LineageTable/LineageTable.tsx:479:6 |
react-hooks/exhaustive-deps |
React Hook useMemo has a missing dependency: 't'. Either include it or remove the dependency array. |
| 🟡 | src/components/LineageTable/LineageTable.tsx:602:6 |
react-hooks/exhaustive-deps |
React Hook useCallback has missing dependencies: 'handlePagingChange', 'setColumnLineageNodes', 'setFilterNodes', 'setLineagePagingInfo', and 'setLoading'. Eith |
| 🟡 | src/components/LineageTable/LineageTable.tsx:622:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'updateEntityData'. Either include it or remove the dependency array. |
| 🟡 | src/components/LineageTable/LineageTable.tsx:693:6 |
react-hooks/exhaustive-deps |
React Hook useMemo has an unnecessary dependency: 'lineagePagingInfo'. Either exclude it or remove the dependency array. |
| 🟡 | src/components/LineageTable/LineageTable.tsx:837:5 |
react-hooks/exhaustive-deps |
React Hook useMemo has a missing dependency: 'entityType'. Either include it or remove the dependency array. |
| 🟡 | src/components/LineageTable/LineageTable.tsx:913:5 |
react-hooks/exhaustive-deps |
React Hook useMemo has an unnecessary dependency: 'lineageDirection'. Either exclude it or remove the dependency array. |
| 🟡 | src/components/LineageTable/LineageTable.tsx:937:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has missing dependencies: 'selectedQuickFilters' and 'setSelectedQuickFilters'. Either include them or remove the dependency array. |
| 🟡 | src/components/LineageTable/LineageTable.tsx:988:6 |
react-hooks/exhaustive-deps |
React Hook useMemo has a missing dependency: 'handlePageChange'. Either include it or remove the dependency array. |
| 🟡 | src/components/Settings/Bot/BotListV1/BotListV1.component.tsx:373:6 |
react-hooks/exhaustive-deps |
React Hook useCallback has missing dependencies: 'fetchBots', 'getResourceLimit', and 'showDeleted'. Either include them or remove the dependency array. |
| 🟡 | src/components/Settings/Bot/BotListV1/BotListV1.component.tsx:422:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'fetchBots'. Either include it or remove the dependency array. |
| 🟡 | src/components/Settings/Services/Services.tsx:209:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has missing dependencies: 'handlePagingChange' and 't'. Either include them or remove the dependency array. |
| 🟡 | src/components/Settings/Services/Services.tsx:232:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has a missing dependency: 'handlePageChange'. Either include it or remove the dependency array. |
| 🟡 | src/components/Settings/Services/Services.tsx:439:5 |
react-hooks/exhaustive-deps |
React Hook useMemo has a missing dependency: 'getServiceLogoElement'. Either include it or remove the dependency array. |
| 🟡 | src/components/Settings/Services/Services.tsx:510:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has a missing dependency: 'handlePageChange'. Either include it or remove the dependency array. |
… and 40 more. Run make ui-checkstyle-changed locally for the full list.
Fix locally (fast - only checks files changed in this branch):
make ui-checkstyle-changed
Code Review ✅ Approved 1 closed / 1 findings🟡 Medium risk Ports the DOMPurify-backed ✅ 1 closedClosed: Bug: SanitizedInput corrupts search/regex query strings
OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|
|
Merge-group eviction (run 35455936610) is unrelated to this PR. Failing test: `playwright/e2e/Pages/Entity.spec.ts:605 › Pipeline › Tag and Glossary Term preservation in column detail panel`, at `utils/glossaryPicker.ts:74` — `treeLocator.waitFor({ state: 'visible' })`. Failure signature is a Playwright flake, not a code fault:
Safe to re-queue. Should I try again from my end, or would you rather do it? |



Describe your changes:
Fixes #33500
The advisory close is at the render sink, not the input source: name/displayName/tag-value fields no longer flow through
stringToHTML(DOMPurify default profile — permissive enough to keep<a>/<b>/<img>— the class of sink flagged by GHSA-59gm-6h39-397f). They now flow through a new narrow util,renderHighlightedText, that recognizes only the two wrappers the codebase actually emits and treats everything else as literal React text (no HTML parsing, nodangerouslySetInnerHTML).Two earlier approaches — wrapping every migrated call site in
SanitizedInput, and baking DOMPurify intoInput'sonChange— were tried and then removed. The wrapper touched 17 files for no consumer-facing benefit once sanitization moved into the component; the Input-level scrubbing HTML-entity-encoded&/</>on every input, corrupting legitimate search queries (AT&T→AT&T) and regex filters (a&b,<tag>). Sanitizing at the render sink is the correct layer — it fires regardless of what lands in the input, and it doesn't destroy queries.Type of change:
High-level design:
New util —
renderHighlightedText(input?: string | null): ReactNode(openmetadata-ui/src/main/resources/ui/src/utils/EntitySearchUtils.tsx). Scans every<span …>and preserves the tag only when it carriesclass="text-highlighter"(the wrapper the backend Elastic profileEntityBuilderConstant.PRE_TAGand the client-sidehighlightSearchTexthelper emit) ordata-diff="true"(the version-diff wrappergetDiffValue/getEntityVersionByFieldinEntityDiffUtils.tsx:257,260emit). Only whitelistedclass+data-testidattributes carry through; every other attribute on the outer tag is silently dropped. Inner text is always a plain React child, so<script>alert(1)</script>or<img onerror=…>embedded inside a wrapper render as visible text, not markup. Fast path: input with no recognized wrapper returns the raw string (memo-friendly).Regex hardening. The wrapper scanner is
/<span\b([^>]*)>([\s\S]*?)<\/span>/gi; attribute scans use.exec()(not.match()) — S6535. The main-appgetSanitizeContentregex (utils/sanitize.utils.ts) was already bounded there; the copy this PR briefly added to core-components was removed with the Input-level scrubbing revert.EntityHeaderTitle.component.tsx. All threestringToHTMLcall sites (memoizedentityName,Tooltip title=for displayName,Typography.Textchild for displayName) now userenderHighlightedText.24-file rendering sweep. Every other
stringToHTML(name|displayName|highlightSearchText(...))call site swapped torenderHighlightedText. Full list inEntityHeaderTitle,EntitySummaryPanelUtils,IngestionListTableUtils,ServiceMainTabContentUtils,DataAssetSummaryPanelUtils,TeamHierarchyNameCell,BotListV1.component,Services,DatabaseSchemaTable,SchemaTable.component,FilesTable,SpreadsheetsTable,KnowledgePageVersion,TestCaseDetail,DataModelsTable,EntityTitleSection,LineageTable,ExploreSearchCard,SearchIndexFieldsTable,AddAttributeModal,SchemaTablesTab,StoredProcedureTab,TestCaseHeaderTitle.component,APIEndpointsTab,ColumnDetailPanel.component.Deliberately left on
stringToHTML(the wider profile is legitimately needed):Certification.description— long-form markdown body.TopicVersion.schemaTypeDiffTextandDataAssetsVersionHeaderUtils.value— version-diff HTML blobs the diff util emits with<ins>/<del>.Untouched: every
Inputimport;Inputstill passes its value through unchanged (no HTML-entity encoding on&/</>). The legacy AntD-basedcommon/SanitizedInput/and its consumerutils/formUtils.tsxalso stay — they drive the AntD form path and are prop-incompatible with the react-ariaInput.Alternatives considered and rejected:
SanitizedInputwrapper in core-components: written and then removed. Once sanitization moved into the shared component, the wrapper added a name without adding behaviour, and touched 17 call sites for no benefit.Input'sonChange: the reviewer flagged that DOMPurify HTML-entity-encodes&/</>on every input keystroke, soAT&TbecomesAT&T, regex filters likea&bare mangled, and controlled search boxes echo the encoded string back. Wrong layer — reverted.Inputimports: no longer applies now thatInputis the sanctioned path.Tests:
Use cases covered
AT&Tin the global search bar / regex filter deliversAT&Tto the backend (notAT&T).displayNamewas stored with<script>alert(1)</script>renders<script>alert(1)</script>as literal text — no execution — anywhereEntityHeaderTitleor one of the 24 swapped call sites paints the name.highlight.displayNamereturnsfoo <span class="text-highlighter">bar</span> bazstill renders the highlight span, correctly emphasised.EntityHeaderTitlerenders a diff (<span data-diff="true" class="diff-added" data-testid="diff-added">test-case-version-changed</span>) shows the diff-added marker with class +data-testidintact — that's whatTestCaseVersionPage.spec.ts:71asserts on, and it now passes.<span class="text-highlighter"><img src=x onerror=alert(1)></span>) renders<img src=x onerror=alert(1)>as text; no<img>element is created.[^>]{1,512}in the entity-link protection inutils/sanitize.utils.ts), so an adversarial<#E::…AAAAinput runs in linear time (CodeQLjs/polynomial-redosaddressed).Unit tests
I added unit tests for the new/changed logic.
Files added/updated:
openmetadata-ui/src/main/resources/ui/src/utils/EntitySearchUtils.test.tsx— newrenderHighlightedTextblock, 9 cases (plain text fast-path, null/empty, wrapper preservation, adversarial<script>/<img>/javascript:payloads render as text,data-highlightextra-attribute tolerance, content escaping inside the wrapper, version-diff wrapper preservation, unrecognized attribute drop, unrecognized<span>renders as literal text). Total in that file: 37 passing.openmetadata-ui/src/main/resources/ui/src/components/Settings/Team/TeamDetails/TeamsHeaderSection/TeamHierarchyNameCell.test.tsx— assertion retargeted fromstringToHTMLtorenderHighlightedText; passes.EntitySearchUtils(IngestionListTableUtils,TeamHierarchyNameCell,SchemaTable,ExploreV1,ExploreSearchCard) updated to exposerenderHighlightedTextalongsidehighlightSearchText.Full jest suite on the main app: 17,911 / 17,912 pass. The single miss (
ServiceConnectionCard.test.tsx) passes in isolation and is a full-suite XHR flake unrelated to this PR.Core-components:
yarn type-check,yarn lint,yarn buildclean.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
TestCaseVersionPage.spec.ts:71, version-page diff marker) is what led to thedata-diff="true"branch inrenderHighlightedText; that spec now passes.Manual testing performed
yarn test --watchAll=false) — 17,911 / 17,912 pass; the flake reproduces without this PR's changes and passes in isolation.yarn install --ignore-scripts && yarn type-check && yarn lint && yarn build— all clean after the final revert removed thedompurifydep +sanitize.tsutil.yarn ui-checkstyle:changedon the main app — 0 errors, prettier + organize-imports diffs already applied.Input-sanitize approach (later removed): revertedInputback manually and confirmed the ESLintno-restricted-syntaxentry fired with the intended message. Rule and message are gone in the final state.UI screen recording / screenshots:
Not applicable. All changes are on the render pipeline for entity names/displayNames; the rendered output for well-formed strings is byte-identical to before. The visible behavioural difference is that HTML/
<script>/<img onerror=…>embedded inside a stored displayName now renders as literal text rather than executing — that difference is invisible under a visual regression harness because there was never a way to make it appear "correctly" as HTML.Checklist:
Fixes <issue-number>: <short explanation>Fixes #33500above.Improvement:
The PR appears safe to merge; no new actionable failures or outstanding previous findings remain.
Findings
Summary
This PR narrows rendering of entity names, display names, and highlighted values to a dedicated React renderer instead of passing them through the broader HTML rendering utility.
InputPropsinterface without changing input behavior.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Name or displayName] --> B{Recognized span wrapper?} B -->|No| C[Return plain React text] B -->|Search highlight| D[Create span with approved class] B -->|Version diff| E[Create span with approved class and test id] D --> F[Render inner content as escaped text] E --> F C --> G[React render sink] F --> GReviews (8) · Last reviewed commit: "Merge branch 'main' into port-sanitized-..."