From 33cddb57cd632939700380a90f92a12360221a98 Mon Sep 17 00:00:00 2001 From: CarterPerez-dev Date: Wed, 29 Apr 2026 01:22:18 -0400 Subject: [PATCH] fix(demo): wire AuditSubscriber so events reach the audit log Tier 1 demo was creating an AuditLog instance but never subscribing it to the bus, so the verification step always reported '0 events'. Now we explicitly start the AuditSubscriber and the verifier reports the actual chain length (4 step events + RotationCompleted = 5). --- .../src/cre/compliance/bundle.cr | 6 +++--- .../src/cre/compliance/control_mapping.cr | 12 ++++++------ .../src/cre/demo/tier_1.cr | 6 +++++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/PROJECTS/intermediate/credential-rotation-enforcer/src/cre/compliance/bundle.cr b/PROJECTS/intermediate/credential-rotation-enforcer/src/cre/compliance/bundle.cr index 1f5e7274..23282a04 100644 --- a/PROJECTS/intermediate/credential-rotation-enforcer/src/cre/compliance/bundle.cr +++ b/PROJECTS/intermediate/credential-rotation-enforcer/src/cre/compliance/bundle.cr @@ -105,9 +105,9 @@ module CRE::Compliance private def build_manifest(entries : Array(FileEntry)) : String { - "framework" => @framework, - "generated" => Time.utc.to_rfc3339, - "files" => entries.map { |e| + "framework" => @framework, + "generated" => Time.utc.to_rfc3339, + "files" => entries.map { |e| {"name" => e.name, "sha256" => e.sha256_hex, "size" => e.size} }, }.to_json diff --git a/PROJECTS/intermediate/credential-rotation-enforcer/src/cre/compliance/control_mapping.cr b/PROJECTS/intermediate/credential-rotation-enforcer/src/cre/compliance/control_mapping.cr index a1dc8b12..9cef80f6 100644 --- a/PROJECTS/intermediate/credential-rotation-enforcer/src/cre/compliance/control_mapping.cr +++ b/PROJECTS/intermediate/credential-rotation-enforcer/src/cre/compliance/control_mapping.cr @@ -23,12 +23,12 @@ module CRE::Compliance } PCI_DSS = { - "rotation.completed" => ["8.3.9", "8.6.3"], - "rotation.failed" => ["8.3.9", "10.2.1"], - "policy.violation" => ["8.6.3", "10.2.1"], - "drift.detected" => ["10.2.1", "11.5.2"], - "audit.batch.sealed" => ["10.5.2", "10.5.3"], - "key.rotation.kek" => ["3.7.4"], + "rotation.completed" => ["8.3.9", "8.6.3"], + "rotation.failed" => ["8.3.9", "10.2.1"], + "policy.violation" => ["8.6.3", "10.2.1"], + "drift.detected" => ["10.2.1", "11.5.2"], + "audit.batch.sealed" => ["10.5.2", "10.5.3"], + "key.rotation.kek" => ["3.7.4"], } ISO27001 = { diff --git a/PROJECTS/intermediate/credential-rotation-enforcer/src/cre/demo/tier_1.cr b/PROJECTS/intermediate/credential-rotation-enforcer/src/cre/demo/tier_1.cr index 22475c05..3f384aa1 100644 --- a/PROJECTS/intermediate/credential-rotation-enforcer/src/cre/demo/tier_1.cr +++ b/PROJECTS/intermediate/credential-rotation-enforcer/src/cre/demo/tier_1.cr @@ -5,6 +5,7 @@ require "../engine/event_bus" require "../engine/rotation_orchestrator" +require "../engine/subscribers/audit_subscriber" require "../persistence/sqlite/sqlite_persistence" require "../rotators/env_file" require "../audit/audit_log" @@ -51,15 +52,18 @@ module CRE::Demo io.puts CRE::Tui::Ansi.bold("Step 3 - Rotating (4-step contract):") bus = CRE::Engine::EventBus.new ch = bus.subscribe(buffer: 256) + audit_sub = CRE::Engine::Subscribers::AuditSubscriber.new(bus, log) + audit_sub.start bus.run rotator = CRE::Rotators::EnvFileRotator.new orchestrator = CRE::Engine::RotationOrchestrator.new(bus, persist) state = orchestrator.run(cred, rotator) - sleep 0.05.seconds + sleep 0.15.seconds drain_steps(ch, io) + audit_sub.stop bus.stop io.puts ""