Skip to content

style: format code with Prettier and StandardJS#928

Closed
deepsource-autofix[bot] wants to merge 1 commit intomainfrom
deepsource-transform-efac7446
Closed

style: format code with Prettier and StandardJS#928
deepsource-autofix[bot] wants to merge 1 commit intomainfrom
deepsource-transform-efac7446

Conversation

@deepsource-autofix
Copy link
Copy Markdown
Contributor

This commit fixes the style issues introduced in fa4234c according to the output
from Prettier and StandardJS.

Details: None

This commit fixes the style issues introduced in fa4234c according to the output
from Prettier and StandardJS.

Details: None
@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
pro-react-admin Ready Ready Preview, Comment Jan 2, 2026 5:54am

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jan 2, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
9.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

</div>
)
: (
<div className='mermaid-output' dangerouslySetInnerHTML={{ __html: svg }} />

Check failure

Code scanning / CodeQL

DOM text reinterpreted as HTML High

DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix

AI 4 months ago

In general, the problem arises because untrusted user input ends up being rendered as HTML without sufficient protection. Since this code relies on Mermaid to generate SVG/HTML, the correct fix is to configure Mermaid to use its safer security settings instead of the relaxed "loose" mode, and avoid overriding it with a weaker value via config. That way, Mermaid enforces stricter rules on how user-supplied diagrams are turned into SVG, significantly reducing or eliminating XSS vectors while preserving the existing functionality as much as possible.

Concretely, in src/components/stateful/mermaidHooks/index.jsx we should:

  • Change securityLevel: 'loose' to a safer level, such as 'strict' (Mermaid’s recommended default for untrusted input).
  • Prevent callers from downgrading securityLevel via the config prop by ensuring the default securityLevel cannot be overridden. This can be done by spreading config before specifying securityLevel, so our secure value wins.
    No other files need changes for this particular vulnerability, and no new imports or helper methods are required.
Suggested changeset 1
src/components/stateful/mermaidHooks/index.jsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/components/stateful/mermaidHooks/index.jsx b/src/components/stateful/mermaidHooks/index.jsx
--- a/src/components/stateful/mermaidHooks/index.jsx
+++ b/src/components/stateful/mermaidHooks/index.jsx
@@ -24,12 +24,13 @@
 
         // Initialize with default config or props
         // Note: initialize is global, but safe to call repeatedly with same config
+        // Use a strict security level for untrusted input and prevent it from being overridden
         mermaid.initialize({
           startOnLoad: false,
           theme: 'default',
-          securityLevel: 'loose',
           fontFamily: 'monospace',
-          ...config
+          ...config,
+          securityLevel: 'strict'
         })
 
         // Attempt to render
EOF
@@ -24,12 +24,13 @@

// Initialize with default config or props
// Note: initialize is global, but safe to call repeatedly with same config
// Use a strict security level for untrusted input and prevent it from being overridden
mermaid.initialize({
startOnLoad: false,
theme: 'default',
securityLevel: 'loose',
fontFamily: 'monospace',
...config
...config,
securityLevel: 'strict'
})

// Attempt to render
Copilot is powered by AI and may make mistakes. Always verify output.
@wkylin wkylin closed this Jan 2, 2026
@wkylin wkylin deleted the deepsource-transform-efac7446 branch January 10, 2026 09:36
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.

2 participants