Scanners¶
Vulnerability scanners that query OSV, NVD, and other databases.
agent_bom.scanners ¶
Vulnerability scanning — re-exports for agent_bom.scanners public surface.
The package_scan re-exports resolve on first use: importing any
agent_bom.scanners.* submodule (the CLI does this for --help) must not
pay for the vulnerability-matching stack.
ScannerExecutionState ¶
Bases: str, Enum
Whether a driver is executable today or declared as a roadmap slot.
Source code in src/agent_bom/scanners/base.py
ScannerFailureMode ¶
Bases: str, Enum
How the orchestrator should treat driver failures.
Source code in src/agent_bom/scanners/base.py
ScannerPhase ¶
Bases: str, Enum
Pipeline phase where a scanner driver contributes evidence.
Source code in src/agent_bom/scanners/base.py
ScannerRegistration
dataclass
¶
Bases: RegistryEntry
Registry metadata for a scanner driver implementation.
Source code in src/agent_bom/scanners/base.py
to_dict ¶
Return a stable API/CLI-safe representation.
Source code in src/agent_bom/scanners/base.py
IncompleteScanError ¶
ScanOptions
dataclass
¶
Immutable per-scan scanner controls.
The legacy module-level setters remain for CLI compatibility, but request handlers and concurrent scan callers should pass explicit options so tenant policy cannot bleed through shared module state.
Source code in src/agent_bom/scanners/scan_options.py
expand_blast_radius_hops ¶
expand_blast_radius_hops(blast_radii: list[BlastRadius], agents: list[Agent], max_depth: int = 1) -> None
Preserve direct findings without inventing cross-agent delegation.
These inputs describe configured inventory, not directed delegation or credential-use receipts. Even an identical remote endpoint does not prove that one client can reach another client or its credentials. The retired shared-name traversal therefore cannot qualify additional hops or risk.
Keep the callable for existing scanner integrations. Historical fields already supplied by a caller remain intact; this function does not rewrite stored evidence. Typed graph queries own evidence-backed path analysis.
Source code in src/agent_bom/scanners/blast_radius.py
builtin_scanner_registrations ¶
Return built-in scanner registrations with capability metadata.
Source code in src/agent_bom/scanners/builtin_registrations.py
get_scanner_registration ¶
Return one scanner registration or raise KeyError.
list_registered_scanners ¶
Return registered scanner drivers sorted by name.
Source code in src/agent_bom/scanners/registry.py
register_scanner ¶
Register a scanner driver with capability and execution metadata.
Source code in src/agent_bom/scanners/registry.py
scanner_registry_summary ¶
Return a compact scanner registry summary for API/UI surfaces.
Source code in src/agent_bom/scanners/registry.py
scanner_registry_warnings ¶
Return sanitized non-fatal registry loading warnings.
advisory_id_severity_fallback ¶
Return conservative triage severity for advisory-only IDs.
Some advisory ecosystems publish IDs before CVSS/vendor severity arrives.
These should not stay invisible as unknown findings in operator views,
but only known advisory namespaces get this fallback. Arbitrary missing
severity still remains UNKNOWN.
Source code in src/agent_bom/scanners/risk.py
parse_cvss_vector ¶
Compute CVSS base score from a vector string (v3.x and v4.0).
Source code in src/agent_bom/core/cvss.py
parse_osv_severity ¶
Extract severity, CVSS score, and severity source from OSV data.
Source code in src/agent_bom/scanners/risk.py
severity_from_label ¶
Normalize vendor labels into the scanner's supported severity enum.
Source code in src/agent_bom/core/severity.py
peek_coverage_warnings ¶
Read the structured coverage warnings without draining them.
The scanner needs to see what a sub-step recorded (e.g. an OSV lookup failure) while leaving the channel intact for the command boundary that actually consumes it.
Source code in src/agent_bom/scanners/state.py
record_coverage_warning ¶
Record a structured per-release coverage-gap warning (deduped by release).
replace swaps an earlier entry for the same release instead of keeping
it, for receipts whose detail accumulates across scanner batches.
Source code in src/agent_bom/scanners/state.py
reset_scan_warnings ¶
Reset all scan warning channels at a command/request boundary.
Source code in src/agent_bom/scanners/state.py
reset_scan_warnings_only ¶
Reset transient scanner warnings without discarding parser coverage gaps.
Project manifest parsers can run before vulnerability scanning and record a structured coverage warning. The package scanner must clear warnings from a prior scan, but must preserve those parser warnings for the final report.
Source code in src/agent_bom/scanners/state.py
build_vulnerabilities ¶
Convert OSV response data to Vulnerability objects.
Filters out false positives by verifying the package version falls within OSV affected ranges. Deduplicates by canonical CVE ID.
Source code in src/agent_bom/scanners/package_scan.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | |
create_client ¶
create_client(timeout: float | None = None, max_redirects: int = 0, *, cert: str | tuple[str, str] | None = None, verify: bool | str = True) -> httpx.AsyncClient
Create an httpx.AsyncClient with connection-level retries.
Uses httpx's built-in transport retry for connection failures (DNS, TCP reset).
Application-level retries (429, 5xx) are handled by request_with_retry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float | None
|
Per-request timeout in seconds. |
None
|
max_redirects
|
int
|
Maximum redirects available if a caller explicitly enables redirects on a request. Redirect following is disabled by default so SSRF validation cannot be bypassed by a Location header. |
0
|
Source code in src/agent_bom/http_client.py
deduplicate_packages ¶
Remove duplicate packages across discovery sources.
Deduplicates by (ecosystem, normalized_name, version) fingerprint. When duplicates exist, the first occurrence is kept (preserves source ordering).
This prevents redundant OSV API calls and duplicate vulnerability findings when the same package is discovered from multiple sources (local, K8s, cloud).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packages
|
list
|
List of Package objects from one or more discovery sources. |
required |
Returns:
| Type | Description |
|---|---|
list
|
Deduplicated list, preserving first-seen order. |
Source code in src/agent_bom/scanners/package_preparation.py
default_scan_options ¶
default_scan_options(*, compliance_enabled: bool = False, resolve_transitive: bool = False, prefer_local_db: bool | None = None, offline: bool | None = None, demo_advisories: bool = False, project_dir: str | None = None) -> ScanOptions
Build per-scan options while preserving legacy offline defaults.
Source code in src/agent_bom/scanners/package_scan.py
parse_fixed_version ¶
parse_fixed_version(vuln_data: dict, package_name: str, ecosystem: str = '', current_version: str = '', source_package: str | None = None, allow_prerelease: bool = True, aliases: tuple[str, ...] = ()) -> Optional[str]
Smallest fix for the installed version's window; stable preferred, pre-release otherwise.
Source code in src/agent_bom/scanners/osv.py
query_osv_batch
async
¶
Query OSV API for vulnerabilities in batch.
Source code in src/agent_bom/scanners/package_scan.py
scan_agents
async
¶
scan_agents(agents: list[Agent], *, compliance_enabled: bool = False, resolve_transitive: bool = False, show_scan_banner: bool = True, options: ScanOptions | None = None) -> list[BlastRadius]
Scan all agents' MCP server packages for vulnerabilities.
Source code in src/agent_bom/scanners/package_scan.py
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 | |
scan_agents_sync ¶
scan_agents_sync(agents: list[Agent], enable_enrichment: bool = False, nvd_api_key: Optional[str] = None, blast_radius_depth: int = 1, compliance_enabled: bool = False, resolve_transitive: bool = False, show_scan_banner: bool = True, offline: bool | None = None, prefer_local_db: bool | None = None, demo_advisories: bool = False, project_dir: str | None = None, options: ScanOptions | None = None) -> list[BlastRadius]
Synchronous wrapper for scan_agents.
Source code in src/agent_bom/scanners/package_scan.py
scan_agents_with_enrichment
async
¶
scan_agents_with_enrichment(agents: list[Agent], nvd_api_key: Optional[str] = None, enable_enrichment: bool = True, compliance_enabled: bool = False, show_scan_banner: bool = True, options: ScanOptions | None = None) -> list[BlastRadius]
Scan agents and enrich vulnerabilities with NVD/EPSS/KEV data.
Source code in src/agent_bom/scanners/package_scan.py
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 | |
scan_packages
async
¶
scan_packages(packages: list[Package], *, resolve_transitive: bool = False, options: ScanOptions | None = None) -> int
Scan a list of packages for vulnerabilities. Returns count of vulns found.
Source code in src/agent_bom/scanners/package_scan.py
set_include_unfixed ¶
Toggle surfacing of unfixed (no-dsa/won't-fix) OS-package advisories.
set_offline_mode ¶
Set offline mode in both scanner and http_client transport layer.