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

Method get_scan_history

db_manager.py:1241–1273  ·  view source on GitHub ↗

Get scan history, optionally filtered by MAC address. Args: mac: MAC address to filter by (None for all) limit: Maximum number of records to return Returns: List of scan history dictionaries

(self, mac: str = None, limit: int = 100)

Source from the content-addressed store, hash-verified

1239 with self.get_connection() as conn:
1240 cursor = conn.cursor()
1241 cursor.execute("""
1242 INSERT INTO scan_history (mac, ip, scan_type, ports_found, vulnerabilities_found)
1243 VALUES (?, ?, ?, ?, ?)
1244 """, (mac.lower().strip(), ip, scan_type, ports_found or '', vulnerabilities_found))
1245 conn.commit()
1246 return True
1247 except Exception as e:
1248 logger.error(f"Failed to add scan history: {e}")
1249 return False
1250
1251 def get_scan_history(self, mac: str = None, limit: int = 100) -> List[Dict]:
1252 """
1253 Get scan history, optionally filtered by MAC address.
1254
1255 Args:
1256 mac: MAC address to filter by (None for all)
1257 limit: Maximum number of records to return
1258
1259 Returns:
1260 List of scan history dictionaries
1261 """
1262 try:
1263 with self.get_connection() as conn:
1264 cursor = conn.cursor()
1265
1266 if mac:
1267 cursor.execute("""
1268 SELECT * FROM scan_history
1269 WHERE mac = ?
1270 ORDER BY timestamp DESC
1271 LIMIT ?
1272 """, (mac.lower().strip(), limit))
1273 else:
1274 cursor.execute("""
1275 SELECT * FROM scan_history
1276 ORDER BY timestamp DESC

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected