Skip to content

Commit a44777d

Browse files
ACM-38694 Replace dangerouslySetInnerHTML with <Trans> in shared resource warnings (#6701)
* fix(applications): replace dangerouslySetInnerHTML with <Trans> (ACM-38694) The getCodeSpan helper in SharedResourceWarning concatenated a resource name (a Subscription metadata.name) into raw HTML rendered via dangerouslySetInnerHTML without encoding (CWE-79). Kubernetes DNS-1123 name validation blocks exploitation today, but the sink is one data-source change away from XSS. Render the shared-resource warnings with <Trans> and React children instead, and remove the getCodeSpan/getWarningSpan raw-HTML helpers. Also convert the remaining static-string dangerouslySetInnerHTML in DeleteResourceModal to plain JSX. No dangerouslySetInnerHTML remains in these components. Signed-off-by: Kevin Cormier <kcormier@redhat.com> * test(applications): add SharedResourceWarning XSS regression tests (ACM-38694) Add a regression test that renders SharedResourceWarning with a malicious subscription name and asserts the payload is rendered as inert, escaped text (no injected element, no fired handler), plus a jest-axe accessibility test. The regression test fails against the previous dangerouslySetInnerHTML code and passes with the <Trans> fix. Signed-off-by: Kevin Cormier <kcormier@redhat.com> * chore(applications): use ~/ import aliases in SharedResourceWarning (ACM-38694) Signed-off-by: Kevin Cormier <kcormier@redhat.com> * Revert changes for shared resource warning Signed-off-by: Kevin Cormier <kcormier@redhat.com> --------- Signed-off-by: Kevin Cormier <kcormier@redhat.com>
1 parent 9e0c6d4 commit a44777d

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

frontend/src/routes/Applications/components/DeleteResourceModal.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,9 @@ export function DeleteResourceModal(props: IDeleteResourceModalProps | { open: f
252252
props.appSetApps.length > 0 && (
253253
<div className="remove-app-modal-content">
254254
<div className="remove-app-modal-content-text">
255-
<p
256-
dangerouslySetInnerHTML={{
257-
__html: `${props.t(
258-
'The following Argo application(s) deployed by the application set will also be deleted:'
259-
)}`,
260-
}}
261-
/>
255+
<p>
256+
{props.t('The following Argo application(s) deployed by the application set will also be deleted:')}
257+
</p>
262258
</div>
263259
<div>
264260
<ul>

0 commit comments

Comments
 (0)