A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
feat(app): restrict nodes in area + disableNative forces
dextmorgn5c74bd32e5a7
diff --git a/flowsint-app/src/components/graphs/details-panel/neighbors.tsx b/flowsint-app/src/components/graphs/details-panel/neighbors.tsxindex fa3e3175..947af987 100644--- a/flowsint-app/src/components/graphs/details-panel/neighbors.tsx+++ b/flowsint-app/src/components/graphs/details-panel/neighbors.tsx@@ -30,13 +30,14 @@ const NeighborsGraph = memo(<ForceGraphViewernodes={neighborsData.nds}edges={neighborsData.rls}- onNodeClick={() => {}}- onNodeRightClick={() => {}}- onBackgroundClick={() => {}}+ onNodeClick={() => { }}+ onNodeRightClick={() => { }}+ onBackgroundClick={() => { }}showLabels={true}showIcons={true}backgroundColor="transparent"instanceId="neighbors"+ allowForces={true}/></>)}diff --git a/flowsint-app/src/components/graphs/graph-viewer.tsx b/flowsint-app/src/components/graphs/graph-viewer.tsxindex b50229af..8f7c3aa9 100644--- a/flowsint-app/src/components/graphs/graph-viewer.tsx+++ b/flowsint-app/src/components/graphs/graph-viewer.tsx@@ -26,7 +26,7 @@ interface GraphViewerProps {onNodeRightClick?: (node: GraphNode, event: MouseEvent) => voidonEdgeRightClick?: (edge: GraphEdge, event: MouseEvent) => voidonBackgroundClick?: () => void- onBackgroundRightClick: (event: MouseEvent) => void+ onBackgroundRightClick?: (event: MouseEvent) => voidshowLabels?: booleanshowIcons?: booleanbackgroundColor?: string@@ -36,6 +36,7 @@ interface GraphViewerProps {instanceId?: string // Add instanceId prop for instance-specific actionsallowLasso?: booleansketchId?: string // Add sketchId for saving node positions+ allowForces?: boolean}// Graph viewer specific colors@@ -134,7 +135,8 @@ const GraphViewer: React.FC<GraphViewerProps> = ({onGraphRef,instanceId,allowLasso = false,- sketchId+ sketchId,+ allowForces = false}) => {const [containerSize, setContainerSize] = useState({ width: 0, height: 0 })const isSelectorModeActive = useGraphControls((s) => s.isSelectorModeActive)@@ -1140,7 +1142,7 @@ const GraphViewer: React.FC<GraphViewerProps> = ({linkCurvature={(link) => link.curvature || 0}nodeCanvasObject={renderNode}onNodeDragEnd={handleNodeDragEnd}- cooldownTicks={forceSettings.cooldownTicks.value}+ cooldownTicks={allowForces ? forceSettings.cooldownTicks.value : 0}cooldownTime={forceSettings.cooldownTime.value}d3AlphaDecay={forceSettings.d3AlphaDecay.value}d3AlphaMin={forceSettings.d3AlphaMin.value}diff --git a/flowsint-app/src/hooks/use-layout.ts b/flowsint-app/src/hooks/use-layout.tsindex d7769a96..6b781e0d 100644--- a/flowsint-app/src/hooks/use-layout.ts+++ b/flowsint-app/src/hooks/use-layout.ts@@ -102,13 +102,18 @@ export function useLayout({},})} else {+ const width = containerSize.width || 800+ const height = containerSize.height || 600+ // Calculate maxRadius as 40% of the smallest dimension to keep nodes in view+ const maxRadius = Math.min(width, height) *2+worker.postMessage({type: 'force',nodes: nodes.map(n => ({ ...n })),edges: edges.map(e => ({ ...e })),options: {- width: containerSize.width || 800,- height: containerSize.height || 600,+ width,+ height,chargeStrength: forceSettings.d3ForceChargeStrength?.value ?? -30,linkDistance: forceSettings.d3ForceLinkDistance?.value ?? 30,linkStrength: forceSettings.d3ForceLinkStrength?.value ?? 2,@@ -116,6 +121,7 @@ export function useLayout({alphaMin: forceSettings.d3AlphaMin?.value ?? 0,velocityDecay: forceSettings.d3VelocityDecay?.value ?? 0.41,iterations: forceSettings.cooldownTicks?.value ?? 300,+ maxRadius,},})}diff --git a/flowsint-app/src/workers/layout.worker.ts b/flowsint-app/src/workers/layout.worker.tsindex 531a5c49..7c78a06c 100644--- a/flowsint-app/src/workers/layout.worker.ts+++ b/flowsint-app/src/workers/layout.worker.ts@@ -41,6 +41,7 @@ interface ForceLayoutOptions {alphaMin?: numbervelocityDecay?: numberiterations?: number+ maxRadius?: number}interface LayoutMessage {@@ -114,6 +115,7 @@ function computeForceLayout(alphaMin = 0,velocityDecay = 0.41,iterations = 300,+ maxRadius,} = options// Create simulation nodes with initial random positions@@ -151,9 +153,28 @@ function computeForceLayout(// Send progress updates every 10 iterationsconst progressInterval = Math.max(1, Math.floor(iterations / 10))+ const centerX = width / 2+ const centerY = height / 2+for (let i = 0; i < iterations; i++) {simulation.tick()+ // Apply circular boundary constraint if maxRadius is specified+ if (maxRadius !== undefined && maxRadius > 0) {+ simNodes.forEach((node: any) => {+ const dx = node.x - centerX+ const dy = node.y - centerY+ const distance = Math.sqrt(dx * dx + dy * dy)++ // If node is outside the circle, push it back to the edge+ if (distance > maxRadius) {+ const ratio = maxRadius / distance+ node.x = centerX + dx * ratio+ node.y = centerY + dy * ratio+ }+ })+ }+// Send progress updatesif (i % progressInterval === 0 || i === iterations - 1) {self.postMessage({