mirror of
https://github.com/CyberSecurityUP/NeuroSploit.git
synced 2026-11-25 21:54:26 +01:00
Merge pull request #73 from JoasASantos/feat/validator-chain-graph-stealth-multimodel
feat: CADP upgrades — Neo4j planner, kill chain, stealth, multimodel, engagement marker
This commit is contained in:
7 files changed
+266
-30
No files matched your search
@@ -1844,6 +1844,7 @@ pub fn cypher_statements_with_engagement(b: &GraphBatch, run: &str, engagement:
|
||||
"from": e.from.1, "to": e.to.1, "status": e.status.as_str(), "confidence": e.confidence, "props": props,
|
||||
}));
|
||||
}
|
||||
let eng_set_edge = engagement.map(|_| ", r.engagement = $engagement").unwrap_or("");
|
||||
for ((rel, fl, tl), rows) in groups {
|
||||
for chunk in rows.chunks(500) {
|
||||
let stmt = format!(
|
||||
@@ -1852,12 +1853,16 @@ pub fn cypher_statements_with_engagement(b: &GraphBatch, run: &str, engagement:
|
||||
SET r += row.props, \
|
||||
r.status = CASE WHEN r.status = 'confirmed' THEN 'confirmed' ELSE row.status END, \
|
||||
r.confidence = CASE WHEN r.confidence IS NULL OR row.confidence > r.confidence THEN row.confidence ELSE r.confidence END, \
|
||||
r.updated_at = timestamp(), r.last_run = $run",
|
||||
r.updated_at = timestamp(), r.last_run = $run{eng_set_edge}",
|
||||
fl.as_str(),
|
||||
tl.as_str(),
|
||||
rel.as_str()
|
||||
);
|
||||
out.push((stmt, json!({"rows": chunk, "run": run})));
|
||||
let mut params = json!({"rows": chunk, "run": run});
|
||||
if let Some(eng) = engagement {
|
||||
params["engagement"] = json!(eng);
|
||||
}
|
||||
out.push((stmt, params));
|
||||
}
|
||||
}
|
||||
out
|
||||
@@ -1895,13 +1900,21 @@ fn cypher_literal(v: &Value) -> String {
|
||||
/// An offline Cypher script: `cypher-shell -u neo4j -p … -f graph.cypher`.
|
||||
/// Values are emitted as escaped literals bound once per statement.
|
||||
pub fn export_cypher(b: &GraphBatch, run: &str) -> String {
|
||||
export_cypher_with_engagement(b, run, None)
|
||||
}
|
||||
|
||||
pub fn export_cypher_with_engagement(b: &GraphBatch, run: &str, engagement: Option<&str>) -> String {
|
||||
let mut s = String::from(
|
||||
"// NeuroSploit attack graph — load with:\n// cypher-shell -a <uri> -u <user> -p <password> -f graph.cypher\n// Idempotent: MERGE on stable keys; secrets are fingerprints only.\n\n",
|
||||
);
|
||||
for (stmt, params) in cypher_statements(b, run) {
|
||||
for (stmt, params) in cypher_statements_with_engagement(b, run, engagement) {
|
||||
let rows = params.get("rows").map(cypher_literal);
|
||||
let run_lit = cypher_literal(&json!(run));
|
||||
let eng_lit = engagement.map(|e| cypher_literal(&json!(e)));
|
||||
let mut st = stmt.replace("$run", &run_lit);
|
||||
if let Some(el) = &eng_lit {
|
||||
st = st.replace("$engagement", el);
|
||||
}
|
||||
if let Some(r) = rows {
|
||||
st = st.replacen("UNWIND $rows AS row", &format!("UNWIND {r} AS row"), 1);
|
||||
}
|
||||
@@ -2026,7 +2039,13 @@ impl Neo4j {
|
||||
|
||||
/// MERGE the batch. Returns (nodes, relationships) sent.
|
||||
pub async fn push(&self, b: &GraphBatch, run: &str) -> anyhow::Result<(usize, usize)> {
|
||||
let stmts = cypher_statements(b, run);
|
||||
self.push_with_engagement(b, run, None).await
|
||||
}
|
||||
|
||||
/// MERGE the batch with an optional engagement identifier stamped on every
|
||||
/// node and edge so separate engagements with overlapping IPs stay apart.
|
||||
pub async fn push_with_engagement(&self, b: &GraphBatch, run: &str, engagement: Option<&str>) -> anyhow::Result<(usize, usize)> {
|
||||
let stmts = cypher_statements_with_engagement(b, run, engagement);
|
||||
// Constraints are schema operations: run them on their own first.
|
||||
let (schema, data): (Vec<_>, Vec<_>) = stmts.into_iter().partition(|(s, _)| s.starts_with("CREATE CONSTRAINT"));
|
||||
for (s, p) in schema {
|
||||
@@ -2137,6 +2156,65 @@ impl Neo4j {
|
||||
}
|
||||
}
|
||||
|
||||
/// Query Neo4j for attack paths from owned nodes to high-value targets
|
||||
/// (DCs, DAs, forest roots). Returns a formatted context block for the planner.
|
||||
pub async fn query_graph_suggestions(&self, engagement: Option<&str>) -> String {
|
||||
let mut parts: Vec<String> = Vec::new();
|
||||
|
||||
// 1. Owned footholds
|
||||
let owned = self.query_owned_nodes(engagement).await;
|
||||
if !owned.is_empty() {
|
||||
let hosts: Vec<String> = owned.iter().filter_map(|o| {
|
||||
let name = o.get("name").and_then(|n| n.as_str()).unwrap_or("");
|
||||
let addr = o.get("address").and_then(|a| a.as_str()).unwrap_or("");
|
||||
let label = o.get("label").and_then(|l| l.as_str()).unwrap_or("");
|
||||
if name.is_empty() && addr.is_empty() { return None; }
|
||||
Some(format!("{label} {name}{}", if addr.is_empty() { String::new() } else { format!(" ({addr})") }))
|
||||
}).collect();
|
||||
if !hosts.is_empty() {
|
||||
parts.push(format!("Owned footholds: {}", hosts.join(", ")));
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Next moves from graph (reachable unowned targets)
|
||||
let moves = self.query_next_moves(engagement).await;
|
||||
if !moves.is_empty() {
|
||||
let mut lines: Vec<String> = Vec::new();
|
||||
for m in moves.iter().take(10) {
|
||||
let from = m.get("from_name").and_then(|v| v.as_str()).unwrap_or("?");
|
||||
let rel = m.get("rel").and_then(|v| v.as_str()).unwrap_or("?");
|
||||
let to = m.get("to_name").and_then(|v| v.as_str()).unwrap_or("?");
|
||||
let addr = m.get("to_address").and_then(|v| v.as_str()).unwrap_or("");
|
||||
lines.push(format!(" {from} -[{rel}]-> {to}{}", if addr.is_empty() { String::new() } else { format!(" ({addr})") }));
|
||||
}
|
||||
parts.push(format!("Graph-derived attack paths (from owned to unowned):\n{}", lines.join("\n")));
|
||||
}
|
||||
|
||||
// 3. Shortest path to DC/DA if any exist in graph
|
||||
for target_label in ["Host", "Identity"] {
|
||||
for target_name in ["DC01-VANGUARD", "DC01-AUREON", "DC01-HELIX", "d.kim", "Administrator"] {
|
||||
let path = self.query_shortest_path("Host", target_label, target_name, engagement).await;
|
||||
if !path.is_empty() {
|
||||
if let Some(arr) = path[0].as_array() {
|
||||
let steps: Vec<String> = arr.iter().filter_map(|n| {
|
||||
let name = n.get("name").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let label = n.get("label").and_then(|v| v.as_str()).unwrap_or("");
|
||||
if name.is_empty() { None } else { Some(format!("[{label}]{name}")) }
|
||||
}).collect();
|
||||
if steps.len() > 1 {
|
||||
parts.push(format!("Shortest path to {target_name}: {}", steps.join(" -> ")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if parts.is_empty() {
|
||||
return String::new();
|
||||
}
|
||||
format!("\nNEO4J GRAPH INTELLIGENCE (BloodHound-style path analysis):\n{}\n", parts.join("\n"))
|
||||
}
|
||||
|
||||
/// Query Neo4j for suggested next moves: edges from owned nodes to unowned targets.
|
||||
pub async fn query_next_moves(&self, engagement: Option<&str>) -> Vec<Value> {
|
||||
let cypher = if engagement.is_some() {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
//! then watch for it to arrive:
|
||||
//!
|
||||
//! ```text
|
||||
//! payload: http://JOASNSCOPEssrf1a2b.oob.example.com/
|
||||
//! payload: http://NEUROSPLOITssrf1a2b.oob.example.com/
|
||||
//! │
|
||||
//! target ─────────────────→│ DNS query for that name ← proof of resolution
|
||||
//! ─────────────────→│ HTTP GET to that name ← proof of egress
|
||||
|
||||
@@ -1501,11 +1501,14 @@ fn write_meta(cfg: &RunConfig, p: &crate::probe::Probe, asset: &str) {
|
||||
// from the artifacts alone.
|
||||
let typesafe_on = std::env::var("NEUROSPLOIT_TYPESAFE").unwrap_or_default().trim().to_lowercase() != "off"
|
||||
&& std::env::var("TYPESAFE_API_KEY").map(|k| !k.trim().is_empty()).unwrap_or(false);
|
||||
let meta = serde_json::json!({
|
||||
let mut meta = serde_json::json!({
|
||||
"target": cfg.target, "asset": asset, "title": p.title, "brand": p.brand,
|
||||
"tech": p.tech, "server": p.server, "status": p.status,
|
||||
"typesafe": typesafe_on,
|
||||
});
|
||||
if let Some(eng) = &cfg.engagement {
|
||||
meta["engagement"] = serde_json::json!(eng);
|
||||
}
|
||||
if let Ok(j) = serde_json::to_string_pretty(&meta) {
|
||||
let _ = std::fs::write(format!("{}/meta.json", dir.trim_end_matches('/')), j);
|
||||
}
|
||||
@@ -2984,7 +2987,7 @@ async fn graph_checkpoint(
|
||||
let mut pb = gm::build(&cfg.target, &rid, findings, internal.as_ref(), None);
|
||||
gm::project_recon(&mut pb, &cfg.target, recon, &in_scope);
|
||||
gm::record_paths(&mut pb, &cs, &rid);
|
||||
match n.push(&pb, &rid).await {
|
||||
match n.push_with_engagement(&pb, &rid, cfg.engagement.as_deref()).await {
|
||||
Ok(_) => synced = " · neo4j synced".into(),
|
||||
Err(e) => synced = format!(" · neo4j push skipped ({e})"),
|
||||
}
|
||||
@@ -3003,6 +3006,16 @@ async fn graph_checkpoint(
|
||||
}
|
||||
}
|
||||
}
|
||||
// Neo4j graph intelligence: query owned nodes, attack paths, shortest
|
||||
// paths to high-value targets. Append to live context so agents get
|
||||
// BloodHound-style path suggestions.
|
||||
let engagement_id = cfg.engagement.as_deref();
|
||||
let suggestions = n.query_graph_suggestions(engagement_id).await;
|
||||
if !suggestions.is_empty() {
|
||||
let cur = gm::live_context(&rid);
|
||||
gm::set_live_context(&rid, format!("{cur}{suggestions}"));
|
||||
synced.push_str(" · neo4j path intelligence");
|
||||
}
|
||||
}
|
||||
let (h, sv, ep, sec) = gm::surface_counts(&gb);
|
||||
let confirmed = cs.iter().filter(|c| c.status == gm::Status::Confirmed).count();
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
//! So every artifact carries the same three-part identity:
|
||||
//!
|
||||
//! ```text
|
||||
//! JOASNSCOPE - <build fingerprint> - <run id> - <per-artifact nonce>
|
||||
//! NEUROSPLOIT - <build fingerprint> - <run id> - <per-artifact nonce>
|
||||
//! │ │ │ │
|
||||
//! who made it which build which engagement which artifact
|
||||
//! ```
|
||||
//!
|
||||
//! The prefix is deliberately a single literal, `JOASNSCOPE`, so a grep for it
|
||||
//! The prefix is deliberately a single literal, `NEUROSPLOIT`, so a grep for it
|
||||
//! across any document finds every trace at once — a marker nobody can find is
|
||||
//! a marker that proves nothing when it matters.
|
||||
//!
|
||||
@@ -31,7 +31,7 @@ use serde::{Deserialize, Serialize};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
/// The literal every trace shares. Grep-able on purpose.
|
||||
pub const SIGIL: &str = "JOASNSCOPE";
|
||||
pub const SIGIL: &str = "NEUROSPLOIT";
|
||||
|
||||
/// Engine name as it appears in artifacts.
|
||||
pub const ENGINE: &str = "neurosploit";
|
||||
|
||||
+130
-13
@@ -4111,7 +4111,8 @@ function extrasPanelsHtml(uid) {
|
||||
</div>
|
||||
<div class="graph-main">
|
||||
<div class="panel-toolbar"><div class="chip-row" data-x="legend"></div><div class="topbar-spacer"></div>
|
||||
<label class="toggle"><input type="checkbox" data-x="full" /> full graph</label></div>
|
||||
<label class="toggle"><input type="checkbox" data-x="full" /> full graph</label>
|
||||
<label class="toggle"><input type="checkbox" data-x="killchain" /> kill chain</label></div>
|
||||
<div class="gm-finding-desc" data-x="fdesc" hidden></div>
|
||||
<div class="gm-wrap" data-x="wrap"><div class="gm-stage" data-x="stage"></div>
|
||||
<div class="gm-zoom"><button class="btn btn-sm" data-z="in">+</button><button class="btn btn-sm" data-z="out">−</button><button class="btn btn-sm" data-z="fit">⤢</button></div></div>
|
||||
@@ -4179,6 +4180,7 @@ function makeExtras(viewSel, uid, getRunId) {
|
||||
x.q('t-method').addEventListener('change', () => extrasTraffic(x));
|
||||
x.q('tr-q').addEventListener('input', debounce('tr', () => extrasTraces(x)));
|
||||
x.q('full').addEventListener('change', () => renderGraphMemory(x));
|
||||
x.q('killchain').addEventListener('change', () => { x.drawnSig = null; renderGraphMemory(x); });
|
||||
bindGraphInteractions(x);
|
||||
return x;
|
||||
}
|
||||
@@ -4409,7 +4411,8 @@ function renderGraphFindingList(x) {
|
||||
const data = x.graphData?.graph;
|
||||
const list = x.q('gflist');
|
||||
if (!list || !data) return;
|
||||
const findings = (data.nodes || []).filter(n => n.label === 'Finding');
|
||||
const hasFilters = x.view.filterSev || x.view.filterStatus || x.view.filterSubnet;
|
||||
const findings = (data.nodes || []).filter(n => n.label === 'Finding' && (!hasFilters || !x._filteredNodeIds || x._filteredNodeIds.has(`${n.label}|${n.key}`)));
|
||||
findings.sort((a, b) => sevRank(a.props?.local_severity) - sevRank(b.props?.local_severity));
|
||||
const sel = x.view.filterFinding || 'overview';
|
||||
const runIds = new Set();
|
||||
@@ -4456,9 +4459,9 @@ function renderGraphMemory(x) {
|
||||
.map(([k, l]) => `<button class="gm-leg gk-${k}${kf.has(k) ? '' : ' gm-leg-active'}" data-kind="${k}"><span class="gm-leg-dot"></span>${esc(l)}</button>`).join('') +
|
||||
'<span class="gm-leg-sep"></span><span class="gm-edge-leg es-confirmed">confirmed</span><span class="gm-edge-leg es-needs_validation">needs validation</span><span class="gm-edge-leg es-hypothesis">hypothesis</span>' +
|
||||
'<span class="gm-leg-sep"></span>' +
|
||||
`<select class="gm-filter" data-filter="severity"><option value="">Severity</option>${[...allSevs].sort((a,b)=>sevRank(a)-sevRank(b)).map(s=>`<option value="${esc(s)}"${x.view.filterSev===s?' selected':''}>${esc(s)}</option>`).join('')}</select>` +
|
||||
`<select class="gm-filter" data-filter="status"><option value="">Status</option>${[...allStatuses].sort().map(s=>`<option value="${esc(s)}"${x.view.filterStatus===s?' selected':''}>${esc(s)}</option>`).join('')}</select>` +
|
||||
`<select class="gm-filter" data-filter="subnet"><option value="">Subnet</option>${[...allSubnets].sort().map(s=>`<option value="${esc(s)}"${x.view.filterSubnet===s?' selected':''}>${esc(s)}</option>`).join('')}</select>` +
|
||||
`<label class="gm-filter-wrap"><span class="gm-filter-label">Severity</span><select class="gm-filter" data-filter="severity"><option value="">All</option>${[...allSevs].sort((a,b)=>sevRank(a)-sevRank(b)).map(s=>`<option value="${esc(s)}"${x.view.filterSev===s?' selected':''}>${esc(s)}</option>`).join('')}</select></label>` +
|
||||
`<label class="gm-filter-wrap"><span class="gm-filter-label">Status</span><select class="gm-filter" data-filter="status"><option value="">All</option>${[...allStatuses].sort().map(s=>`<option value="${esc(s)}"${x.view.filterStatus===s?' selected':''}>${esc(s)}</option>`).join('')}</select></label>` +
|
||||
`<label class="gm-filter-wrap"><span class="gm-filter-label">Subnet</span><select class="gm-filter" data-filter="subnet"><option value="">All</option>${[...allSubnets].sort().map(s=>`<option value="${esc(s)}"${x.view.filterSubnet===s?' selected':''}>${esc(s)}</option>`).join('')}</select></label>` +
|
||||
`<div class="gm-killchain">${KILL_CHAIN_STAGES.map(s => `<div class="kc-stage ${stageCoverage[s] ? 'kc-covered' : ''}" title="${esc(s)}: ${stageCoverage[s] || 0} findings"><div class="kc-bar"></div><div class="kc-label">${esc(s)}</div></div>`).join('')}</div>`;
|
||||
$$('[data-kind]', x.q('legend')).forEach(btn => btn.addEventListener('click', () => {
|
||||
const k = btn.dataset.kind;
|
||||
@@ -4485,6 +4488,8 @@ function renderGraphMemory(x) {
|
||||
if (x.view.filterSev) nodes = nodes.filter(n => !n.props?.local_severity || n.props.local_severity === x.view.filterSev);
|
||||
if (x.view.filterStatus) nodes = nodes.filter(n => !n.props?.status || n.props.status === x.view.filterStatus);
|
||||
if (x.view.filterSubnet) { const pfx = x.view.filterSubnet.replace('.0/24', '.'); nodes = nodes.filter(n => !n.props?.address || n.props.address.startsWith(pfx)); }
|
||||
x._filteredNodeIds = new Set(nodes.filter(n => n.label === 'Finding').map(n => id(n)));
|
||||
if (x.view.filterSev || x.view.filterStatus || x.view.filterSubnet) renderGraphFindingList(x);
|
||||
let keep = new Set(nodes.map(id));
|
||||
let edges = (data.edges || []).filter((e) => keep.has(eid(e.from)) && keep.has(eid(e.to)));
|
||||
if (!full) {
|
||||
@@ -4630,7 +4635,7 @@ function renderGraphMemory(x) {
|
||||
${assetCtx}
|
||||
<div class="fd-cards">
|
||||
${cweStr ? `<div class="fd-card"><div class="fd-card-label">CWE</div><div class="fd-card-value">${esc(Array.isArray(cweStr) ? cweStr.join(', ') : cweStr)}</div></div>` : ''}
|
||||
${cvssStr ? `<div class="fd-card"><div class="fd-card-label">CVSS</div><div class="fd-card-value">${esc(String(cvssStr))}</div></div>` : ''}
|
||||
${cvssStr ? (() => { const cs = String(cvssStr); const vm = cs.match(/([\d.]+)\s*(\(.*\))?/); const score = vm ? vm[1] : cs; const vec = vm && vm[2] ? vm[2] : (cs.includes('/') && !vm ? cs : ''); return `<div class="fd-card"><div class="fd-card-label">CVSS</div><div class="fd-card-value">${esc(score)}${vec ? `<span class="cvss-vector">${esc(vec)}</span>` : ''}</div></div>`; })() : ''}
|
||||
${owasp ? `<div class="fd-card"><div class="fd-card-label">OWASP</div><div class="fd-card-value">${esc(owasp)}</div></div>` : ''}
|
||||
${mitre ? `<div class="fd-card"><div class="fd-card-label">MITRE</div><div class="fd-card-value">${esc(mitre)}</div></div>` : ''}
|
||||
${stageVal ? `<div class="fd-card"><div class="fd-card-label">Stage</div><div class="fd-card-value">${esc(stageVal)}</div></div>` : ''}
|
||||
@@ -4659,6 +4664,49 @@ function renderGraphMemory(x) {
|
||||
show(descBox, false);
|
||||
}
|
||||
|
||||
// Kill chain: find longest attack path through traversal edges
|
||||
const CHAIN_EDGES = new Set(['ESCALATES_TO', 'CAN_ACCESS', 'PIVOTS_TO', 'ENABLES', 'IMPACTS']);
|
||||
const chainEdges = edges.filter(e => CHAIN_EDGES.has(e.type));
|
||||
const fwd = new Map();
|
||||
const rev = new Map();
|
||||
for (const e of chainEdges) {
|
||||
const f = eid(e.from), t = eid(e.to);
|
||||
(fwd.get(f) || fwd.set(f, []).get(f)).push({ to: t, edge: e });
|
||||
(rev.get(t) || rev.set(t, []).get(t)).push({ from: f, edge: e });
|
||||
}
|
||||
const allChainNodes = new Set([...fwd.keys(), ...rev.keys()]);
|
||||
const roots = [...allChainNodes].filter(n => !rev.has(n) || rev.get(n).length === 0);
|
||||
if (!roots.length) for (const n of allChainNodes) { roots.push(n); break; }
|
||||
let longestPath = [];
|
||||
const dfs = (cur, path, visited) => {
|
||||
if (path.length > longestPath.length) longestPath = [...path];
|
||||
for (const { to } of (fwd.get(cur) || [])) {
|
||||
if (!visited.has(to)) { visited.add(to); path.push(to); dfs(to, path, visited); path.pop(); visited.delete(to); }
|
||||
}
|
||||
};
|
||||
for (const r of roots) { const v = new Set([r]); dfs(r, [r], v); }
|
||||
const killChainSet = new Set(longestPath);
|
||||
const killChainEdgeSet = new Set();
|
||||
for (let i = 0; i < longestPath.length - 1; i++) {
|
||||
const from = longestPath[i];
|
||||
for (const { to, edge } of (fwd.get(from) || [])) {
|
||||
if (to === longestPath[i + 1]) killChainEdgeSet.add(edge);
|
||||
}
|
||||
}
|
||||
|
||||
const showKillChain = x.q('killchain')?.checked;
|
||||
if (showKillChain && longestPath.length > 1) {
|
||||
const neighbors = new Set(killChainSet);
|
||||
for (const e of edges) {
|
||||
const f = eid(e.from), t = eid(e.to);
|
||||
if (killChainSet.has(f)) neighbors.add(t);
|
||||
if (killChainSet.has(t)) neighbors.add(f);
|
||||
}
|
||||
nodes = nodes.filter(n => neighbors.has(id(n)));
|
||||
keep = new Set(nodes.map(id));
|
||||
edges = edges.filter(e => keep.has(eid(e.from)) && keep.has(eid(e.to)));
|
||||
}
|
||||
|
||||
// Circular node layout — left-to-right columns by entity kind
|
||||
const NW = 180, NH = 110, GX = 90, GY = 42, PER = 7;
|
||||
const cols = new Map();
|
||||
@@ -4723,7 +4771,8 @@ function renderGraphMemory(x) {
|
||||
const a = pos.get(eid(e.from)), b = pos.get(eid(e.to));
|
||||
if (!a || !b) return '';
|
||||
const st = e.status || 'needs_validation';
|
||||
return `<path class="gm-e es-${esc(st)}${GM_TRAVERSAL.has(e.type) ? ' gm-trav' : ''}" data-from="${esc(eid(e.from))}" data-to="${esc(eid(e.to))}" marker-end="url(#${arrow(st)})" d="${path(a, b)}"><title>${esc(e.type)} · ${esc(st)} · conf ${Number(e.confidence || 0).toFixed(2)}</title></path>`;
|
||||
const onKC = killChainEdgeSet.has(e);
|
||||
return `<path class="gm-e es-${esc(st)}${GM_TRAVERSAL.has(e.type) ? ' gm-trav' : ''}${onKC ? ' gm-e-onpath' : ''}" data-from="${esc(eid(e.from))}" data-to="${esc(eid(e.to))}" marker-end="url(#${arrow(st)})" d="${path(a, b)}"><title>${esc(e.type)} · ${esc(st)} · conf ${Number(e.confidence || 0).toFixed(2)}</title></path>`;
|
||||
}).join('');
|
||||
const cards = nodes.map((n) => {
|
||||
const p = pos.get(id(n));
|
||||
@@ -4733,7 +4782,8 @@ function renderGraphMemory(x) {
|
||||
const sevBadge = sev ? `<span class="gm-sev-badge sev ${sevClass(sev)}">${esc(sev.charAt(0).toUpperCase())}</span>` : '';
|
||||
const countBadge = props.endpoint_count ? `<span class="gm-badge" style="background:var(--sev-high-fg);color:#fff">${props.endpoint_count}</span>` : '';
|
||||
const sub = gmSub(n);
|
||||
return `<div class="gm-node gk-${kind}" style="left:${p.x}px;top:${p.y}px;width:${NW}px" data-id="${esc(id(n))}">
|
||||
const onKC = killChainSet.has(id(n));
|
||||
return `<div class="gm-node gk-${kind}${onKC ? ' gm-onpath' : ''}" style="left:${p.x}px;top:${p.y}px;width:${NW}px" data-id="${esc(id(n))}">
|
||||
<div class="gm-circle">${gmIcon(n.label)}${sevBadge}${countBadge}</div>
|
||||
<div class="gm-node-label" title="${esc(gmName(n))}">${esc(gmName(n))}</div>
|
||||
${sub ? `<div class="gm-node-info" title="${esc(sub)}">${esc(sub)}</div>` : ''}
|
||||
@@ -4997,20 +5047,31 @@ async function loadPentests() {
|
||||
const body = $('#pentestsBody');
|
||||
if (!body) return;
|
||||
try {
|
||||
const runs = await api('/api/runs');
|
||||
const [runs, projects] = await Promise.all([api('/api/runs'), api('/api/projects').catch(() => [])]);
|
||||
if (!runs.length) { body.innerHTML = '<div class="empty-state">No pentests yet. Click <strong>+ New Pentest</strong> to start.</div>'; return; }
|
||||
const matchRun = (p, r) => (r.projectId && r.projectId === p.id)
|
||||
|| (p.runIds || []).includes(r.id)
|
||||
|| (p.targets || []).some(t => {
|
||||
const needle = t.replace(/^https?:\/\//, '').replace(/\/.*$/, '').toLowerCase();
|
||||
const hay = (String(r.target || '') + ' ' + String(r.name || '') + ' ' + String(r.id || '')).toLowerCase();
|
||||
return needle && hay.includes(needle);
|
||||
})
|
||||
|| (p.name && r.name && r.name.toLowerCase().includes(p.name.toLowerCase()));
|
||||
const projectFor = (r) => { for (const p of projects) { if (matchRun(p, r)) return p.name; } return ''; };
|
||||
const renderRows = (q) => {
|
||||
const lq = (q || '').trim().toLowerCase();
|
||||
const filtered = lq ? runs.filter(r => {
|
||||
const blob = `${r.id || ''} ${r.target || ''} ${r.name || ''} ${r.state || ''}`.toLowerCase();
|
||||
const blob = `${r.id || ''} ${r.target || ''} ${r.name || ''} ${r.state || ''} ${projectFor(r)}`.toLowerCase();
|
||||
return blob.includes(lq);
|
||||
}) : runs;
|
||||
const rows = filtered.map(r => {
|
||||
const mode = (r.id || '').startsWith('ns-wb-') ? 'whitebox' : (r.id || '').startsWith('ns-gb-') ? 'greybox' : (r.id || '').startsWith('ns-host-') ? 'host' : 'blackbox';
|
||||
const when = r.when ? timeAgo(Math.floor(new Date(r.when).getTime() / 1000)) : '';
|
||||
const proj = projectFor(r);
|
||||
return `<tr class="pentest-row" data-id="${esc(r.id)}">
|
||||
<td class="mono">${esc(r.id)}</td>
|
||||
<td>${esc(r.target || r.name || '')}</td>
|
||||
<td>${esc(proj)}</td>
|
||||
<td>${esc(mode)}</td>
|
||||
<td>${r.findings ?? 0}</td>
|
||||
<td>${esc(r.state || 'done')}</td>
|
||||
@@ -5018,7 +5079,7 @@ async function loadPentests() {
|
||||
</tr>`;
|
||||
}).join('');
|
||||
body.innerHTML = rows
|
||||
? `<table class="data-table"><thead><tr><th>ID</th><th>Target</th><th>Mode</th><th>Findings</th><th>Status</th><th>When</th></tr></thead><tbody>${rows}</tbody></table>`
|
||||
? `<table class="data-table"><thead><tr><th>ID</th><th>Target</th><th>Project</th><th>Mode</th><th>Findings</th><th>Status</th><th>When</th></tr></thead><tbody>${rows}</tbody></table>`
|
||||
: `<div class="empty-state">No pentests matching "${esc(q)}".</div>`;
|
||||
$$('.pentest-row', body).forEach(row => {
|
||||
row.style.cursor = 'pointer';
|
||||
@@ -5205,8 +5266,8 @@ async function loadProjects() {
|
||||
|| (p.runIds || []).includes(r.id)
|
||||
|| (p.targets || []).some(t => {
|
||||
const needle = t.replace(/^https?:\/\//, '').replace(/\/.*$/, '').toLowerCase();
|
||||
const hay = String(r.target || '').toLowerCase();
|
||||
return needle && (hay === needle || hay.includes(needle));
|
||||
const hay = (String(r.target || '') + ' ' + String(r.name || '') + ' ' + String(r.id || '')).toLowerCase();
|
||||
return needle && hay.includes(needle);
|
||||
});
|
||||
const group = new Map();
|
||||
for (const p of projects) {
|
||||
@@ -5230,6 +5291,7 @@ async function loadProjects() {
|
||||
<span class="project-run-meta">${r.findings || 0}f · ${esc(r.state || '')}</span>
|
||||
</button>`).join('')}${rs.length > 6 ? `<div class="project-run-more">+${rs.length - 6} more</div>` : ''}</div>` : '<div class="project-empty">No tests matched yet.</div>'}
|
||||
<div class="config-card-actions">
|
||||
<button class="btn btn-sm btn-primary" data-manage-runs="${esc(p.id)}">Manage Runs</button>
|
||||
<button class="btn btn-sm" data-edit-project="${esc(p.id)}">Edit</button>
|
||||
<button class="btn btn-sm btn-danger" data-del-project="${esc(p.id)}">Delete</button>
|
||||
</div>
|
||||
@@ -5240,6 +5302,7 @@ async function loadProjects() {
|
||||
const r = runs.find(x => x.id === el.dataset.run);
|
||||
if (r) openRun({ id: r.id, state: r.state });
|
||||
}));
|
||||
$$('[data-manage-runs]', body).forEach(el => el.addEventListener('click', () => openProjectRuns(el.dataset.manageRuns, projects, runs, matches)));
|
||||
$$('[data-edit-project]', body).forEach(el => el.addEventListener('click', () => openProject(el.dataset.editProject, projects)));
|
||||
$$('[data-del-project]', body).forEach(el => el.addEventListener('click', async () => {
|
||||
if (!confirm('Delete this project? The runs themselves are not touched.')) return;
|
||||
@@ -5291,6 +5354,60 @@ $('#btnProjectSubmit')?.addEventListener('click', async () => {
|
||||
} catch (e) { toast(`Failed: ${e.message}`, 'error'); }
|
||||
});
|
||||
|
||||
function openProjectRuns(projectId, projects, allRuns, matchFn) {
|
||||
const p = projects.find(x => x.id === projectId);
|
||||
if (!p) return;
|
||||
$('#projectRunsId').value = projectId;
|
||||
$('#projectRunsTitle').textContent = `${p.name} — Manage Runs`;
|
||||
const explicitIds = new Set(p.runIds || []);
|
||||
const renderList = (q) => {
|
||||
const lq = (q || '').trim().toLowerCase();
|
||||
const sorted = [...allRuns].sort((a, b) => {
|
||||
const aMatch = explicitIds.has(a.id) || matchFn(p, a);
|
||||
const bMatch = explicitIds.has(b.id) || matchFn(p, b);
|
||||
if (aMatch && !bMatch) return -1;
|
||||
if (!aMatch && bMatch) return 1;
|
||||
return (b.ts || 0) - (a.ts || 0);
|
||||
});
|
||||
const filtered = lq ? sorted.filter(r => {
|
||||
const blob = `${r.id || ''} ${r.target || ''} ${r.name || ''} ${r.state || ''}`.toLowerCase();
|
||||
return blob.includes(lq);
|
||||
}) : sorted;
|
||||
$('#projectRunsList').innerHTML = filtered.map(r => {
|
||||
const checked = explicitIds.has(r.id) || matchFn(p, r);
|
||||
const autoMatch = !explicitIds.has(r.id) && matchFn(p, r);
|
||||
return `<label class="project-run-check" style="display:flex;align-items:center;gap:8px;padding:6px 8px;border-bottom:1px solid var(--border);cursor:pointer">
|
||||
<input type="checkbox" data-rid="${esc(r.id)}" ${checked ? 'checked' : ''} ${autoMatch ? 'title="Auto-matched by target"' : ''} />
|
||||
<span class="state-dot state-${esc(r.state || 'unknown')}" style="flex-shrink:0"></span>
|
||||
<span style="flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${esc(r.name || r.target || r.id)}</span>
|
||||
<span class="muted" style="flex-shrink:0;font-size:12px">${r.findings || 0}f · ${esc(r.state || '')}</span>
|
||||
${autoMatch ? '<span style="font-size:10px;color:var(--accent);flex-shrink:0">auto</span>' : ''}
|
||||
</label>`;
|
||||
}).join('');
|
||||
};
|
||||
renderList('');
|
||||
const searchEl = $('#projectRunsSearch');
|
||||
searchEl.value = '';
|
||||
searchEl.oninput = () => renderList(searchEl.value);
|
||||
const saveBtn = $('#btnProjectRunsSave');
|
||||
const newSave = saveBtn.cloneNode(true);
|
||||
saveBtn.replaceWith(newSave);
|
||||
newSave.addEventListener('click', async () => {
|
||||
const checked = [...$$('input[data-rid]:checked', $('#projectRunsList'))].map(el => el.dataset.rid);
|
||||
try {
|
||||
await api(`/api/projects/${encodeURIComponent(projectId)}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ ...p, runIds: checked }),
|
||||
});
|
||||
closeModal('#projectRunsModal');
|
||||
toast('Runs updated', 'ok');
|
||||
loadProjects();
|
||||
} catch (e) { toast(`Failed: ${e.message}`, 'error'); }
|
||||
});
|
||||
openModal('#projectRunsModal');
|
||||
}
|
||||
|
||||
async function loadNetworks() {
|
||||
const body = $('#networksBody');
|
||||
if (!body) return;
|
||||
|
||||
@@ -1452,6 +1452,26 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-overlay" id="projectRunsModal" hidden>
|
||||
<div class="modal modal-lg">
|
||||
<div class="modal-head">
|
||||
<div class="title" id="projectRunsTitle">Project Runs</div>
|
||||
<button class="icon-btn" onclick="closeModal('#projectRunsModal')" aria-label="Close"><svg class="ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M6 6l12 12M18 6 6 18"/></svg></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" id="projectRunsId" />
|
||||
<div class="field-group">
|
||||
<input id="projectRunsSearch" type="text" placeholder="Search runs..." />
|
||||
</div>
|
||||
<div id="projectRunsList" style="max-height:400px;overflow-y:auto"></div>
|
||||
</div>
|
||||
<div class="modal-foot">
|
||||
<button class="btn" onclick="closeModal('#projectRunsModal')">Close</button>
|
||||
<button class="btn btn-primary" id="btnProjectRunsSave">Save Selection</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ============ INTEGRATION CONFIG MODAL ============ -->
|
||||
<div class="modal-overlay" id="integrationModal" hidden>
|
||||
<div class="modal modal-sm">
|
||||
|
||||
+15
-7
@@ -1032,19 +1032,19 @@ body.resizing-ns { user-select: none; cursor: ns-resize; }
|
||||
.moves ul { margin: 0; padding-left: 18px; font-size: var(--fs-sm); color: var(--text-dim); }
|
||||
.moves ul li { margin-bottom: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; text-overflow: ellipsis; }
|
||||
.chain-ref { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
|
||||
.chain-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
|
||||
.chain-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; min-width: 0; }
|
||||
.chain-impact, .chain-steps .step { overflow-wrap: anywhere; }
|
||||
.chain-list { display: flex; flex-direction: column; gap: var(--sp-2); }
|
||||
.chain-card { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
|
||||
.chain-card { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
|
||||
.chain-card.st-confirmed { border-left: 3px solid var(--sev-low-fg); }
|
||||
.chain-card.st-needs_validation { border-left: 3px solid var(--sev-medium-fg); }
|
||||
.chain-card.st-hypothesis { border-left: 3px dashed var(--border-strong); }
|
||||
.chain-card summary { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); cursor: pointer; flex-wrap: wrap; list-style: none; }
|
||||
.chain-card summary { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); cursor: pointer; flex-wrap: wrap; list-style: none; overflow: hidden; }
|
||||
.chain-card summary::-webkit-details-marker { display: none; }
|
||||
.chain-title { font-weight: 600; font-size: var(--fs-base); flex: 1; min-width: 260px; }
|
||||
.chain-pot { font-size: var(--fs-xs); color: var(--sev-medium-fg); font-weight: 600; }
|
||||
.chain-meta { font-size: var(--fs-xs); color: var(--text-faint); font-family: var(--mono); }
|
||||
.chain-body { padding: 0 var(--sp-4) var(--sp-4); border-top: 1px solid var(--border); }
|
||||
.chain-meta { font-size: var(--fs-xs); color: var(--text-faint); font-family: var(--mono); white-space: nowrap; flex-shrink: 0; }
|
||||
.chain-body { padding: 0 var(--sp-4) var(--sp-4); border-top: 1px solid var(--border); overflow: hidden; word-break: break-word; }
|
||||
.chain-impact { margin: var(--sp-3) 0; font-size: var(--fs-sm); }
|
||||
.chain-steps { margin: 0 0 var(--sp-3); padding-left: 20px; font-family: var(--mono); font-size: var(--fs-xs); }
|
||||
.chain-steps .step { padding: 3px 0; color: var(--text-dim); }
|
||||
@@ -1054,7 +1054,7 @@ body.resizing-ns { user-select: none; cursor: ns-resize; }
|
||||
.chain-block { margin-top: var(--sp-2); }
|
||||
.chain-block-h { font-size: var(--fs-xs); text-transform: none; color: var(--text-faint); font-weight: 700; }
|
||||
.chain-block ul { margin: 4px 0 0; padding-left: 18px; font-size: var(--fs-sm); }
|
||||
.chain-block li { margin: 3px 0; line-height: 1.5; }
|
||||
.chain-block li { margin: 3px 0; line-height: 1.5; overflow-wrap: anywhere; }
|
||||
/* readable chain prose: node refs as chips, relations as labels, meta muted */
|
||||
.chain-steps { font-family: var(--sans); }
|
||||
.chain-steps .step { line-height: 1.6; }
|
||||
@@ -1118,6 +1118,11 @@ body.resizing-ns { user-select: none; cursor: ns-resize; }
|
||||
.gm-node-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text); text-align: center; max-width: 176px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 9px; letter-spacing: -.01em; }
|
||||
.gm-node-info { font-size: 10px; font-family: var(--mono); color: var(--accent); text-align: center; max-width: 176px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; opacity: .85; }
|
||||
.gm-node-sub { font-size: var(--fs-xs); color: var(--text-faint); text-align: center; max-width: 176px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
|
||||
/* Kill chain path highlight */
|
||||
.gm-onpath .gm-circle { box-shadow: 0 0 0 3px #f59e0b, 0 0 18px 4px rgba(245,158,11,.45), 0 8px 22px -6px rgba(15,23,42,.35); }
|
||||
.gm-onpath .gm-circle::after { opacity: 1; background: radial-gradient(circle, rgba(245,158,11,.3), transparent 68%); }
|
||||
.gm-onpath .gm-node-label { color: #f59e0b; font-weight: 700; }
|
||||
.gm-e-onpath { stroke: #f59e0b !important; stroke-width: 4.5 !important; opacity: 1 !important; stroke-dasharray: none !important; filter: drop-shadow(0 0 6px rgba(245,158,11,.5)) !important; }
|
||||
/* Solid Wiz-style fills by kind (white icon on saturated disc) */
|
||||
.gk-internet .gm-circle { background: linear-gradient(145deg, #60a5fa, #2563eb); }
|
||||
.gk-asset .gm-circle { background: linear-gradient(145deg, #38bdf8, #0284c7); }
|
||||
@@ -1274,7 +1279,8 @@ a.deliv-card:hover { border-color: var(--accent); }
|
||||
.gm-finding-desc .fd-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--sp-2); margin-bottom: var(--sp-3); }
|
||||
.gm-finding-desc .fd-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3); }
|
||||
.gm-finding-desc .fd-card-label { font-size: var(--fs-xs); text-transform: none; color: var(--text-faint); font-weight: 600; }
|
||||
.gm-finding-desc .fd-card-value { font-size: var(--fs-sm); font-weight: 500; margin-top: 2px; font-family: var(--mono); }
|
||||
.gm-finding-desc .fd-card-value { font-size: var(--fs-sm); font-weight: 500; margin-top: 2px; font-family: var(--mono); word-break: break-all; overflow-wrap: break-word; }
|
||||
.gm-finding-desc .fd-card-value .cvss-vector { display: block; font-size: 9px; color: var(--text-faint); margin-top: 2px; word-break: break-all; }
|
||||
.gm-finding-desc .fd-section { margin-bottom: var(--sp-3); }
|
||||
.gm-finding-desc .fd-section:last-child { margin-bottom: 0; }
|
||||
.gm-finding-desc .fd-section-title { font-size: var(--fs-xs); font-weight: 700; text-transform: none; color: var(--text-faint); margin-bottom: var(--sp-1); }
|
||||
@@ -1715,6 +1721,8 @@ input[type="number"] { font-variant-numeric: tabular-nums; }
|
||||
.fd-asset-label { font-size:10px; text-transform:uppercase; letter-spacing:.5px; color:var(--text-faint); white-space:nowrap; font-weight:600 }
|
||||
.fd-asset-value { font-size:12px; font-family:var(--mono); color:var(--text) }
|
||||
/* Filter dropdowns */
|
||||
.gm-filter-wrap { display:inline-flex; align-items:center; gap:4px; position:relative }
|
||||
.gm-filter-label { font-size:10px; font-weight:600; color:var(--text-faint); text-transform:uppercase; letter-spacing:.3px }
|
||||
.gm-filter { background:var(--surface-2, rgba(127,127,127,.06)); color:var(--text); border:1px solid var(--border); border-radius:4px; padding:2px 6px; font-size:11px; cursor:pointer; outline:none }
|
||||
.gm-filter:focus { border-color:var(--accent) }
|
||||
/* Re-validate button */
|
||||
|
||||
Reference in new issue
Block a user