fix root computation

This commit is contained in:
overcuriousity 2025-09-16 15:25:39 +02:00
parent 0e92ec6e9a
commit ad4086b156
3 changed files with 20 additions and 32 deletions

View File

@ -514,7 +514,6 @@ class CrtShProvider(BaseProvider):
shared = [] shared = []
# Create a set of certificate IDs from the first list for quick lookup # Create a set of certificate IDs from the first list for quick lookup
# <<< FIX: Added robust type checking to handle potentially malformed API data
cert1_ids = set() cert1_ids = set()
for cert in certs1: for cert in certs1:
cert_id = cert.get('certificate_id') cert_id = cert.get('certificate_id')

View File

@ -65,7 +65,7 @@ class GraphManager {
this.contextMenu = null; this.contextMenu = null;
this.history = []; this.history = [];
this.filterPanel = null; this.filterPanel = null;
this.trueRootIds = new Set(); this.initialTargetIds = new Set();
// Track large entity members for proper hiding // Track large entity members for proper hiding
this.largeEntityMembers = new Set(); this.largeEntityMembers = new Set();
this.isScanning = false; this.isScanning = false;
@ -442,8 +442,7 @@ class GraphManager {
this.nodes.update(processedNodes); this.nodes.update(processedNodes);
this.edges.update(processedEdges); this.edges.update(processedEdges);
// After data is loaded, compute roots and apply filters // After data is loaded, apply filters
this.computeTrueRoots();
this.updateFilterControls(); this.updateFilterControls();
this.applyAllFilters(); this.applyAllFilters();
@ -983,6 +982,7 @@ class GraphManager {
this.edges.clear(); this.edges.clear();
this.history = []; this.history = [];
this.largeEntityMembers.clear(); // Clear large entity tracking this.largeEntityMembers.clear(); // Clear large entity tracking
this.clearInitialTargets();
// Show placeholder // Show placeholder
const placeholder = this.container.querySelector('.graph-placeholder'); const placeholder = this.container.querySelector('.graph-placeholder');
@ -1040,11 +1040,11 @@ class GraphManager {
} }
}); });
// BFS traversal from true roots // BFS traversal from initial targets
const traversalQueue = []; const traversalQueue = [];
// Start from true roots that aren't excluded // Start from initial targets that aren't excluded
this.trueRootIds.forEach(rootId => { this.initialTargetIds.forEach(rootId => {
if (!excludedNodeIds.has(rootId)) { if (!excludedNodeIds.has(rootId)) {
const node = this.nodes.get(rootId); const node = this.nodes.get(rootId);
if (node && !excludedNodeTypes.has(node.type)) { if (node && !excludedNodeTypes.has(node.type)) {
@ -1151,33 +1151,20 @@ class GraphManager {
forensicStatistics: { forensicStatistics: {
visibleNodes: visibleNodes.length, visibleNodes: visibleNodes.length,
hiddenNodes: hiddenNodes.length, hiddenNodes: hiddenNodes.length,
trueRoots: this.trueRootIds.size, initialTargets: this.initialTargetIds.size,
integrityStatus: visibleNodes.length > 0 && this.trueRootIds.size > 0 ? 'INTACT' : 'COMPROMISED' integrityStatus: visibleNodes.length > 0 && this.initialTargetIds.size > 0 ? 'INTACT' : 'COMPROMISED'
} }
}; };
} }
computeTrueRoots() { addInitialTarget(targetId) {
this.trueRootIds.clear(); this.initialTargetIds.add(targetId);
const allNodes = this.nodes.get({ returnType: 'Object' }); console.log("Initial targets:", this.initialTargetIds);
const allEdges = this.edges.get(); }
const inDegrees = {};
for (const nodeId in allNodes) { clearInitialTargets() {
inDegrees[nodeId] = 0; this.initialTargetIds.clear();
} console.log("Initial targets cleared.");
allEdges.forEach(edge => {
if (inDegrees[edge.to] !== undefined) {
inDegrees[edge.to]++;
}
});
for (const nodeId in allNodes) {
if (inDegrees[nodeId] === 0) {
this.trueRootIds.add(nodeId);
}
}
console.log("Computed true roots:", this.trueRootIds);
} }
updateFilterControls() { updateFilterControls() {

View File

@ -297,6 +297,8 @@ class DNSReconApp {
this.graphManager.clear(); this.graphManager.clear();
} }
this.graphManager.addInitialTarget(target);
console.log(`Scan started for ${target} with depth ${maxDepth}`); console.log(`Scan started for ${target} with depth ${maxDepth}`);
// Start polling immediately with faster interval for responsiveness // Start polling immediately with faster interval for responsiveness
@ -481,7 +483,7 @@ class DNSReconApp {
console.log('- Nodes:', graphData.nodes ? graphData.nodes.length : 0); console.log('- Nodes:', graphData.nodes ? graphData.nodes.length : 0);
console.log('- Edges:', graphData.edges ? graphData.edges.length : 0); console.log('- Edges:', graphData.edges ? graphData.edges.length : 0);
if (graphData.nodes) { /*if (graphData.nodes) {
graphData.nodes.forEach(node => { graphData.nodes.forEach(node => {
console.log(` Node: ${node.id} (${node.type})`); console.log(` Node: ${node.id} (${node.type})`);
}); });
@ -491,7 +493,7 @@ class DNSReconApp {
graphData.edges.forEach(edge => { graphData.edges.forEach(edge => {
console.log(` Edge: ${edge.from} -> ${edge.to} (${edge.label})`); console.log(` Edge: ${edge.from} -> ${edge.to} (${edge.label})`);
}); });
} }*/
// Only update if data has changed // Only update if data has changed
if (this.hasGraphChanged(graphData)) { if (this.hasGraphChanged(graphData)) {