Security and architecture review of current codebase. 11 findings: - 3 P1 (XSS, hardcoded creds, unbounded memory growth) - 4 P2 (SSE protocol, broker deadlock, NetworkMap architecture, CORS) - 4 P3 (security headers, error leakage, dead code, binary payload) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2.8 KiB
status, priority, issue_id, tags, dependencies
| status | priority | issue_id | tags | dependencies | |||||
|---|---|---|---|---|---|---|---|---|---|
| pending | p2 | 006 |
|
NetworkMap.tsx Functions Redeclared in Component Body Every Render
Problem Statement
initializeMap, updateNodeMarkers, createMarker, updateMarker, and showInfoWindow are declared inside the component function body without useCallback. They are redeclared on every render, cannot be properly listed in dependency arrays, and are the direct cause of the /* eslint-disable react-hooks/exhaustive-deps */ at the top of the file. The planned topology polyline feature will make this worse if it follows the same pattern.
Findings
- File:
web/src/components/dashboard/NetworkMap.tsx, lines 261-455, line 1 (eslint-disable) tryInitializeMapuseCallback (line 133) listsupdateNodeMarkersandinitializeMapin deps — but these change every render, defeating memoization- The
eslint-disablesuppression acknowledges the problem but doesn't fix it - Adding polyline management code to this pattern makes the component increasingly difficult to reason about
Proposed Solutions
Option A: Extract to module-level pure functions (Recommended)
Move functions that don't access component state/refs directly (e.g., getMarkerIcon, marker content builders) to module-level. Pass refs/state as parameters.
- Pros: Cleanest; enables proper useCallback dependency arrays; allows tree-shaking
- Effort: Medium
- Risk: Low
Option B: Wrap all in useCallback with correct deps
Convert all functions to useCallback with proper dependency lists. Remove the eslint-disable.
- Pros: Fixes the hook rules without restructuring
- Cons: Still keeps large functions in the component body
- Effort: Medium
- Risk: Low
Option C: Leave as-is, document for topology addition
Accept the pattern and apply it consistently for topology polylines. Remove the eslint-disable only when refactoring later.
- Effort: None now
- Cons: Technical debt grows; makes the topology feature harder to test
- Risk: Medium (ongoing)
Recommended Action
At minimum, do Option A for module-level pure helpers before adding topology polyline code. The topology feature addition is a natural trigger for this cleanup.
Technical Details
- Affected file:
web/src/components/dashboard/NetworkMap.tsx - This should be addressed before or alongside the topology polyline rendering implementation
Acceptance Criteria
- The
/* eslint-disable react-hooks/exhaustive-deps */comment is removed - All
useCallbackhooks have accurate, complete dependency arrays - Adding polyline management code does not require more eslint suppression
Work Log
- 2026-03-15: Identified by architecture-strategist review agent