Outputs & Alerting
Output serializers (Rich terminal, JSON, SARIF 2.1.0) and noise-gated outbound notifiers (HMAC webhooks, Slack Block Kit, idempotent GitHub Issues).
outputs
Output formatters and outbound alerting (Rich, JSON, SARIF, Webhook, Slack, GitHub).
AlertDeliveryError
Bases: RuntimeError
Raised when outbound alert validation, signing, or HTTP delivery fails.
AlertDeliveryResult
GitHubIssueError
Bases: AlertDeliveryError
Raised when GitHub repository validation or REST issue synchronization fails.
GitHubIssueSyncer(repo, token, *, api_base_url=DEFAULT_GITHUB_API_URL, labels=DEFAULT_ISSUE_LABELS, include_triage=False, dry_run=False, timeout_seconds=15.0, http_client=None)
Idempotent GitHub REST API v3 client for creating and updating zerobom issues.
Deduplicates issues across repeated CI runs using the hidden HTML marker
<!-- zerobom:advisory-id:<id> --> rather than brittle issue titles.
Initialize a GitHub issue syncer targeting a single repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo
|
str
|
Target repository in |
required |
token
|
str
|
GitHub bearer credential with |
required |
api_base_url
|
str
|
GitHub REST API base URL (HTTPS enforced). |
DEFAULT_GITHUB_API_URL
|
labels
|
Sequence[str]
|
Labels attached when creating new issues. |
DEFAULT_ISSUE_LABELS
|
include_triage
|
bool
|
Also sync issues for pending |
False
|
dry_run
|
bool
|
Compute create/update decisions without mutating GitHub state. |
False
|
timeout_seconds
|
float
|
Bounded per-request timeout in seconds. |
15.0
|
http_client
|
Client | None
|
Optional injected |
None
|
Raises:
| Type | Description |
|---|---|
GitHubIssueError
|
If |
Source code in src/zerobom/outputs/github_issue.py
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 | |
close()
Close the underlying httpx.Client if owned by this instance.
Source code in src/zerobom/outputs/github_issue.py
496 497 498 499 | |
sync_outcome(outcome)
Create, update, or leave unchanged the GitHub issue for one pipeline outcome.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outcome
|
PipelineOutcome
|
Evaluated :class: |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Structured |
IssueSyncResult
|
class: |
Raises:
| Type | Description |
|---|---|
GitHubIssueError
|
If issue rendering or GitHub API synchronization fails. |
Source code in src/zerobom/outputs/github_issue.py
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 | |
sync_outcomes(outcomes)
Synchronize GitHub issues across a sequence of pipeline outcomes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outcomes
|
Sequence[PipelineOutcome]
|
Sequence of evaluated :class: |
required |
Returns:
| Type | Description |
|---|---|
tuple[IssueSyncResult, ...]
|
Tuple of :class: |
Source code in src/zerobom/outputs/github_issue.py
716 717 718 719 720 721 722 723 724 725 | |
IssueSyncResult
Bases: StrictModel
Outcome summary returned by :meth:GitHubIssueSyncer.sync_outcome.
Attributes:
| Name | Type | Description |
|---|---|---|
advisory_id |
str
|
Advisory identifier evaluated during sync (or |
action |
Literal['created', 'updated', 'unchanged', 'skipped', 'dry_run_create', 'dry_run_update']
|
Sync action taken (created, updated, unchanged, skipped, or dry-run). |
issue_number |
int | None
|
GitHub issue number if created, updated, or matched. |
issue_url |
str | None
|
Web URL ( |
reason |
str | None
|
Optional human-readable explanation when skipped. |
RenderedGitHubIssue
Bases: StrictModel
Deterministic, sanitized GitHub Issue payload derived from a verified outcome.
Attributes:
| Name | Type | Description |
|---|---|---|
advisory_id |
str
|
Canonical OSV/PRECVE advisory identifier. |
event_type |
Literal['auto_hit', 'triage_review']
|
Actionable event classification ( |
marker |
str
|
Hidden HTML comment marker used for idempotent issue lookup. |
title |
str
|
Bounded single-line GitHub issue title. |
body |
str
|
Sanitized GitHub Flavored Markdown body ending with |
labels |
tuple[str, ...]
|
Issue labels applied when creating a new issue. |
SlackNotifier(webhook_url, *, allowed_hosts=SLACK_WEBHOOK_HOSTS, timeout_seconds=10.0, dns_resolver=default_dns_resolver, http_client=None)
Host-pinned Slack Incoming Webhook client sending sanitized Block Kit payloads.
Initialize a Slack Incoming Webhook notifier pinned to Slack webhook hosts.
Source code in src/zerobom/outputs/slack.py
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 | |
close()
Close the internally managed HTTP client connection pool.
Source code in src/zerobom/outputs/slack.py
376 377 378 379 | |
send_outcome(outcome, *, triage_id=None, include_interactive_buttons=True, dedup_check=None, on_sent=None)
Send a consolidated AUTO or interactive TRIAGE notification to Slack.
Source code in src/zerobom/outputs/slack.py
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 | |
send_outcomes(outcomes, *, triage_ids=None, include_interactive_buttons=True, dedup_check=None, on_sent=None)
Deliver Slack notifications across a sequence of :class:PipelineOutcome entries.
Source code in src/zerobom/outputs/slack.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
WebhookNotifier(url, *, signing_secret=None, timeout_seconds=_DEFAULT_WEBHOOK_TIMEOUT_SECONDS, allow_insecure_http=False, allow_private_targets=False, allowed_hosts=None, dns_resolver=default_dns_resolver, http_client=None)
Stateless SSRF-hardened JSON webhook alert client with optional HMAC signing.
Initialize an SSRF-validated generic webhook alert client.
Source code in src/zerobom/outputs/webhook.py
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 | |
close()
Close the internally managed HTTP client connection pool.
Source code in src/zerobom/outputs/webhook.py
414 415 416 417 | |
send_outcome(outcome, *, triage_id=None, dedup_check=None, on_sent=None)
Evaluate routing rules and deliver a consolidated alert if warranted.
Source code in src/zerobom/outputs/webhook.py
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 | |
send_outcomes(outcomes, *, triage_ids=None, dedup_check=None, on_sent=None)
Deliver alerts across a sequence of :class:PipelineOutcome entries.
Source code in src/zerobom/outputs/webhook.py
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
build_issue_marker(advisory_id)
Build the deterministic HTML comment marker used for issue deduplication.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
advisory_id
|
str
|
Advisory identifier (e.g. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Comment marker |
Raises:
| Type | Description |
|---|---|
GitHubIssueError
|
If |
Source code in src/zerobom/outputs/github_issue.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
build_json_report(outcomes)
Convert pipeline outcomes into a schema-stable JSON-serializable report dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outcomes
|
Sequence[PipelineOutcome]
|
Sequence of evaluated :class: |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing |
dict[str, Any]
|
|
Source code in src/zerobom/outputs/json_out.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 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 | |
build_sarif_log(outcomes, *, repo_root=None)
Build a GitHub Code Scanning-compatible SARIF 2.1.0 log dictionary.
Emits tool.driver.rules[] definitions with numeric security-severity tags,
repo-relative artifactLocation.uri values, cloud-agnostic asset properties, and
deterministic partialFingerprints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outcomes
|
Sequence[PipelineOutcome]
|
Sequence of evaluated :class: |
required |
repo_root
|
Path | None
|
Optional repository root directory used to relativize SBOM paths. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
SARIF 2.1.0 dictionary ready for JSON serialization and upload. |
Source code in src/zerobom/outputs/sarif.py
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 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 | |
build_slack_auto_payload(outcome)
Build a consolidated Slack Block Kit alert payload for matched vulnerabilities.
Source code in src/zerobom/outputs/slack.py
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 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 | |
build_slack_triage_decision_payload(*, advisory_id, status, actor, match_count=0, already_decided=False, note=None)
Build a Block Kit replace_original update payload after human triage decision.
Source code in src/zerobom/outputs/slack.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 334 335 | |
build_slack_triage_payload(outcome, *, triage_id=None, include_interactive_buttons=True)
Build a Slack Block Kit review notification for TRIAGE advisories.
Source code in src/zerobom/outputs/slack.py
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 | |
build_webhook_payload(outcome, *, event_type, triage_id=None)
Build a canonical JSON webhook payload and its deterministic SHA-256 digest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outcome
|
PipelineOutcome
|
Evaluated :class: |
required |
event_type
|
Literal['auto_hit', 'triage_review']
|
Classified notification category ( |
required |
triage_id
|
str | None
|
Optional persisted triage queue ID included for review workflows. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[dict[str, Any], str]
|
Tuple of |
Source code in src/zerobom/outputs/webhook.py
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 | |
classify_alert_event(outcome)
Determine outbound alerting policy for a :class:PipelineOutcome.
Policy:
- DROP -> None (silent).
- TRIAGE -> "triage_review" when a compiled OSV advisory is present.
- AUTO or pure scan (credibility is None) -> "auto_hit" ONLY when
at least one vulnerable inventory component matched.
Source code in src/zerobom/outputs/webhook.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
escape_slack_mrkdwn(text, *, max_length=2800)
Sanitize untrusted text for Slack mrkdwn to neutralize mention/link injection.
Strips ASCII control characters (except \n and \t), escapes &, <, and
> (blocking <!channel>, <!here>, <@U...>, and spoofed links), and bounds
rendered length.
Source code in src/zerobom/outputs/slack.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
render_github_issue(outcome, *, labels=DEFAULT_ISSUE_LABELS, include_triage=False)
Render an actionable :class:PipelineOutcome into a sanitized GitHub issue payload.
Noise suppression matches zerobom alerting invariants:
DROPadvisories andAUTOadvisories with zero vulnerable matches returnNone.AUTOadvisories with vulnerable inventory hits always render.TRIAGEadvisories render only wheninclude_triage=True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outcome
|
PipelineOutcome
|
Evaluated pipeline outcome. |
required |
labels
|
Sequence[str]
|
Issue labels attached on creation. |
DEFAULT_ISSUE_LABELS
|
include_triage
|
bool
|
When |
False
|
Returns:
| Type | Description |
|---|---|
RenderedGitHubIssue | None
|
Rendered issue payload, or |
Raises:
| Type | Description |
|---|---|
GitHubIssueError
|
If an actionable outcome lacks an OSV advisory or valid labels. |
Source code in src/zerobom/outputs/github_issue.py
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 | |
render_json_outcomes(outcomes, *, indent=2)
Render pipeline outcomes as formatted JSON text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outcomes
|
Sequence[PipelineOutcome]
|
Sequence of evaluated :class: |
required |
indent
|
int
|
JSON indentation spaces. |
2
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted UTF-8 JSON report string. |
Source code in src/zerobom/outputs/json_out.py
73 74 75 76 77 78 79 80 81 82 83 | |
render_sarif(outcomes, *, repo_root=None, indent=2)
Serialize pipeline outcomes as formatted SARIF 2.1.0 JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outcomes
|
Sequence[PipelineOutcome]
|
Sequence of evaluated :class: |
required |
repo_root
|
Path | None
|
Optional repository root for relativizing SBOM paths. |
None
|
indent
|
int
|
JSON indentation spaces. |
2
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted UTF-8 SARIF 2.1.0 JSON string. |
Source code in src/zerobom/outputs/sarif.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
render_terminal_outcomes(outcomes, *, console=None)
Render advisory verification, grounded quotes, and SBOM hits cleanly to the terminal.
All untrusted strings (article titles, URLs, evidence quotes, PURLs, versions) are wrapped
in rich.text.Text objects to prevent terminal markup-injection vulnerabilities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outcomes
|
Sequence[PipelineOutcome]
|
Sequence of evaluated :class: |
required |
console
|
Console | None
|
Optional |
None
|
Source code in src/zerobom/outputs/terminal.py
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 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
sanitize_github_markdown(text, *, max_length=2000)
Sanitize untrusted text before embedding it into GitHub Flavored Markdown.
Defends against raw HTML/XSS injection, HTML comment breakouts, automatic image
rendering ( pixel/SSRF vectors), and unintended mass @mention pings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Untrusted text extracted from security blogs, SBOMs, or package metadata. |
required |
max_length
|
int
|
Maximum output character length before truncation. |
2000
|
Returns:
| Type | Description |
|---|---|
str
|
Escaped, length-bounded Markdown-safe string. |
Source code in src/zerobom/outputs/github_issue.py
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 | |
sanitize_table_cell(text, *, max_length=200)
Sanitize untrusted text for safe single-line rendering inside a GFM table cell.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Untrusted cell string. |
required |
max_length
|
int
|
Maximum cell length. |
200
|
Returns:
| Type | Description |
|---|---|
str
|
Single-line, pipe-escaped Markdown cell string. |
Source code in src/zerobom/outputs/github_issue.py
194 195 196 197 198 199 200 201 202 203 204 205 206 | |
sign_webhook_body(body, secret, timestamp)
Compute sha256=<hex> HMAC signature over {timestamp}.{body}.
Source code in src/zerobom/outputs/webhook.py
146 147 148 149 150 | |
validate_github_repo(repo)
Validate and split a owner/repo GitHub repository slug.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo
|
str
|
Repository slug in |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
Validated |
Raises:
| Type | Description |
|---|---|
GitHubIssueError
|
If |
Source code in src/zerobom/outputs/github_issue.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
validate_webhook_url(url, *, allow_insecure_http=False, allow_private_targets=False, allowed_hosts=None, dns_resolver=default_dns_resolver)
Validate an outbound webhook/callback URL against scheme, host, and SSRF policies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
Candidate webhook or Slack callback URL. |
required |
allow_insecure_http
|
bool
|
Explicit opt-in for plain |
False
|
allow_private_targets
|
bool
|
Explicit opt-in to skip public-IP checks (internal relays only). |
False
|
allowed_hosts
|
frozenset[str] | None
|
Optional exact lowercase hostname allowlist (e.g. Slack webhook hosts). |
None
|
dns_resolver
|
DnsResolver
|
DNS resolution callable returning IP strings for host/port pairs. |
default_dns_resolver
|
Returns:
| Type | Description |
|---|---|
str
|
Normalized trimmed webhook URL. |
Raises:
| Type | Description |
|---|---|
AlertDeliveryError
|
If syntax, scheme, credentials, host allowlist, or IP checks fail. |
Source code in src/zerobom/outputs/webhook.py
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 141 142 143 | |