feat: 漏洞详情页删除证据/元数据 Tab,新增「链路图」
链路图展示该漏洞所属任务探索图里,从初始节点(任务根)追溯到本漏洞节点的
那条链路:漏洞节点 + 其全部祖先(沿边反向可达)+ 之间的关系边。
- db.ExplorationStore.FindingLineage(nodeID):递归 CTE 取祖先子图(节点+边),
下游(如 finding→proves→goal)与无关节点不纳入
- GET /api/exploration/findings/{id}/lineage:解析 finding 的 node_id/task_id →
返回 {nodes,edges};无节点/任务已删 → 空图
- 前端 api.findingLineage;详情页 Tab 改为「概览 / 链路图」
- lineage.tsx:按深度拓扑排序,自根到漏洞纵向展示节点卡片 + 入边关系标注,
漏洞节点高亮
- db 测试补 FindingLineage 断言(含祖先/排除下游 goal/排除无关意图)
go build / db / server 测试通过。
This commit is contained in:
1 parent
33714a5ff0
commit
b741ee176c
6 files changed
+356
-37
No files matched your search
@@ -372,6 +372,66 @@ func (s *ExplorationStore) Edges(limit int) ([]Edge, error) {
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
// FindingLineage returns the sub-DAG that leads FROM the exploration root TO the
|
||||
// given node: the node itself plus all its ancestors (nodes reverse-reachable by
|
||||
// following edges backward), and every edge whose both endpoints are in that set.
|
||||
// Used to render "how this finding was reached" — origin → … → finding. Returns
|
||||
// empty (not error) for a nonexistent node.
|
||||
func (s *ExplorationStore) FindingLineage(nodeID int64) ([]*Node, []Edge, error) {
|
||||
// anc = the node + everything that can reach it via edges (walk src<-dst).
|
||||
nodeRows, err := s.db.Query(`
|
||||
WITH RECURSIVE anc(id) AS (
|
||||
SELECT $2::bigint
|
||||
UNION
|
||||
SELECT e.src_id
|
||||
FROM exploration_edges e
|
||||
JOIN anc ON e.dst_id = anc.id
|
||||
WHERE e.exploration_id = $1
|
||||
)
|
||||
SELECT `+nodeCols+`
|
||||
FROM exploration_nodes
|
||||
WHERE exploration_id = $1 AND id IN (SELECT id FROM anc)
|
||||
ORDER BY id`, s.expID, nodeID)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
nodes, err := scanNodes(nodeRows)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, nil, nil
|
||||
}
|
||||
// edges among the ancestor set only (the lineage's internal relations).
|
||||
edgeRows, err := s.db.Query(`
|
||||
WITH RECURSIVE anc(id) AS (
|
||||
SELECT $2::bigint
|
||||
UNION
|
||||
SELECT e.src_id
|
||||
FROM exploration_edges e
|
||||
JOIN anc ON e.dst_id = anc.id
|
||||
WHERE e.exploration_id = $1
|
||||
)
|
||||
SELECT src_id, rel, dst_id
|
||||
FROM exploration_edges
|
||||
WHERE exploration_id = $1
|
||||
AND src_id IN (SELECT id FROM anc)
|
||||
AND dst_id IN (SELECT id FROM anc)`, s.expID, nodeID)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
defer edgeRows.Close()
|
||||
var edges []Edge
|
||||
for edgeRows.Next() {
|
||||
var e Edge
|
||||
if err := edgeRows.Scan(&e.From, &e.Rel, &e.To); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
edges = append(edges, e)
|
||||
}
|
||||
return nodes, edges, edgeRows.Err()
|
||||
}
|
||||
|
||||
// FindingIntents maps each finding id to the intent that produced it (the
|
||||
// intent --yields--> finding edge; report_finding links it). Findings with no
|
||||
// producing intent are absent. Precise (JOIN, no edge-scan limit).
|
||||
|
||||
Reference in new issue
Block a user