A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
feat(app): graph minimap + lod for edges
dextmorgn67bfd115dc8e
diff --git a/flowsint-app/src/components/sketches/details-panel/neighbors.tsx b/flowsint-app/src/components/sketches/details-panel/neighbors.tsxindex 58202956..e4a04b94 100644--- a/flowsint-app/src/components/sketches/details-panel/neighbors.tsx+++ b/flowsint-app/src/components/sketches/details-panel/neighbors.tsx@@ -39,6 +39,7 @@ const NeighborsGraph = memo(instanceId="neighbors"allowForces={true}autoZoomOnNode={false}+ showMinimap={false}/></>)}diff --git a/flowsint-app/src/components/sketches/graph/index.tsx b/flowsint-app/src/components/sketches/graph/index.tsxindex 2af5e3eb..48c4e8a4 100644--- a/flowsint-app/src/components/sketches/graph/index.tsx+++ b/flowsint-app/src/components/sketches/graph/index.tsx@@ -22,6 +22,7 @@ import { GraphEmptyState } from './graph-empty-state'import { GraphTooltip } from './graph-tooltip'import { GraphLoadingOverlay } from './graph-loading-overlay'import { GraphSelectorOverlay } from './graph-selector-overlay'+import MinimapCanvas from './minimap'const GraphViewer: React.FC<GraphViewerProps> = ({nodes,@@ -41,7 +42,8 @@ const GraphViewer: React.FC<GraphViewerProps> = ({allowLasso = false,sketchId,allowForces = false,- autoZoomOnNode = true+ autoZoomOnNode = true,+ showMinimap}) => {const [containerSize, setContainerSize] = useState({ width: 0, height: 0 })const graphRef = useRef<any>(null)@@ -55,6 +57,7 @@ const GraphViewer: React.FC<GraphViewerProps> = ({const setActions = useGraphControls((s) => s.setActions)const setCurrentLayoutType = useGraphControls((s) => s.setCurrentLayoutType)const autoZoomOnCurrentNode = useGraphSettingsStore((s) => s.getSettingValue('general', 'autoZoomOnCurrentNode'))+ const showMinimapSetting = useGraphSettingsStore((s) => s.getSettingValue('general', 'showMinimap'))const forceSettings = useGraphSettingsStore((s) => s.forceSettings)const setImportModalOpen = useGraphSettingsStore((s) => s.setImportModalOpen)@@ -344,6 +347,14 @@ const GraphViewer: React.FC<GraphViewerProps> = ({containerSize={containerSize}/>)}+ {(showMinimap ?? showMinimapSetting) && graphData.nodes.length > 0 && (+ <MinimapCanvas+ nodes={graphData.nodes}+ graphRef={graphRef}+ canvasWidth={containerSize.width}+ canvasHeight={containerSize.height}+ />+ )}<GraphLoadingOverlay isVisible={isRegeneratingLayout} /></div>)diff --git a/flowsint-app/src/components/sketches/graph/link-renderer.ts b/flowsint-app/src/components/sketches/graph/link-renderer.tsindex 76890fb6..263a7564 100644--- a/flowsint-app/src/components/sketches/graph/link-renderer.ts+++ b/flowsint-app/src/components/sketches/graph/link-renderer.ts@@ -12,6 +12,60 @@ interface LinkRenderParams {currentEdge: any}+// Helper to check if a node position is in viewport+const isPositionInViewport = (x: number, y: number, ctx: CanvasRenderingContext2D, margin: number = 80): boolean => {+ const transform = ctx.getTransform()+ const canvasWidth = ctx.canvas.width+ const canvasHeight = ctx.canvas.height++ // Transform position to screen coordinates+ const screenX = x * transform.a + transform.e+ const screenY = y * transform.d + transform.f++ // Check if within viewport bounds (with margin for smoother culling)+ return (+ screenX >= -margin &&+ screenX <= canvasWidth + margin &&+ screenY >= -margin &&+ screenY <= canvasHeight + margin+ )+}++// Helper to check if edge is in viewport (at least one endpoint or edge crosses viewport)+const isEdgeInViewport = (link: any, ctx: CanvasRenderingContext2D, margin: number = 80): boolean => {+ const { source: start, target: end } = link+ if (typeof start !== 'object' || typeof end !== 'object') return false++ // Check if either endpoint is in viewport+ const startInView = isPositionInViewport(start.x, start.y, ctx, margin)+ const endInView = isPositionInViewport(end.x, end.y, ctx, margin)++ if (startInView || endInView) return true++ // Check if edge crosses viewport (both endpoints outside but line passes through)+ const transform = ctx.getTransform()+ const canvasWidth = ctx.canvas.width+ const canvasHeight = ctx.canvas.height++ const screenStartX = start.x * transform.a + transform.e+ const screenStartY = start.y * transform.d + transform.f+ const screenEndX = end.x * transform.a + transform.e+ const screenEndY = end.y * transform.d + transform.f++ // Simple AABB intersection check+ const minX = Math.min(screenStartX, screenEndX)+ const maxX = Math.max(screenStartX, screenEndX)+ const minY = Math.min(screenStartY, screenEndY)+ const maxY = Math.max(screenStartY, screenEndY)++ return !(+ maxX < -margin ||+ minX > canvasWidth + margin ||+ maxY < -margin ||+ minY > canvasHeight + margin+ )+}+export const renderLink = ({link,ctx,@@ -28,6 +82,9 @@ export const renderLink = ({const { source: start, target: end } = linkif (typeof start !== 'object' || typeof end !== 'object') return+ // Early exit: skip edge if outside viewport+ if (!isEdgeInViewport(link, ctx)) return+const linkKey = `${start.id}-${end.id}`const isHighlighted = highlightLinks.has(linkKey)const isSelected = selectedEdges.some((e) => e.id === link.id)diff --git a/flowsint-app/src/components/sketches/graph/minimap.tsx b/flowsint-app/src/components/sketches/graph/minimap.tsxnew file mode 100644index 00000000..4f689f75--- /dev/null+++ b/flowsint-app/src/components/sketches/graph/minimap.tsx@@ -0,0 +1,177 @@+import { useEffect, useRef } from 'react'+import { GraphNode } from '@/types'++interface MinimapCanvasProps {+ nodes: GraphNode[]+ width?: number+ height?: number+ graphRef: React.RefObject<any>+ canvasWidth: number+ canvasHeight: number+}++const MinimapCanvas = ({+ nodes,+ width = 160,+ height = 120,+ graphRef,+ canvasWidth,+ canvasHeight+}: MinimapCanvasProps) => {+ const canvasRef = useRef<HTMLCanvasElement>(null)+ const animationFrameRef = useRef<number | null>(null)++ useEffect(() => {+ const canvas = canvasRef.current+ const ctx = canvas?.getContext('2d')+ if (!canvas || !ctx) return++ // Calculate bounding box of all nodes+ const getBounds = () => {+ const validNodes = nodes.filter((n) => typeof n.x === 'number' && typeof n.y === 'number')+ if (validNodes.length === 0) return null++ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity++ for (const node of validNodes) {+ if (node.x && node.x < minX) minX = node.x+ if (node.x && node.x > maxX) maxX = node.x+ if (node.y && node.y < minY) minY = node.y+ if (node.y && node.y > maxY) maxY = node.y+ }++ return { minX, minY, maxX, maxY }+ }++ const renderMinimap = () => {+ if (!graphRef.current) return++ const bounds = getBounds()+ if (!bounds) return++ const { minX, minY, maxX, maxY } = bounds++ try {+ // Check if required methods exist+ if (typeof graphRef.current.graph2ScreenCoords !== 'function' ||+ typeof graphRef.current.zoom !== 'function') {+ return+ }++ // Get the current zoom state from the graph+ const k = graphRef.current.zoom() || 1++ // Calculate viewport bounds in world coordinates+ const invScale = 1 / k+ const viewportWidth = canvasWidth * invScale+ const viewportHeight = canvasHeight * invScale++ // Get center position - use centerAt if available, otherwise default to origin+ let centerX = 0+ let centerY = 0++ if (typeof graphRef.current.centerAt === 'function') {+ const center = graphRef.current.centerAt()+ centerX = center?.x ?? 0+ centerY = center?.y ?? 0+ }++ const viewportX1 = centerX - viewportWidth / 2+ const viewportY1 = centerY - viewportHeight / 2+ const viewportX2 = centerX + viewportWidth / 2+ const viewportY2 = centerY + viewportHeight / 2++ // Expand bounds to include viewport+ const worldMinX = Math.min(minX, viewportX1)+ const worldMinY = Math.min(minY, viewportY1)+ const worldMaxX = Math.max(maxX, viewportX2)+ const worldMaxY = Math.max(maxY, viewportY2)++ const worldWidth = worldMaxX - worldMinX || 1+ const worldHeight = worldMaxY - worldMinY || 1++ // Scale to fit in minimap+ const scaleX = width / worldWidth+ const scaleY = height / worldHeight+ const scale = Math.min(scaleX, scaleY) * 0.9 // 0.9 for padding++ // Center content+ const offsetX = (width - worldWidth * scale) / 2+ const offsetY = (height - worldHeight * scale) / 2++ // Project function+ const project = (x: number, y: number): [number, number] => [+ (x - worldMinX) * scale + offsetX,+ (y - worldMinY) * scale + offsetY+ ]++ // Clear canvas+ ctx.clearRect(0, 0, width, height)++ // Draw nodes+ const nodeRadius = .75+ for (const node of nodes) {+ if (typeof node.x !== 'number' || typeof node.y !== 'number') continue++ const [cx, cy] = project(node.x, node.y)++ ctx.beginPath()+ ctx.arc(cx, cy, nodeRadius, 0, 2 * Math.PI)+ ctx.fillStyle = node.nodeColor || '#888'+ ctx.fill()+ }++ // Draw viewport rectangle+ const [vx1, vy1] = project(viewportX1, viewportY1)+ const [vx2, vy2] = project(viewportX2, viewportY2)++ const rectWidth = Math.abs(vx2 - vx1)+ const rectHeight = Math.abs(vy2 - vy1)+ const rectX = Math.min(vx1, vx2)+ const rectY = Math.min(vy1, vy2)++ ctx.strokeStyle = 'rgba(255, 115, 0, 0.8)'+ ctx.fillStyle = 'rgba(255, 115, 0, 0.1)'+ ctx.lineWidth = 1.4+ ctx.beginPath()+ ctx.roundRect(rectX, rectY, rectWidth, rectHeight, 4)+ ctx.fill()+ ctx.stroke()++ } catch (error) {+ // Silent fail if graph not ready+ return+ }+ }++ // Render loop+ const animate = () => {+ renderMinimap()+ animationFrameRef.current = requestAnimationFrame(animate)+ }++ animate()++ return () => {+ if (animationFrameRef.current) {+ cancelAnimationFrame(animationFrameRef.current)+ }+ }+ }, [nodes, width, height, graphRef, canvasWidth, canvasHeight])++ return (+ <div+ style={{ width, height }}+ className="absolute bottom-3 right-3 bg-background/90 backdrop-blur-sm overflow-hidden border border-border rounded-lg"+ >+ <canvas+ ref={canvasRef}+ width={width}+ height={height}+ className="bg-transparent"+ />+ </div>+ )+}++export default MinimapCanvasdiff --git a/flowsint-app/src/components/sketches/graph/types.ts b/flowsint-app/src/components/sketches/graph/types.tsindex 38cdaecb..8f94fdfc 100644--- a/flowsint-app/src/components/sketches/graph/types.ts+++ b/flowsint-app/src/components/sketches/graph/types.ts@@ -19,6 +19,7 @@ export interface GraphViewerProps {sketchId?: stringallowForces?: booleanautoZoomOnNode?: boolean+ showMinimap?: boolean}export interface TooltipData {diff --git a/flowsint-app/src/components/sketches/minimap.tsx b/flowsint-app/src/components/sketches/minimap.tsxdeleted file mode 100644index 6a29853d..00000000--- a/flowsint-app/src/components/sketches/minimap.tsx+++ /dev/null@@ -1,141 +0,0 @@-import { GraphNode } from '@/types'-import { useMemo } from 'react'-import { GRAPH_COLORS } from './graph-viewer'--interface zoomEnricher {- x: number- y: number- k: number-}-interface MinimapProps {- nodes: GraphNode[]- zoomEnricher: zoomEnricher- width?: number- height?: number- canvasWidth: number- canvasHeight: number-}-const Minimap = ({- nodes,- zoomEnricher,- width = 160,- height = 120,- canvasWidth = 800,- canvasHeight = 600-}: MinimapProps) => {- // Calculate the visible viewport in world coordinates- const invScale = 1 / zoomEnricher.k-- // The viewport center in world coordinates- // zoomEnricher.x and zoomEnricher.y are screen offsets, so we need to convert them- const viewportCenterX = zoomEnricher.x * invScale- const viewportCenterY = zoomEnricher.y * invScale-- // Viewport dimensions in world coordinates- const viewportWidth = canvasWidth * invScale- const viewportHeight = canvasHeight * invScale-- // Viewport bounds in world coordinates- const viewportX1 = viewportCenterX - viewportWidth / 2- const viewportY1 = viewportCenterY - viewportHeight / 2- const viewportX2 = viewportCenterX + viewportWidth / 2- const viewportY2 = viewportCenterY + viewportHeight / 2-- // Calculate global bounding box including nodes and viewport- const [minX, minY, maxX, maxY] = useMemo(() => {- const validNodes = nodes.filter((n) => typeof n.x === 'number' && typeof n.y === 'number')-- if (validNodes.length === 0) {- // If no nodes, just show the viewport- return [viewportX1, viewportY1, viewportX2, viewportY2]- }-- const nodeXs = validNodes.map((n) => n.x)- const nodeYs = validNodes.map((n) => n.y)-- const allX = [...nodeXs, viewportX1, viewportX2]- const allY = [...nodeYs, viewportY1, viewportY2]-- return [- Math.min(...allX.filter((x): x is number => x !== undefined)),- Math.min(...allY.filter((y): y is number => y !== undefined)),- Math.max(...allX.filter((x): x is number => x !== undefined)),- Math.max(...allY.filter((y): y is number => y !== undefined))- ]- }, [nodes, viewportX1, viewportY1, viewportX2, viewportY2])-- const worldWidth = maxX - minX || 1- const worldHeight = maxY - minY || 1-- // Scale to fit everything in the minimap- const scaleX = width / worldWidth- const scaleY = height / worldHeight- const scale = Math.min(scaleX, scaleY)-- // Center the minimap content- const offsetX = (width - worldWidth * scale) / 2- const offsetY = (height - worldHeight * scale) / 2-- // Project world coordinates to minimap coordinates- const project = (x, y) => [(x - minX) * scale + offsetX, (y - minY) * scale + offsetY]-- // Project viewport bounds to minimap coordinates- const [vx1, vy1] = project(viewportX1, viewportY1)- const [vx2, vy2] = project(viewportX2, viewportY2)-- // Calculate viewBox dimensions with padding- const viewBoxWidth = Math.abs(vx2 - vx1) + 6- const viewBoxHeight = Math.abs(vy2 - vy1) + 6-- // Position the viewBox to show the current viewport- const viewBoxX = Math.min(vx1, vx2) - 3- const viewBoxY = Math.min(vy1, vy2) - 3-- // Fixed node radius for consistent sizing- const nodeRadius = 2-- return (- <div- style={{ width: width, height: height }}- className="absolute bottom-3 right-3 bg-background/90 backdrop-blur-sm overflow-hidden border border-border rounded-lg"- >- <svg- width={width}- height={height}- className="bg-transparent"- style={{ backgroundColor: 'transparent' }}- >- {nodes- .filter((n: GraphNode) => typeof n.x === 'number' && typeof n.y === 'number')- .map((n: GraphNode, i: number) => {- const [cx, cy] = project(n.x, n.y)- return (- <circle- key={i}- cx={cx}- cy={cy}- r={nodeRadius}- fill={n.nodeColor || 'currentColor'}- className="text-foreground"- />- )- })}-- {/* Viewport rectangle - shows current visible area */}- <rect- x={viewBoxX}- y={viewBoxY}- rx={4}- ry={4}- width={viewBoxWidth}- height={viewBoxHeight}- fill={GRAPH_COLORS.LASSO_FILL}- stroke={GRAPH_COLORS.LASSO_STROKE}- strokeWidth={1}- />- </svg>- </div>- )-}--export default Minimapdiff --git a/flowsint-app/src/stores/graph-settings-store.ts b/flowsint-app/src/stores/graph-settings-store.tsindex 195e3b0f..eb00f970 100644--- a/flowsint-app/src/stores/graph-settings-store.ts+++ b/flowsint-app/src/stores/graph-settings-store.ts@@ -17,6 +17,12 @@ const DEFAULT_SETTINGS = {value: true,description: 'Automatically zoom to the current node when it changes.'},+ showMinimap: {+ name: 'Show Minimap',+ type: 'boolean',+ value: true,+ description: 'Display the minimap overview of the graph.'+ },},graph: {nodeSize: {diff --git a/flowsint-enrichers/src/flowsint_enrichers/domain/to_dummy_individuals.py b/flowsint-enrichers/src/flowsint_enrichers/domain/to_dummy_individuals.pynew file mode 100644index 00000000..90e62256--- /dev/null+++ b/flowsint-enrichers/src/flowsint_enrichers/domain/to_dummy_individuals.py@@ -0,0 +1,64 @@+import socket+from typing import Dict, List+from flowsint_core.core.logger import Logger+from flowsint_core.core.enricher_base import Enricher+from flowsint_enrichers.registry import flowsint_enricher+from flowsint_types.domain import Domain+from flowsint_types.email import Email+from flowsint_types.ip import Ip+++@flowsint_enricher+class ToDummyEnricher(Enricher):+ """ToDummyEnricher"""++ InputType = Domain+ OutputType = Ip++ @classmethod+ def name(cls) -> str:+ return "domain_to_dummy"++ @classmethod+ def category(cls) -> str:+ return "Domain"++ @classmethod+ def key(cls) -> str:+ return "domain"++ @classmethod+ def documentation(cls) -> str:+ """Return formatted markdown documentation for the domain resolver enricher."""+ return ""++ async def scan(self, data: List[InputType]) -> List[OutputType]:+ results: Dict[str, List[OutputType]] = {}+ for d in data:+ # Add dummy related items+ related = [+ Domain(domain=f"sub.{d.domain}"),+ Email(email=f"{d.domain}@domain.com"),+ ]+ results[d.domain] = related+ return results++ def postprocess(+ self, results: Dict[str, List[OutputType]], original_input: List[InputType]+ ) -> List[OutputType]:+ for domain in results:+ root = Domain(domain=domain)+ self.create_node(root)+ for item in results[domain]:+ self.create_node(item)+ self.create_relationship(+ root,+ item,+ "IS_RELATED_T0",+ )+ self.log_graph_message(f"Dummy enricher finished.")+ return results+++InputType = ToDummyEnricher.InputType+OutputType = ToDummyEnricher.OutputType