ARES - authorized red-team engagement automation with dashboard, campaign scope, module orchestration, OPSEC controls, encrypted vault, and reporting.
Python active-directorycloud-securitydefensive-validationfastapigood-first-issuemitre-attackopsecreactred-teamreportingsecurity
feat(graph): convert pivot graph to wide horizontal landscape layout with high-contrast badge legibility
Mafifrizicacbe8a18031
diff --git a/frontend/src/features/graph/CobaltStrikeNodes.tsx b/frontend/src/features/graph/CobaltStrikeNodes.tsxindex ad4e625..3976c53 100644--- a/frontend/src/features/graph/CobaltStrikeNodes.tsx+++ b/frontend/src/features/graph/CobaltStrikeNodes.tsx@@ -171,19 +171,21 @@ export const PivotComputerNode = memo(function PivotComputerNode({ data, selectelet privilegeText =isElevated ? "SYSTEM *" :- privilege === "user" ? (nodeData.process || (nodeData.metadata?.user ? String(nodeData.metadata.user) : "BEACON")) :+ privilege === "user" ? (nodeData.metadata?.user ? String(nodeData.metadata.user) : (nodeData.process || "BEACON")) :(nodeData.label || "TARGET");- if (privilegeText.length > 20) {- privilegeText = privilegeText.slice(0, 18) + "…";+ if (privilegeText.length > 26) {+ privilegeText = privilegeText.slice(0, 24) + "…";}let subText = nodeData.subLabel || nodeData.ip || nodeData.label || "10.0.0.1";if (subText.includes("\n")) {subText = subText.split("\n")[1] || subText.split("\n")[0];}- if (subText.length > 24) {- subText = subText.slice(0, 22) + "…";+ // Clean noisy prefixes like 'Exploit-Target: ' so meaningful hostnames/IPs are visible+ subText = subText.replace(/^(?:Exploit-Target|Target):\s*/i, "");+ if (subText.length > 28) {+ subText = subText.slice(0, 26) + "…";}return (diff --git a/frontend/src/features/graph/GraphPage.tsx b/frontend/src/features/graph/GraphPage.tsxindex 43ab3fd..a203067 100644--- a/frontend/src/features/graph/GraphPage.tsx+++ b/frontend/src/features/graph/GraphPage.tsx@@ -76,65 +76,150 @@ function cobaltPivotLayout(};const shouldDim = highlightedNodeIds.size > 0;-- // Build adjacency for dynamic positioning if nodes are not in FIXED_COORDINATES- const columnLevels = new Map<string, number>();const nodes = graph.nodes;const edges = graph.edges;- // Assign column levels via safe BFS with cycle detection- const inDegree = new Map<string, number>();- nodes.forEach((n) => inDegree.set(n.id, 0));- edges.forEach((e) => {- if (inDegree.has(e.target)) {- inDegree.set(e.target, (inDegree.get(e.target) ?? 0) + 1);- }- });-- const queue: string[] = [];- const visited = new Set<string>();+ const isDemoTopology = nodes.length <= 9 && nodes.every((n) => Boolean(FIXED_COORDINATES[n.id]));+ const dynamicCoords = new Map<string, { x: number; y: number }>();++ if (!isDemoTopology) {+ // 1. Build adjacency graph for safe BFS and stage derivation+ const inDegree = new Map<string, number>();+ const outgoingEdges = new Map<string, string[]>();+ nodes.forEach((n) => {+ inDegree.set(n.id, 0);+ outgoingEdges.set(n.id, []);+ });+ edges.forEach((e) => {+ if (inDegree.has(e.target)) {+ inDegree.set(e.target, (inDegree.get(e.target) ?? 0) + 1);+ }+ outgoingEdges.get(e.source)?.push(e.target);+ });++ // 2. Identify roots: firewall / perimeter ingress or nodes with in-degree 0+ const depthMap = new Map<string, number>();+ const visited = new Set<string>();+ const queue: string[] = [];++ nodes.forEach((n) => {+ const isFw = n.type === "firewall" || n.id.includes("firewall") || n.id.includes("ingress");+ if (isFw || (inDegree.get(n.id) ?? 0) === 0) {+ depthMap.set(n.id, 0);+ visited.add(n.id);+ queue.push(n.id);+ }+ });- nodes.forEach((n) => {- if ((inDegree.get(n.id) ?? 0) === 0 || n.type === "firewall") {- columnLevels.set(n.id, 0);- visited.add(n.id);- queue.push(n.id);+ if (queue.length === 0 && nodes.length > 0) {+ depthMap.set(nodes[0].id, 0);+ visited.add(nodes[0].id);+ queue.push(nodes[0].id);}- });-- if (queue.length === 0 && nodes.length > 0) {- columnLevels.set(nodes[0].id, 0);- visited.add(nodes[0].id);- queue.push(nodes[0].id);- }- // Guaranteed termination: Each node visited at most once, depth capped at 6 columns- while (queue.length > 0) {- const currId = queue.shift()!;- const currCol = columnLevels.get(currId) ?? 0;- const outgoing = edges.filter((e) => e.source === currId);- for (const edge of outgoing) {- const nextId = edge.target;- if (!visited.has(nextId)) {- visited.add(nextId);- columnLevels.set(nextId, Math.min(currCol + 1, 6));- queue.push(nextId);+ // 3. BFS traversal to calculate horizontal progression depth+ while (queue.length > 0) {+ const currId = queue.shift()!;+ const currDepth = depthMap.get(currId) ?? 0;+ const targets = outgoingEdges.get(currId) ?? [];+ for (const targetId of targets) {+ if (!visited.has(targetId)) {+ visited.add(targetId);+ depthMap.set(targetId, currDepth + 1);+ queue.push(targetId);+ }}}- }- // Any remaining nodes not reachable from root get assigned columns gracefully- nodes.forEach((n, idx) => {- if (!columnLevels.has(n.id)) {- columnLevels.set(n.id, (idx % 3) + 1);- }- });+ // 4. Assign semantic depths for any disconnected or isolated target nodes+ nodes.forEach((n) => {+ if (!depthMap.has(n.id)) {+ const inf = inferCobaltNodeData(n);+ const isDc = n.type === "dc" || n.label.toLowerCase().includes("dc") || inf.os === "windows-server";+ const isElevated = inf.privilege === "system" || inf.privilege === "admin";+ if (isDc) {+ depthMap.set(n.id, 4); // Far right: Crown Jewels / Domain Controllers+ } else if (isElevated) {+ depthMap.set(n.id, 3); // Internal Servers & Footholds+ } else if (inf.status === "active") {+ depthMap.set(n.id, 2); // Lateral Workstations+ } else {+ depthMap.set(n.id, 1); // DMZ / Perimeter targets+ }+ }+ });++ // 5. Ensure Crown Jewels and Domain Controllers always sit on the far-right tier+ const calculatedMaxDepth = Math.max(...Array.from(depthMap.values()), 1);+ nodes.forEach((n) => {+ const inf = inferCobaltNodeData(n);+ const isDc = n.type === "dc" || n.label.toLowerCase().includes("dc") || inf.os === "windows-server";+ if (isDc) {+ depthMap.set(n.id, Math.max(depthMap.get(n.id) ?? 0, calculatedMaxDepth));+ }+ });++ // 6. Group nodes by horizontal depth tiers+ const stageBuckets = new Map<number, SafeGraphNode[]>();+ nodes.forEach((n) => {+ const d = depthMap.get(n.id) ?? 0;+ if (!stageBuckets.has(d)) stageBuckets.set(d, []);+ stageBuckets.get(d)!.push(n);+ });++ const sortedDepths = Array.from(stageBuckets.keys()).sort((a, b) => a - b);++ // 7. Horizontal Layout Discipline (Menyamping):+ // Vertical height is strictly capped at MAX_ROWS (3 rows) so nodes NEVER cascade downwards!+ // Additional nodes in the same stage expand horizontally into sub-columns side-by-side.+ const MAX_ROWS = 3;+ const COL_PITCH = 240; // Horizontal spacing between adjacent node centers+ const ROW_PITCH = 150; // Vertical pitch allowing room for monitor + stand + 2-line badge+ const STAGE_GAP = 55; // Visual breathing gap between major architectural stages+ const START_X = 50;+ const START_Y = 50;++ let cursorX = START_X;++ sortedDepths.forEach((d) => {+ const stageNodes = stageBuckets.get(d)!;++ // Sort within stage for visual hierarchy and consistent lateral alignment:+ // Firewalls first, then SYSTEM/Admin elevations, then user beacons, then mapped targets+ stageNodes.sort((a, b) => {+ if (a.type === "firewall") return -1;+ if (b.type === "firewall") return 1;+ const aInf = inferCobaltNodeData(a);+ const bInf = inferCobaltNodeData(b);+ const prio = (priv?: string) => (priv === "system" ? 3 : priv === "admin" ? 2 : priv === "user" ? 1 : 0);+ const diff = prio(bInf.privilege) - prio(aInf.privilege);+ if (diff !== 0) return diff;+ return a.label.localeCompare(b.label);+ });- // Count items per column to space vertically- const colRows = new Map<number, number>();- const isDemoTopology = nodes.length <= 9 && nodes.every((n) => Boolean(FIXED_COORDINATES[n.id]));+ const count = stageNodes.length;+ const numSubCols = Math.max(1, Math.ceil(count / MAX_ROWS));++ for (let i = 0; i < count; i++) {+ const node = stageNodes[i];+ const subCol = Math.floor(i / MAX_ROWS);+ const row = i % MAX_ROWS;++ // Vertically center columns that have fewer than MAX_ROWS items+ const itemsInThisSubCol = Math.min(MAX_ROWS, count - subCol * MAX_ROWS);+ const verticalCenterOffset = ((MAX_ROWS - itemsInThisSubCol) * ROW_PITCH) / 2;++ const x = cursorX + subCol * COL_PITCH;+ const y = START_Y + row * ROW_PITCH + verticalCenterOffset;++ dynamicCoords.set(node.id, { x, y });+ }++ cursorX += numSubCols * COL_PITCH + STAGE_GAP;+ });+ }- const canvasNodes: CanvasNode[] = nodes.map((node, index) => {+ const canvasNodes: CanvasNode[] = nodes.map((node) => {const inferred = inferCobaltNodeData(node);let x: number;let y: number;@@ -143,11 +228,9 @@ function cobaltPivotLayout(x = FIXED_COORDINATES[node.id].x;y = FIXED_COORDINATES[node.id].y;} else {- const col = columnLevels.get(node.id) ?? (index % 4);- const row = colRows.get(col) ?? 0;- colRows.set(col, row + 1);- x = 50 + col * 220;- y = 50 + row * 140;+ const coord = dynamicCoords.get(node.id) ?? { x: 50, y: 150 };+ x = coord.x;+ y = coord.y;}const nodeType = inferred.os === "firewall" ? "pivotFirewall" : "pivotComputer";diff --git a/frontend/src/features/graph/graphCobalt.css b/frontend/src/features/graph/graphCobalt.cssindex 44c513c..f20a1a1 100644--- a/frontend/src/features/graph/graphCobalt.css+++ b/frontend/src/features/graph/graphCobalt.css@@ -370,28 +370,28 @@/* Under-Monitor Monospace Telemetry */.cobalt-node-caption {- margin-top: 4px;+ margin-top: 5px;text-align: center;- font-family: Consolas, "Courier New", monospace;+ font-family: Consolas, "Cascadia Code", "Courier New", monospace;font-size: 11px;- line-height: 1.25;+ line-height: 1.35;color: #ffffff;- max-width: 140px;- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;- text-shadow:- 1px 1px 0 #000,- -1px -1px 0 #000,- 1px -1px 0 #000,- -1px 1px 0 #000,- 0 2px 4px #000;+ min-width: 115px;+ max-width: 185px;+ background: rgba(12, 16, 22, 0.92);+ border: 1px solid rgba(80, 88, 102, 0.5);+ border-radius: 4px;+ padding: 3px 6px;+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);+ backdrop-filter: blur(4px);+ user-select: none;+ pointer-events: none;}.cobalt-node-privilege {display: block;font-weight: 700;- letter-spacing: 0.02em;+ letter-spacing: 0.03em;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;@@ -399,23 +399,27 @@.cobalt-node-privilege.system {color: #ff3333;+ text-shadow: 0 0 6px rgba(255, 51, 51, 0.45);}.cobalt-node-privilege.user {- color: #ffffff;+ color: #00d4ff;+ text-shadow: 0 0 6px rgba(0, 212, 255, 0.35);}.cobalt-node-privilege.neutral {- color: #ffffff;+ color: #f59e0b;+ text-shadow: 0 0 6px rgba(245, 158, 11, 0.35);}.cobalt-node-subtext {display: block;- font-size: 11px;- color: #ffffff;+ font-size: 10.5px;+ color: #e2e8f0;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;+ letter-spacing: 0.02em;}/* ── Cobalt Firewall / Ingress Gateway Node ──────────────────────────────── */diff --git a/frontend/src/features/graph/graphModel.ts b/frontend/src/features/graph/graphModel.tsindex 175336f..840bb24 100644--- a/frontend/src/features/graph/graphModel.ts+++ b/frontend/src/features/graph/graphModel.ts@@ -275,14 +275,14 @@ export function inferCobaltNodeData(node: SafeGraphNode): CobaltNodeInference {if (explicitSubLabel.includes("\n")) {explicitSubLabel = explicitSubLabel.split("\n")[1] || explicitSubLabel.split("\n")[0];}- if (explicitSubLabel.length > 24) {- explicitSubLabel = explicitSubLabel.slice(0, 22) + "…";+ if (explicitSubLabel.length > 28) {+ explicitSubLabel = explicitSubLabel.slice(0, 26) + "…";}}let finalSubLabel = explicitSubLabel !== undefined ? explicitSubLabel : (ip || (pid ? `PID: ${pid}` : undefined));- if (finalSubLabel && finalSubLabel.length > 24) {- finalSubLabel = finalSubLabel.slice(0, 22) + "…";+ if (finalSubLabel && finalSubLabel.length > 28) {+ finalSubLabel = finalSubLabel.slice(0, 26) + "…";}return {