fix large entity

This commit is contained in:
overcuriousity
2025-09-15 13:58:30 +02:00
parent 51902e3155
commit fc326a66c8
25 changed files with 50 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
/**
* Graph visualization module for DNSRecon
* Handles network graph rendering using vis.js
* Handles network graph rendering using vis.js with proper large entity node hiding
*/
const contextMenuCSS = `
.graph-context-menu {
@@ -66,6 +66,8 @@ class GraphManager {
this.history = [];
this.filterPanel = null;
this.trueRootIds = new Set();
// Track large entity members for proper hiding
this.largeEntityMembers = new Set();
this.options = {
nodes: {
@@ -179,8 +181,6 @@ class GraphManager {
document.body.addEventListener('click', () => this.hideContextMenu());
}
/**
* Create floating node info popup
*/
@@ -215,9 +215,6 @@ class GraphManager {
console.log('Context menu created and added to body');
}
/**
* Initialize the network graph
*/
@@ -246,7 +243,6 @@ class GraphManager {
this.addGraphControls();
this.addFilterPanel();
console.log('Graph initialized successfully');
} catch (error) {
console.error('Failed to initialize graph:', error);
@@ -379,25 +375,38 @@ class GraphManager {
this.initialize();
}
this.largeEntityMembers.clear();
const largeEntityMap = new Map();
graphData.nodes.forEach(node => {
if (node.type === 'large_entity' && node.attributes && Array.isArray(node.attributes.nodes)) {
node.attributes.nodes.forEach(nodeId => {
largeEntityMap.set(nodeId, node.id);
this.largeEntityMembers.add(nodeId);
});
}
});
const processedNodes = graphData.nodes.map(node => {
const processed = this.processNode(node);
if (largeEntityMap.has(node.id)) {
processed.hidden = true;
}
return processed;
const filteredNodes = graphData.nodes.filter(node => {
// Only include nodes that are NOT members of large entities
return !this.largeEntityMembers.has(node.id);
});
console.log(`Filtered ${graphData.nodes.length - filteredNodes.length} large entity member nodes from visualization`);
// Process only the filtered nodes
const processedNodes = filteredNodes.map(node => {
return this.processNode(node);
});
const mergedEdges = {};
graphData.edges.forEach(edge => {
// Skip edges involving large entity members that are hidden
if (this.largeEntityMembers.has(edge.from) || this.largeEntityMembers.has(edge.to)) {
return;
}
// Redirect edges from large entity members to their container
const fromNode = largeEntityMap.has(edge.from) ? largeEntityMap.get(edge.from) : edge.from;
const toNode = largeEntityMap.has(edge.to) ? largeEntityMap.get(edge.to) : edge.to;
const mergeKey = `${fromNode}-${toNode}-${edge.label}`;
@@ -443,7 +452,6 @@ class GraphManager {
this.updateFilterControls();
this.applyAllFilters();
// Highlight new additions briefly
if (newNodes.length > 0 || newEdges.length > 0) {
setTimeout(() => this.highlightNewElements(newNodes, newEdges), 100);
@@ -455,6 +463,8 @@ class GraphManager {
}
console.log(`Graph updated: ${processedNodes.length} nodes, ${processedEdges.length} edges (${newNodes.length} new nodes, ${newEdges.length} new edges)`);
console.log(`Large entity members hidden: ${this.largeEntityMembers.size}`);
} catch (error) {
console.error('Failed to update graph:', error);
this.showError('Failed to update visualization');
@@ -541,8 +551,6 @@ class GraphManager {
}
};
return processedEdge;
}
@@ -589,7 +597,6 @@ class GraphManager {
return colors[nodeType] || '#ffffff';
}
/**
* Get node border color based on type
* @param {string} nodeType - Node type
@@ -980,6 +987,7 @@ class GraphManager {
this.nodes.clear();
this.edges.clear();
this.history = [];
this.largeEntityMembers.clear(); // Clear large entity tracking
// Show placeholder
const placeholder = this.container.querySelector('.graph-placeholder');
@@ -1008,7 +1016,7 @@ class GraphManager {
return {
nodeCount: this.nodes.length,
edgeCount: this.edges.length,
//isStabilized: this.network ? this.network.isStabilized() : false
largeEntityMembersHidden: this.largeEntityMembers.size
};
}
@@ -1138,7 +1146,6 @@ class GraphManager {
console.log(`Filters applied. Reachable nodes: ${reachableNodes.size}`);
}
/**
* Show context menu for a node
* @param {string} nodeId - The ID of the node