fix: resolve CodeQL JavaScript code-scanning alerts in Studio#4386
Conversation
Fixes the 8 live CodeQL JS alerts on main, all in Studio application code: xss-through-dom: - studio-database.js: render current database name with .text() instead of .html() - studio-utils.js: escape the database name fed into the backupDatabase() confirm dialog - index.html: set toast title/message via textContent instead of innerHTML - studio-database.js: serve flame-graph tooltips from an in-memory array keyed by index instead of round-tripping HTML through a data attribute and re-parsing it incomplete-sanitization: - studio-record-editor.js: escape backslash before the single quote when building SQL string literals - studio-database.js / studio-profiler.js: replace inline onclick string interpolation with data attributes and delegated click handlers
There was a problem hiding this comment.
Code Review
This pull request introduces several security and robustness improvements across the web studio frontend. Key changes include mitigating potential XSS vulnerabilities by replacing raw HTML string concatenation with safe DOM APIs (such as .textContent and jQuery's .text()), escaping HTML values in database and profiler modules, refactoring flame graph tooltips to store HTML in memory rather than in DOM attributes, and replacing inline onclick handlers with jQuery event listeners. Additionally, SQL string escaping in the record editor was improved to correctly escape backslashes. There are no review comments to address, and the changes look solid.
Up to standards ✅🟢 Issues
|
Code ReviewThe direction of this PR is correct - moving from inline Bug 1 (Regression - Medium):
|
Summary
Resolves the 8 live CodeQL JavaScript code-scanning alerts on
main. All are in Studio application JS (studio/src/main/resources/static/); the latest CodeQL analysis at HEAD contains exactly these 8 results.xss-through-dom
studio-database.js(Node Time Dimension ( Time Series ) #702): render the current database name with.text()instead of.html().studio-utils.js(What performance gain should I be expecting with indexes on graph databases? #1417):escapeHtml()the database name fed into thebackupDatabase()confirm dialog, matching the existingdropDatabase/resetDatabasepattern.index.html(Error on RemoteMutableVertex getType call. #1420): set toasttitle/messageviatextContentinstead of buildinginnerHTML.studio-database.js(Introduce a constructor in RID class that takes only a String rid #1421): serve flame-graph tooltips from an in-memory array keyed by index (data-flame-tip-idx) instead of round-tripping already-escaped HTML through adata-flame-tipattribute and re-parsing it via.html().incomplete-sanitization
studio-record-editor.js(Is it possible to run a whole database in-memory? #1418, Introductory Tutorial #1654): escape backslash before the single quote when building SQL string literals (\\then\', per ArcadeDB SQL escaping).studio-database.js(build(deps): bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.3 to 3.2.5 #1424) andstudio-profiler.js(build(deps): bump mockito-core.version from 5.9.0 to 5.10.0 #1457): replace fragile inlineonclick="fn('...')"string interpolation withdata-*attributes and delegated click handlers.Note on the other ~31 "open" JS alerts
Those reference
studio/src/main/resources/static/components/DataTables/**(deleted in #2260) or code that was refactored away. They are absent from the current analysis and only lingered open because the CodeQL analysis category was renamed (javascript→javascript-typescript), which prevented GitHub's auto-close. They have been dismissed separately as stale.Test plan
node --checkpasses on all three edited.jsfilesNote: webpack does not process Studio application JS (it only copies vendor libs), so there is no bundling/build step for these files.