Skip to content

[high] fix: graph.js mouseover throws for all MITRE ATT&CK galaxies (invalid CSS selector) - #1277

Open
elhoim wants to merge 1 commit into
MISP:mainfrom
elhoim:fix/graphjs-css-selector
Open

elhoim wants to merge 1 commit into
MISP:mainfrom
elhoim:fix/graphjs-css-selector

Conversation

@elhoim

@elhoim elhoim commented Aug 30, 2026

Copy link
Copy Markdown
Member

BLUF — graph.js mouseover throws for every MITRE ATT&CK galaxy because the CSS selector is invalid

  • Problemgraph.js builds a CSS class from a galaxy name with an expression that only strips whitespace and dots, then queries with the same expression, so any other character goes into the selector raw and document.querySelectorAll throws a DOMException that aborts the mouseover handler. 17 of the 131 galaxy names hit this, including every MITRE ATT&CK galaxy (the ampersand), plus names containing parentheses and a slash.
  • Fix — Introduce one galaxyClass() helper replacing every character outside [A-Za-z0-9_-], used at all six assign and select sites so the two cannot drift.
  • Effect — Node highlight, legend emphasis and link highlighting work again on the galaxies people browse most.

Problem

graph.js builds a CSS class from a galaxy name and later looks it up with a selector built the same way — six sites, all carrying a copy of the same expression:

d3.selectAll(".legend-text.galaxy-" + d.galaxy.replace(/\s+/g, '-').replace(/[\s.]/g, '-'))

Only whitespace and . are replaced. Everything else goes into the selector untouched, and a class selector may only contain [A-Za-z0-9_-] (plus non-ASCII and escapes). document.querySelectorAll throws a DOMException on anything else, which aborts the handler that called it.

17 of the 131 galaxy names produce an invalid selector — including every MITRE ATT&CK * galaxy:

"MITRE ATT&CK Techniques"     -> .galaxy-MITRE-ATT&CK-Techniques      (&)
"MITRE ATT&CK Groups"         -> .galaxy-MITRE-ATT&CK-Groups          (&)
"Concealment Layers ... (CLOAK)" -> .galaxy-...-Knowledge-(CLOAK)     ( and )
"UAVs/UCAVs"                  -> .galaxy-UAVs/UCAVs                   (/)

15 names contain &, one contains (), one contains /. Hovering a node in any of those galaxies throws, so the mouseover highlight, the legend emphasis and the link highlighting all stop working for exactly the galaxies people use most.

Fix

One galaxyClass() helper that replaces every character outside [A-Za-z0-9_-], used at all six sites — the three that assign the class and the three that select on it — so the two can no longer drift apart.

All 131 galaxy names are ASCII (checked), so no non-ASCII identifiers are being flattened, and no stylesheet hardcodes these class names (grep -rn "galaxy-" stylesheets/ is empty), so renaming them affects nothing else.

Verification

galaxies: 131
invalid class selectors -- committed expression: 17
invalid class selectors -- galaxyClass()       : 0

  "MITRE ATT&CK Analytics"
      before: .galaxy-MITRE-ATT&CK-Analytics
      after : .galaxy-MITRE-ATT-CK-Analytics
  "UAVs/UCAVs"
      before: .galaxy-UAVs/UCAVs
      after : .galaxy-UAVs-UCAVs

node --check graph.js passes, and no hand-rolled copy of the expression remains in the file.

🤖 Generated with Claude Code

…ndler

graph.js builds a class from a galaxy name and looks it up with a selector
built the same way, replacing only whitespace and ".":

  d3.selectAll(".legend-text.galaxy-" + d.galaxy.replace(/\s+/g,'-').replace(/[\s.]/g,'-'))

A class selector may only contain [A-Za-z0-9_-]; querySelectorAll throws a
DOMException on anything else and aborts the calling handler. 17 of the 131
galaxy names hit this -- 15 contain "&" (every "MITRE ATT&CK *" galaxy), one
"()" and one "/" -- so node mouseover, legend emphasis and link
highlighting are all dead for exactly the busiest galaxies.

Add one galaxyClass() helper replacing every character outside
[A-Za-z0-9_-], used at all six sites (three that assign the class, three
that select on it) so the two cannot drift apart.

All 131 names are ASCII and no stylesheet hardcodes these classes, so the
rename affects nothing else.

Verified: 17 invalid selectors -> 0; node --check passes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HZGwPoa8MMfkhCw47rDLA4
@elhoim elhoim changed the title fix: graph.js mouseover throws for all MITRE ATT&CK galaxies (invalid CSS selector) [high] fix: graph.js mouseover throws for all MITRE ATT&CK galaxies (invalid CSS selector) Sep 3, 2026
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