MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / add_vulnerability

Method add_vulnerability

network_intelligence.py:264–310  ·  view source on GitHub ↗

Add a new vulnerability finding

(self, host: str, port: int, service: str, vulnerability: str, 
                         severity: str = "medium", details: Optional[Dict] = None)

Source from the content-addressed store, hash-verified

262 self.logger.error(f"Error updating network profile: {e}")
263
264 def add_vulnerability(self, host: str, port: int, service: str, vulnerability: str,
265 severity: str = "medium", details: Optional[Dict] = None) -> Optional[str]:
266 """Add a new vulnerability finding"""
267 try:
268 network_id = self.get_current_network_id()
269 if not network_id:
270 self.logger.error("No network ID available for vulnerability")
271 return None
272
273 # Create vulnerability ID
274 vuln_hash = hashlib.md5(f"{host}:{port}:{service}:{vulnerability}".encode()).hexdigest()[:12]
275 vuln_id = f"vuln_{vuln_hash}"
276
277 # Create vulnerability data
278 vuln_data = {
279 'id': vuln_id,
280 'host': host,
281 'port': port,
282 'service': service,
283 'vulnerability': vulnerability,
284 'severity': severity,
285 'details': details or {},
286 'discovered': datetime.now().isoformat(),
287 'network_id': network_id,
288 'status': 'active',
289 'confirmation_count': 1,
290 'last_confirmed': datetime.now().isoformat()
291 }
292
293 # Add to active vulnerabilities
294 if network_id not in self.active_vulnerabilities:
295 self.active_vulnerabilities[network_id] = {}
296
297 self.active_vulnerabilities[network_id][vuln_id] = vuln_data
298
299 # Update network profile
300 self.update_network_profile(network_id)
301
302 # Save data
303 self.save_intelligence_data()
304
305 self.logger.info(f"Added vulnerability: {vuln_id} on network {network_id}")
306 return vuln_id
307
308 except Exception as e:
309 self.logger.error(f"Error adding vulnerability: {e}")
310 return None
311
312 def add_credential(self, host: str, service: str, username: str, password: str,
313 protocol: str = "unknown", details: Optional[Dict] = None) -> Optional[str]:

Callers 3

add_vulnerabilityFunction · 0.80

Calls 7

errorMethod · 0.80
hexdigestMethod · 0.80
infoMethod · 0.80
encodeMethod · 0.45

Tested by 1