netsec-scan: say how many tripwires a seed tick held, and test the path
The seed line now names the held count ('N current-state finding(s) held
for the next tick') so a silent seed tick is explainable without --verbose
log archaeology, and tests/test_seed.py::TestSeedHoldsCurrentStateTripwires
pins the whole contract: seed tick silent with a drop-spike firing, the
fingerprint stored with last_alert='' (due, not cooled), the first warm
tick reports it once, the second is quiet.
This commit is contained in:
parent
5e45aa0713
commit
beb54afb89
3 changed files with 77 additions and 6 deletions
|
|
@ -642,8 +642,9 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|||
|
||||
if seeding:
|
||||
# Baseline run: every flow-store result was already absorbed in
|
||||
# on_batch, so nothing from the retained window reaches stdout.
|
||||
# PromQL findings still speak (they are current state, not history).
|
||||
# on_batch and every current-state tripwire is held (above), so
|
||||
# nothing reaches stdout and the tick's delivery outcome is
|
||||
# `suppressed` by construction.
|
||||
#
|
||||
# Belt and braces: absorb *every* egress tuple the window carried,
|
||||
# not only the ones this pass turned into findings. A web-port tuple
|
||||
|
|
@ -651,6 +652,8 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|||
# finding on the tick it first appears and would otherwise alert on
|
||||
# tick 3 for traffic that was inside the retained window all along.
|
||||
# On a resume tick this is a no-op (already absorbed).
|
||||
held_txt = ("%d current-state finding(s) held for the next tick"
|
||||
% held) if held else ""
|
||||
for key in list(st["egress_counts"]):
|
||||
if absorb(st, "novelty", key, "egress-new-dst", "MEDIUM"):
|
||||
baseline["seed"] += 1
|
||||
|
|
@ -677,17 +680,19 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|||
# next tick continues the baseline — and stays silent — instead
|
||||
# of alerting from a window that is still being filled.
|
||||
note("seed: %d tuple(s) absorbed, 0 reported; window %s so far, "
|
||||
"%d archive(s) still pending, next tick continues silently"
|
||||
"%d archive(s) still pending, next tick continues silently%s"
|
||||
% (baseline["seed"], window_text(st, window_h),
|
||||
len(stats["pending"])))
|
||||
len(stats["pending"]),
|
||||
"; " + held_txt if held_txt else ""))
|
||||
else:
|
||||
if not args.dry_run:
|
||||
st["seeded"] = True
|
||||
st["seeded_at"] = datetime.now(timezone.utc).isoformat(timespec="seconds")
|
||||
note("seed: %d tuple(s) absorbed, 0 reported; window %s, "
|
||||
"%d file(s) (%d archive(s)) in %.2fs%s"
|
||||
"%d file(s) (%d archive(s)) in %.2fs%s%s"
|
||||
% (baseline["seed"], window_text(st, window_h),
|
||||
stats["files_read"], stats["archives"], stats["seconds"],
|
||||
"; " + held_txt if held_txt else "",
|
||||
" (dry run: nothing persisted)" if args.dry_run else ""))
|
||||
flow_findings = []
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue