(self)
| 452 | thread.join(timeout=0.05) |
| 453 | |
| 454 | def pcap_analyse(self): |
| 455 | if not os.access(self.destination_report.get(), os.W_OK): |
| 456 | mb.showerror("Error", "Permission denied to create report! Run with higher privilege.") |
| 457 | return |
| 458 | |
| 459 | log.info("pcap_analyse: file=%s", os.path.basename(self.pcap_file.get())) |
| 460 | if not os.path.exists(self.pcap_file.get()): |
| 461 | mb.showerror("Error", "File Not Found!") |
| 462 | return |
| 463 | |
| 464 | self.trigger['state'] = 'disabled' |
| 465 | self.ibutton['state'] = 'disabled' |
| 466 | self.browser_button['state'] = 'disabled' |
| 467 | self.to_menu['state'] = 'disabled' |
| 468 | self.from_menu['state'] = 'disabled' |
| 469 | self.analyze_button['state'] = 'disabled' |
| 470 | |
| 471 | # Derive filename if user typed the path directly instead of using Browse |
| 472 | if not self.filename: |
| 473 | self.filename = os.path.basename(self.pcap_file.get()).replace(".pcap", "").replace(".pcapng", "") |
| 474 | |
| 475 | # Offer to reload from SQLite cache if this PCAP was analyzed before |
| 476 | store = self._open_store() |
| 477 | if self.filename and store.has_session(self.filename): |
| 478 | if mb.askyesno("Reload Session", |
| 479 | f"Cached analysis found for '{self.filename}'.\n" |
| 480 | "Reload without re-parsing the PCAP?"): |
| 481 | log.info("pcap_analyse: reloading session '%s' from cache", self.filename) |
| 482 | self._spin_start("Loading cache") |
| 483 | store.load_session(self.filename) |
| 484 | self._spin_stop(f"✓ {len(memory.packet_db)} sessions (cached)") |
| 485 | self._populate_filter_menus() |
| 486 | self._re_enable_controls() |
| 487 | return |
| 488 | |
| 489 | self._spin_start("Reading packets") |
| 490 | packet_read, exc_box = self._run_in_thread(pcap_reader.PcapEngine, self.pcap_file.get(), self.engine.get()) |
| 491 | self._poll_thread(packet_read) |
| 492 | |
| 493 | if exc_box: |
| 494 | self._spin_stop("✗ Analysis failed", ok=False) |
| 495 | log.error("PCAP analysis failed: %s", exc_box[0]) |
| 496 | mb.showerror("Analysis Error", f"PCAP analysis failed:\n{exc_box[0]}") |
| 497 | self._re_enable_controls() |
| 498 | return |
| 499 | |
| 500 | self._spin_stop(f"✓ {len(memory.packet_db)} sessions") |
| 501 | |
| 502 | log.info("pcap_analyse: read complete, generating packet report") |
| 503 | threading.Thread(target=report_generator.ReportGenerator(self.destination_report.get(), self.filename).packetDetails, args=(), daemon=True).start() |
| 504 | |
| 505 | if self.filename: |
| 506 | self._open_store().save_session(self.filename) |
| 507 | self._populate_filter_menus() |
| 508 | self._re_enable_controls() |
| 509 | |
| 510 | def _populate_filter_menus(self) -> None: |
| 511 | self.details_fetch = 0 |
nothing calls this directly
no test coverage detected