Inventory Backends
Query-driven InventoryBackend protocol, zerobom.backends entry-point loader, conformance test harness, hardened SBOM parser/indexer, and built-in inventory plugins (local_sbom, dependency_track, oci_sbom, k8s_sbom).
backends
Cloud-agnostic inventory backend interfaces, plugin registry, parser, and conformance.
BackendConfigError
Bases: BackendLoadError
Raised when backend configuration options or credentials are invalid or missing.
BackendConformanceCase(expected_backend_name, vulnerable_advisory, safe_advisory, unmatched_advisory, min_vulnerable_hits=1)
dataclass
Parameterized conformance test suite describing expected plugin matching behavior.
Attributes:
| Name | Type | Description |
|---|---|---|
expected_backend_name |
str
|
Expected value of |
vulnerable_advisory |
OsvAdvisory
|
Advisory that must match at least |
safe_advisory |
OsvAdvisory
|
Same package with a fixed bound lower than installed versions (0 hits). |
unmatched_advisory |
OsvAdvisory
|
Unrelated non-existent package (must return 0 hits). |
min_vulnerable_hits |
int
|
Minimum vulnerable matches expected for |
BackendConformanceError
Bases: AssertionError
Raised when an :class:InventoryBackend plugin violates conformance invariants.
BackendError
Bases: RuntimeError
Base exception for inventory backend loading, configuration, and query errors.
BackendLoadError
Bases: BackendError
Raised when a requested inventory backend cannot be found, loaded, or instantiated.
BackendQueryError
Bases: BackendError
Raised when an inventory backend runtime query fails or exceeds safety ceilings.
BackendRegistry(*, entry_points_provider=None, include_builtins=True)
Discovers, validates, and instantiates built-in and plugin inventory backends.
Initialize the backend registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entry_points_provider
|
Callable[[str], Iterable[Any]] | None
|
Optional callable overriding |
None
|
include_builtins
|
bool
|
Whether to register the built-in |
True
|
Source code in src/zerobom/backends/registry.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
create(name, *, config=None, **kwargs)
Instantiate and protocol-verify a named inventory backend.
When config is supplied and the backend factory defines a callable from_config
hook, from_config(merged_config) is invoked; otherwise keyword arguments are passed
directly to the backend constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Registered or plugin backend name. |
required |
config
|
Mapping[str, Any] | None
|
Optional parsed configuration mapping (from :func: |
None
|
**kwargs
|
Any
|
Explicit keyword arguments forwarded or merged into |
{}
|
Returns:
| Type | Description |
|---|---|
InventoryBackend
|
Instantiated object satisfying :class: |
Raises:
| Type | Description |
|---|---|
BackendLoadError
|
If loading/instantiation fails or the object does not implement
:class: |
BackendConfigError
|
Propagated directly if configuration validation fails. |
Source code in src/zerobom/backends/registry.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
get_factory(name)
Resolve and lazily load the factory callable for a named backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Registered or entry-point backend identifier. |
required |
Returns:
| Type | Description |
|---|---|
Callable[..., Any]
|
Factory callable capable of instantiating the backend. |
Raises:
| Type | Description |
|---|---|
BackendLoadError
|
If |
Source code in src/zerobom/backends/registry.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
list_backends()
Return sorted valid names of all registered and entry-point-discovered backends.
Source code in src/zerobom/backends/registry.py
190 191 192 193 | |
register(name, factory)
Manually register an inventory backend factory under a validated name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Backend identifier matching |
required |
factory
|
Callable[..., InventoryBackend]
|
Callable returning an :class: |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/zerobom/backends/registry.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
DependencyTrackBackend(*, base_url, api_key=None, bearer_token=None, project_uuid=None, query_mode='coordinates', exclude_inactive_projects=True, only_latest_project_versions=False, page_size=100, max_pages=50, timeout_seconds=DEFAULT_API_TIMEOUT_SECONDS, max_response_bytes=DEFAULT_MAX_RESPONSE_BYTES, ca_bundle=None, verify_tls=True, allow_insecure_http=False, http_client=None)
Query-driven OWASP Dependency-Track REST API v1 inventory backend.
Initialize an OWASP Dependency-Track API v1 inventory backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
Dependency-Track API root URL (e.g., |
required |
api_key
|
str | None
|
Dependency-Track |
None
|
bearer_token
|
str | None
|
Optional OIDC/JWT bearer credential (mutually exclusive with
|
None
|
project_uuid
|
str | None
|
Optional single Dependency-Track project UUID filter. |
None
|
query_mode
|
Literal['coordinates', 'purl']
|
Lookup strategy ( |
'coordinates'
|
exclude_inactive_projects
|
bool
|
Exclude inactive projects when querying components. |
True
|
only_latest_project_versions
|
bool
|
Restrict queries to latest project versions. |
False
|
page_size
|
int
|
API page size in |
100
|
max_pages
|
int
|
Maximum paginated pages per query in |
50
|
timeout_seconds
|
float
|
HTTP request timeout in |
DEFAULT_API_TIMEOUT_SECONDS
|
max_response_bytes
|
int
|
Maximum response payload size per HTTP call. |
DEFAULT_MAX_RESPONSE_BYTES
|
ca_bundle
|
str | Path | None
|
Optional custom PEM CA bundle path for private internal PKI. |
None
|
verify_tls
|
bool
|
Enable TLS certificate verification (recommended). |
True
|
allow_insecure_http
|
bool
|
Explicit opt-in to permit |
False
|
http_client
|
Client | None
|
Optional externally managed :class: |
None
|
Raises:
| Type | Description |
|---|---|
BackendConfigError
|
If URL, credentials, TLS options, or bounds are invalid. |
Source code in src/zerobom/backends/dependency_track.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
name
property
Registered backend plugin identifier ("dependency_track").
close()
Close the internally managed HTTP client connection pool.
Source code in src/zerobom/backends/dependency_track.py
284 285 286 287 | |
find_components(queries)
Query Dependency-Track /api/v1/component/identity for candidate packages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
queries
|
Sequence[PackageQuery]
|
Normalized package queries built from an OSV advisory. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Deduplicated |
tuple[InventoryComponent, ...]
|
class: |
Raises:
| Type | Description |
|---|---|
BackendQueryError
|
On HTTP failure, auth denial, redirect, pagination overflow, or malformed JSON responses. |
Source code in src/zerobom/backends/dependency_track.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
from_config(config)
classmethod
Instantiate :class:DependencyTrackBackend from CLI/file configuration.
Environment variable fallbacks: ZEROBOM_DT_URL, ZEROBOM_DT_API_KEY,
and ZEROBOM_DT_BEARER_TOKEN.
Source code in src/zerobom/backends/dependency_track.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
InMemoryComponentIndex(components=())
In-memory O(1) lookup index over normalized :class:InventoryComponent records.
Initialize the index and ingest any initial component records.
Source code in src/zerobom/backends/sbom_parser.py
451 452 453 454 455 456 457 458 | |
components
property
All indexed :class:InventoryComponent records in insertion order.
add_components(components)
Add normalized components into canonical PURL, upstream, and fallback indices.
Source code in src/zerobom/backends/sbom_parser.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | |
find_components(queries)
Return deduplicated candidate components matching any supplied query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
queries
|
Sequence[PackageQuery]
|
Canonical package descriptors built from an OSV advisory. |
required |
Returns:
| Type | Description |
|---|---|
tuple[InventoryComponent, ...]
|
Deduplicated tuple of matching :class: |
Source code in src/zerobom/backends/sbom_parser.py
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |
InventoryBackend
Bases: Protocol
Query-driven contract implemented by local SBOMs and external/cloud plugins.
All backends return normalized :class:InventoryComponent entries; deterministic version
range matching remains exclusively in :mod:zerobom.verify.osv_compiler.
name
property
Unique identifier for this inventory backend (e.g., "local_sbom").
find_components(queries)
Look up candidate components matching any of the supplied package queries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
queries
|
Sequence[PackageQuery]
|
Canonical package descriptors extracted from an OSV advisory. |
required |
Returns:
| Type | Description |
|---|---|
tuple[InventoryComponent, ...]
|
Tuple of matching :class: |
Source code in src/zerobom/backends/base.py
40 41 42 43 44 45 46 47 48 | |
K8sSbomBackend(*, api_server=None, kubeconfig=None, context=None, cluster_name=None, namespace=None, include_cluster_reports=False, label_selector=None, bearer_token=None, token_file=None, username=None, password=None, ca_bundle=None, ca_pem_data=None, client_cert=None, client_key=None, in_cluster=False, serviceaccount_token_path=_SA_TOKEN_DEFAULT, serviceaccount_ca_path=_SA_CA_DEFAULT, env=None, page_size=100, max_pages=50, verify_tls=True, allow_insecure_http=False, timeout_seconds=DEFAULT_API_TIMEOUT_SECONDS, max_response_bytes=DEFAULT_MAX_RESPONSE_BYTES, http_client=None)
Read-only Kubernetes API backend querying Trivy Operator SbomReport CRDs.
Initialize a read-only Kubernetes Trivy Operator SbomReport backend.
Supports explicit api_server + credentials, standard kubeconfig YAML files
(excluding exec credential plugins), and in-cluster ServiceAccount discovery.
Raises:
| Type | Description |
|---|---|
BackendConfigError
|
If cluster discovery, auth, TLS, namespace, or bounds fail. |
Source code in src/zerobom/backends/k8s_sbom.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 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 | |
name
property
Registered backend plugin identifier ("k8s_sbom").
close()
Close the internally managed HTTP client connection pool.
Source code in src/zerobom/backends/k8s_sbom.py
466 467 468 469 | |
find_components(queries)
Search indexed Kubernetes SbomReport components for candidate matches.
Source code in src/zerobom/backends/k8s_sbom.py
499 500 501 502 503 504 505 506 507 | |
from_config(config)
classmethod
Instantiate :class:K8sSbomBackend from CLI options or YAML/JSON config.
Source code in src/zerobom/backends/k8s_sbom.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | |
load()
Fetch and index Trivy Operator SbomReport objects into memory.
Source code in src/zerobom/backends/k8s_sbom.py
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | |
LocalSbomBackend(paths, *, max_file_bytes=MAX_SBOM_FILE_BYTES, max_files=MAX_SBOM_FILES, max_depth=MAX_CYCLONEDX_DEPTH)
Zero-config inventory backend reading CycloneDX and SPDX JSON SBOMs from disk.
Load and index CycloneDX and SPDX JSON SBOM files from files or directories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
Path | str | Sequence[Path | str]
|
File path, directory path, or sequence of paths to scan. |
required |
max_file_bytes
|
int
|
Maximum allowed byte size per SBOM JSON file. |
MAX_SBOM_FILE_BYTES
|
max_files
|
int
|
Maximum number of JSON files permitted in a directory scan. |
MAX_SBOM_FILES
|
max_depth
|
int
|
Maximum CycloneDX nested |
MAX_CYCLONEDX_DEPTH
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If resource ceilings are non-positive or |
SbomParseError
|
If an explicit file is missing/malformed/oversized/unrecognized,
a directory exceeds |
Source code in src/zerobom/backends/local_sbom.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
components
property
All normalized inventory components parsed from configured SBOM files.
loaded_files
property
SBOM files successfully parsed during initialization.
name
property
Backend identifier registered in zerobom.backends.
skipped_files
property
JSON or symlinked files skipped during directory scanning.
find_components(queries)
Return candidate components matching any query in O(1) per index lookup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
queries
|
Sequence[PackageQuery]
|
Canonical package descriptors built from an OSV advisory. |
required |
Returns:
| Type | Description |
|---|---|
tuple[InventoryComponent, ...]
|
Deduplicated tuple of matching :class: |
Source code in src/zerobom/backends/local_sbom.py
290 291 292 293 294 295 296 297 298 299 | |
from_config(config)
classmethod
Instantiate :class:LocalSbomBackend from parsed CLI or YAML/JSON configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Mapping[str, Any]
|
Mapping containing |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Initialized |
LocalSbomBackend
|
class: |
Raises:
| Type | Description |
|---|---|
BackendConfigError
|
If |
Source code in src/zerobom/backends/local_sbom.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
OciSbomBackend(*, images, username=None, password=None, bearer_token=None, platform=None, allowed_auth_hosts=(), fallback_tag_schema=True, allow_blob_redirects=True, allow_private_redirects=False, allow_insecure_http=False, ca_bundle=None, verify_tls=True, timeout_seconds=DEFAULT_API_TIMEOUT_SECONDS, max_sbom_bytes=DEFAULT_MAX_RESPONSE_BYTES, strict=False, dns_resolver=None, http_client=None)
OCI Distribution v1.1 container image SBOM and attestation inventory backend.
Initialize an OCI container registry SBOM inventory backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images
|
Sequence[str]
|
Container image references to scan for attached SBOMs/attestations. |
required |
username
|
str | None
|
Optional registry username for HTTP Basic / Bearer token exchange. |
None
|
password
|
str | None
|
Optional registry password or PAT matching |
None
|
bearer_token
|
str | None
|
Optional pre-minted registry Bearer token. |
None
|
platform
|
str | None
|
Optional multi-arch filter formatted as |
None
|
allowed_auth_hosts
|
Sequence[str]
|
Optional explicit third-party bearer auth realm host allowlist. |
()
|
fallback_tag_schema
|
bool
|
Fall back to OCI 1.0 |
True
|
allow_blob_redirects
|
bool
|
Follow one validated HTTPS redirect on |
True
|
allow_private_redirects
|
bool
|
Explicit opt-in to permit private/loopback redirect or realm targets for internal registries. |
False
|
allow_insecure_http
|
bool
|
Explicit opt-in to permit |
False
|
ca_bundle
|
str | Path | None
|
Optional PEM CA bundle path for private internal registries. |
None
|
verify_tls
|
bool
|
Enable TLS certificate verification. |
True
|
timeout_seconds
|
float
|
HTTP request timeout in |
DEFAULT_API_TIMEOUT_SECONDS
|
max_sbom_bytes
|
int
|
Maximum SBOM/attestation blob size permitted per layer. |
DEFAULT_MAX_RESPONSE_BYTES
|
strict
|
bool
|
Raise :class: |
False
|
dns_resolver
|
DnsResolver | None
|
Optional DNS resolver callable for offline SSRF testing. |
None
|
http_client
|
Client | None
|
Optional externally managed :class: |
None
|
Raises:
| Type | Description |
|---|---|
BackendConfigError
|
If image references, credentials, platform, TLS, or bounds fail. |
Source code in src/zerobom/backends/oci_sbom.py
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 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |
image_refs
property
Configured OCI image references.
name
property
Registered backend plugin identifier ("oci_sbom").
close()
Close the internally managed HTTP client connection pool.
Source code in src/zerobom/backends/oci_sbom.py
608 609 610 611 | |
find_components(queries)
Search indexed OCI image SBOM components for candidate package matches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
queries
|
Sequence[PackageQuery]
|
Canonical package descriptors built from an OSV advisory. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Matching |
tuple[InventoryComponent, ...]
|
class: |
Source code in src/zerobom/backends/oci_sbom.py
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 | |
from_config(config)
classmethod
Instantiate :class:OciSbomBackend from CLI options or YAML/JSON config.
Environment variable fallbacks: ZEROBOM_OCI_TOKEN, ZEROBOM_OCI_USERNAME,
and ZEROBOM_OCI_PASSWORD.
Source code in src/zerobom/backends/oci_sbom.py
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | |
load()
Fetch and index SBOMs/attestations for all configured container images.
Source code in src/zerobom/backends/oci_sbom.py
620 621 622 623 624 625 626 627 628 629 630 631 632 | |
SbomParseError
Bases: ValueError
Raised when an SBOM input path or JSON document violates schema or safety bounds.
assert_backend_conformance(backend, case)
Verify that an :class:InventoryBackend plugin fulfills every ZeroBOM contract invariant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
InventoryBackend
|
Instantiated backend plugin under test. |
required |
case
|
BackendConformanceCase
|
Parameterized conformance test case. |
required |
Returns:
| Type | Description |
|---|---|
tuple[MatchResult, ...]
|
Verified tuple of vulnerable :class: |
Raises:
| Type | Description |
|---|---|
BackendConformanceError
|
If any protocol, identifier, |
Source code in src/zerobom/backends/conformance.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
build_default_conformance_case(*, backend_name, package_name='requests', ecosystem='PyPI', canonical_purl='pkg:pypi/requests', vulnerable_fixed='2.31.0', safe_fixed='1.0.0')
Construct a standard three-advisory conformance fixture for a backend plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend_name
|
str
|
Expected plugin |
required |
package_name
|
str
|
Target package present in the plugin's inventory. |
'requests'
|
ecosystem
|
str
|
OSV ecosystem string for |
'PyPI'
|
canonical_purl
|
str
|
Versionless canonical PURL matching the inventory entry. |
'pkg:pypi/requests'
|
vulnerable_fixed
|
str
|
Version higher than installed version (triggers vulnerable hit). |
'2.31.0'
|
safe_fixed
|
str
|
Version lower than installed version (must yield zero vulnerable hits). |
'1.0.0'
|
Returns:
| Name | Type | Description |
|---|---|---|
Configured |
BackendConformanceCase
|
class: |
Source code in src/zerobom/backends/conformance.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
derive_sbom_asset(data, *, asset_id, backend, location=None, scope=None, asset_type=None, extra_metadata=None)
Construct a cloud-agnostic :class:AssetRef enriched from SBOM document headers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Mapping[str, Any]
|
Parsed CycloneDX or SPDX JSON mapping. |
required |
asset_id
|
str
|
Unique asset identifier (file path, object URI, digest, or resource ID). |
required |
backend
|
str
|
Registered |
required |
location
|
str | None
|
Optional path, URI, digest, or region string. |
None
|
scope
|
str | None
|
Optional scope override; falls back to document root component or doc name. |
None
|
asset_type
|
str | None
|
Optional asset category override; falls back to metadata component type or
|
None
|
extra_metadata
|
Mapping[str, Any] | None
|
Optional plugin-supplied opaque metadata merged safely into |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Validated |
AssetRef
|
class: |
Raises:
| Type | Description |
|---|---|
SbomParseError
|
If required asset fields violate :class: |
Source code in src/zerobom/backends/sbom_parser.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
match_advisory_with_backend(advisory, backend, *, only_vulnerable=True)
Query an :class:InventoryBackend and evaluate hits deterministically with univers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
advisory
|
OsvAdvisory
|
Compiled OSV advisory containing affected package definitions. |
required |
backend
|
InventoryBackend
|
Any local or plugin-supplied :class: |
required |
only_vulnerable
|
bool
|
When |
True
|
Returns:
| Type | Description |
|---|---|
tuple[MatchResult, ...]
|
Deduplicated tuple of deterministic :class: |
Source code in src/zerobom/backends/base.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
parse_backend_options(raw_options=(), *, config_path=None, max_config_bytes=MAX_BACKEND_CONFIG_BYTES)
Parse backend plugin configuration from an optional YAML/JSON file and CLI flags.
CLI KEY=VALUE options override keys loaded from config_path. Repeated CLI keys
are collected into a list of strings so plugins accepting sequences (such as multiple SBOM
paths or namespaces) receive all supplied values cleanly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_options
|
Sequence[str]
|
Sequence of |
()
|
config_path
|
Path | None
|
Optional path to a YAML or JSON backend config file. |
None
|
max_config_bytes
|
int
|
Maximum allowed config file byte size. |
MAX_BACKEND_CONFIG_BYTES
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Validated dictionary ready for :meth: |
Raises:
| Type | Description |
|---|---|
BackendConfigError
|
If the config file is missing/oversized/malformed, contains
invalid keys, or any CLI |
Source code in src/zerobom/backends/registry.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
parse_cyclonedx_dict(data, *, asset, source_label='<sbom>', max_depth=MAX_CYCLONEDX_DEPTH)
Parse a CycloneDX (1.4-1.6) JSON mapping iteratively with bounded recursion depth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Mapping[str, Any]
|
Decoded CycloneDX JSON object. |
required |
asset
|
AssetRef
|
:class: |
required |
source_label
|
str
|
Human-readable label included in depth-limit diagnostics. |
'<sbom>'
|
max_depth
|
int
|
Maximum nested |
MAX_CYCLONEDX_DEPTH
|
Returns:
| Type | Description |
|---|---|
tuple[InventoryComponent, ...]
|
Tuple of normalized :class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
SbomParseError
|
If nesting exceeds |
Source code in src/zerobom/backends/sbom_parser.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | |
parse_sbom_bytes(raw, *, asset_id, backend, location=None, scope=None, asset_type=None, extra_metadata=None, max_bytes=MAX_SBOM_FILE_BYTES, max_depth=MAX_CYCLONEDX_DEPTH)
Decode and parse bounded UTF-8 CycloneDX or SPDX JSON bytes from any storage source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
bytes
|
Unparsed UTF-8 JSON bytes representing a CycloneDX or SPDX document. |
required |
asset_id
|
str
|
Unique asset identifier (file path, object URI, image digest, etc.). |
required |
backend
|
str
|
Registered |
required |
location
|
str | None
|
Optional manifest location or region string. |
None
|
scope
|
str | None
|
Optional project/cluster/bucket scope override. |
None
|
asset_type
|
str | None
|
Optional asset category override. |
None
|
extra_metadata
|
Mapping[str, Any] | None
|
Optional extra metadata merged safely into the generated |
None
|
max_bytes
|
int
|
Maximum allowed raw payload size prior to UTF-8/JSON decoding. |
MAX_SBOM_FILE_BYTES
|
max_depth
|
int
|
Maximum permitted nested CycloneDX component depth. |
MAX_CYCLONEDX_DEPTH
|
Returns:
| Type | Description |
|---|---|
tuple[InventoryComponent, ...]
|
Tuple of normalized :class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
SbomParseError
|
If size exceeds |
Source code in src/zerobom/backends/sbom_parser.py
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 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | |
parse_spdx_dict(data, *, asset)
Parse an SPDX (2.2-2.3) JSON mapping into normalized components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Mapping[str, Any]
|
Decoded SPDX JSON object. |
required |
asset
|
AssetRef
|
:class: |
required |
Returns:
| Type | Description |
|---|---|
tuple[InventoryComponent, ...]
|
Tuple of normalized :class: |
Source code in src/zerobom/backends/sbom_parser.py
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 | |