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

Method get_findings_summary

db_manager.py:2313–2360  ·  view source on GitHub ↗

Get summary statistics for all findings. Returns: Dict with summary stats (counts by severity, scanner, etc.)

(self)

Source from the content-addressed store, hash-verified

2311 if result.get(field):
2312 try:
2313 result[field] = json.loads(result[field])
2314 except json.JSONDecodeError:
2315 result[field] = []
2316 results.append(result)
2317
2318 return results
2319 except Exception as e:
2320 logger.error(f"Failed to get all findings: {e}")
2321 return []
2322
2323 def get_findings_summary(self) -> Dict[str, Any]:
2324 """
2325 Get summary statistics for all findings.
2326
2327 Returns:
2328 Dict with summary stats (counts by severity, scanner, etc.)
2329 """
2330 try:
2331 with self.get_connection() as conn:
2332 cursor = conn.cursor()
2333
2334 summary = {
2335 'total': 0,
2336 'by_severity': {},
2337 'by_scanner': {},
2338 'unique_hosts': 0
2339 }
2340
2341 # Total count
2342 cursor.execute("SELECT COUNT(*) FROM scan_findings")
2343 summary['total'] = cursor.fetchone()[0]
2344
2345 # By severity
2346 cursor.execute("""
2347 SELECT severity, COUNT(*) as count
2348 FROM scan_findings
2349 GROUP BY severity
2350 """)
2351 for row in cursor.fetchall():
2352 summary['by_severity'][row['severity']] = row['count']
2353
2354 # By scanner
2355 cursor.execute("""
2356 SELECT scanner, COUNT(*) as count
2357 FROM scan_findings
2358 GROUP BY scanner
2359 """)
2360 for row in cursor.fetchall():
2361 summary['by_scanner'][row['scanner']] = row['count']
2362
2363 # Unique hosts

Callers 1

get_summaryMethod · 0.80

Calls 6

get_connectionMethod · 0.95
cursorMethod · 0.80
errorMethod · 0.80
executeMethod · 0.45
fetchoneMethod · 0.45
fetchallMethod · 0.45

Tested by

no test coverage detected