Skip to content

ATLAS-5389: Atlas React Dashboard — Align UI with strict browser resource policy (nonce-based script/style handling) - #744

Open
pawarprasad123 wants to merge 1 commit into
masterfrom
ATLAS-5389_broswerResourcePolicy
Open

ATLAS-5389: Atlas React Dashboard — Align UI with strict browser resource policy (nonce-based script/style handling)#744
pawarprasad123 wants to merge 1 commit into
masterfrom
ATLAS-5389_broswerResourcePolicy

Conversation

@pawarprasad123

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This PR prepares the React Dashboard for strict Content Security Policy (CSP) by wiring a per-request CSP nonce into MUI/Emotion style injection. When the server injects a nonce into the HTML shell and CSP headers, Emotion-generated <style> tags will carry the same nonce and will not be blocked by the browser.

Without this change, MUI components (which use Emotion for sx and runtime styles) would render unstyled under a strict style-src 'self' 'nonce-...' policy.

Problem

DAST findings show Atlas UI currently allows inline scripts, dynamic eval, and inline styles. Server-side work will introduce per-request nonce support. On the React side:

  1. MUI/Emotion injects runtime <style data-emotion="css"> tags — these need a matching CSP nonce.
  2. HTML shell needs a placeholder for the server to inject the nonce value.

Under strict CSP, blocked Emotion styles would break the entire React UI (sidebar, tables, forms, toasts, etc.).

Out of Scope (follow-up on same JIRA)

Item Phase Notes
Classic Dashboardv2 (/index.html) Not in scope per JIRA
Server-side CSP filter/header Backend Separate PR
Lineage tooltip inline style= attributes ( need to verify once the backend changes are available) Phase 2 atlas-lineage/src/index.js — separate change
dangerouslySetInnerHTML audit Phase 2 Separate review
Third-party CSS nonce (toastify, quill, etc.) Server Backend link-tag nonce injection

How was this patch tested?

Automated tests
Command run:

cd dashboard
npm test -- --testPathPattern="cspNonce|emotionCache|Main.test" --watchAll=false

Result: 33/33 passed (3 suites, ~3s)

Build verification
cd dashboard && npm run build
Result: Success (~12.6s) — no TypeScript or Vite errors.

Linter verification
Result: No linter errors in changed files.

Manual testing (required before integrated merge)
These require backend CSP + HTML nonce injection (not available in unit tests):

Test How to verify
1 CSP header has nonce
2 Meta tag populated
3 Emotion styles have nonce
4 No console CSP errors
5 UI renders styled
6 Local strict CSP simulation

Dependencies
Backend PR must deploy per-request nonce generation and HTML injection before full E2E validation.
Vite build already externalizes JS bundles — no pipeline changes needed.
@emotion/cache is available transitively via @emotion/react / MUI.

…urce policy (nonce-based script/style handling)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant