-
Notifications
You must be signed in to change notification settings - Fork 52
Add Ballerina troubleshooting guide and update documentation navigation #285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1b554bb
5cf8321
098e321
885e7d7
2a9f0d5
6d16d78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||||||||||||||||||||||||||||||||||||||||
| document.addEventListener("DOMContentLoaded", function () { | ||||||||||||||||||||||||||||||||||||||||||||
| // Select all .mermaid elements | ||||||||||||||||||||||||||||||||||||||||||||
| const mermaidElements = document.querySelectorAll(".mermaid"); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| mermaidElements.forEach((el) => { | ||||||||||||||||||||||||||||||||||||||||||||
| // 1. Extract content from <code> tag if it exists, otherwise use el.innerHTML | ||||||||||||||||||||||||||||||||||||||||||||
| const codeTag = el.querySelector("code"); | ||||||||||||||||||||||||||||||||||||||||||||
| let content = codeTag ? codeTag.innerHTML : el.innerHTML; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // 2. Decode HTML entities (e.g., > to >) | ||||||||||||||||||||||||||||||||||||||||||||
| content = content | ||||||||||||||||||||||||||||||||||||||||||||
| .replace(/</g, "<") | ||||||||||||||||||||||||||||||||||||||||||||
| .replace(/>/g, ">") | ||||||||||||||||||||||||||||||||||||||||||||
| .replace(/&/g, "&") | ||||||||||||||||||||||||||||||||||||||||||||
| .replace(/"/g, '"'); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // 3. Update the element's textContent with the clean, decoded content | ||||||||||||||||||||||||||||||||||||||||||||
| // We use textContent to ensure no HTML tags remain. | ||||||||||||||||||||||||||||||||||||||||||||
| el.textContent = content.trim(); | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // 4. Initialize mermaid now that the content is clean | ||||||||||||||||||||||||||||||||||||||||||||
| mermaid.initialize({ | ||||||||||||||||||||||||||||||||||||||||||||
| startOnLoad: true, | ||||||||||||||||||||||||||||||||||||||||||||
| theme: document.body.getAttribute("data-md-color-scheme") === "slate" ? "dark" : "default", | ||||||||||||||||||||||||||||||||||||||||||||
| securityLevel: "loose", | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // 5. Manually trigger rendering in case startOnLoad doesn't pick up the changes | ||||||||||||||||||||||||||||||||||||||||||||
| mermaid.run(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+23
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify current implementation has no mermaid availability guard
rg -n 'mermaid\.initialize|mermaid\.run|typeof\s+window\.mermaid|typeof\s+mermaid' en/docs/assets/js/mermaid-init.js
# Verify Mermaid runtime is externally loaded from CDN
rg -n 'extra_javascript|mermaid-init\.js|mermaid\.min\.js|unpkg\.com/mermaid' en/mkdocs.yml -C2Repository: wso2/docs-bi Length of output: 515 Fix Mermaid initialization: add runtime guard AND fix script loading order. Lines 23 and 30 call Two fixes required:
Proposed fixesIn - mermaid.initialize({
+ if (typeof window.mermaid === "undefined") {
+ console.error("Mermaid runtime is not available; diagrams were not rendered.");
+ return;
+ }
+
+ window.mermaid.initialize({
startOnLoad: true,
theme: document.body.getAttribute("data-md-color-scheme") === "slate" ? "dark" : "default",
securityLevel: "loose",
});
- mermaid.run();
+ window.mermaid.run();In extra_javascript:
- assets/lib/json-formatter/json-formatter.umd.js
- assets/lib/highlightjs/highlight.min.js
- assets/js/theme.js
- assets/js/copy-page.js
- - assets/js/mermaid-init.js
- https://unpkg.com/mermaid@10.6.1/dist/mermaid.min.js
+ - assets/js/mermaid-init.js📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
In Mermaid 10.6.1, what are the security differences between securityLevel "strict", "antiscript", and "loose", and which is recommended for untrusted markdown/diagram content?💡 Result:
In Mermaid 10.6.1,
securityLevelprimarily controls (a) whether Mermaid will allow raw HTML in diagram text/labels and (b) whether click interactions (e.g.,clickdirectives) are enabled:"strict"(default): HTML tags in text are encoded/escaped, and click functionality is disabled. This is the safest of the three. [1]"antiscript": HTML tags in text are allowed, but Mermaid removes only<script>elements; click functionality is enabled. This still leaves a much larger XSS/abuse surface thanstrict(because it allows HTML and interactivity). [1]"loose": HTML tags in text are allowed, and click functionality is enabled—the least restrictive / highest risk option. [1]Recommendation for untrusted markdown/diagram content: use
securityLevel: "strict"(and do not enableloose/antiscriptfor untrusted user input). [1][2]Sources:
[1] Mermaid config schema docs (
securityLevel) https://mermaid.js.org/config/schema-docs/config-properties-securitylevel.html[2] Example of risk when
securityLevel: "loose"enables clickable JS execution paths (advisory write-up) https://dbugs.ptsecurity.com/vulnerability/PT-2026-25086🏁 Script executed:
Repository: wso2/docs-bi
Length of output: 1452
🏁 Script executed:
Repository: wso2/docs-bi
Length of output: 226
🏁 Script executed:
Repository: wso2/docs-bi
Length of output: 3473
Change
securityLevel: "loose"tosecurityLevel: "strict"for documentation that accepts external contributions.Line 26 weakens Mermaid's security model. The
"loose"setting allows HTML tags in diagram text and enables click interactions, creating an XSS exposure risk for diagrams contributed via PRs or other external sources. The preprocessing in lines 5–20 only normalizes initial content and does not prevent Mermaid's rendering rules from interpreting malicious input.Mermaid's
"strict"mode (the default) escapes HTML and disables click functionality, making it the recommended setting for untrusted markdown/diagram content.Safer default
🤖 Prompt for AI Agents