Repository navigation
Add policy-gated ETW logging for sidecar GCS - #2982
Manish Ranjan Mahanta (marma-dev) wants to merge 5 commits into
Conversation
Signed-off-by: Manish Ranjan Mahanta <mmahanta@microsoft.com>
Signed-off-by: Manish Ranjan Mahanta <mmahanta@microsoft.com>
06b5d20 to
03b8e51
Compare
Signed-off-by: Manish Ranjan Mahanta <mmahanta@microsoft.com>
|
Investigated the windows-2022 failure: GitHub reports "The self-hosted runner lost communication with the server." Rego policy, repo, LCOW/WCOW-tagged, non-functional, and parity test steps passed before the runner was lost during the shim-test step. The full job log blob is unavailable, so the underlying runner-disconnect cause could not be established. Pushed provider cleanup in 9f13693; a new CI run should validate it. |
|
Shouldn't early boot/init events of gcs side car be captured but relayed only when enabled? We could maintain a small, bounded in-memory buffer in the sidecar’s logging hook: record only startup diagnostics; flush them to ETW once the policy is validated and allows runtime logging; discard them if policy denies logging. |
Signed-off-by: Manish Ranjan Mahanta <mmahanta@microsoft.com>
|
apurv15 Implemented the startup-buffer suggestion in e6a6291. The sidecar buffers at most 128 pre-policy events / 256 KiB (16 KiB per event), and flushes only after both runtime-policy approval and ETW collector enablement. Policy denial discards pending events. Live VBS C-WCOW testing forwarded 14 pre-policy startup events; the denied-policy run forwarded zero sidecar events while other ETW providers continued. |
| } | ||
|
|
||
| func copyStartupEntry(entry *logrus.Entry) (*logrus.Entry, int, bool) { | ||
| if len(entry.Message) > maxStartupEventBytes { |
There was a problem hiding this comment.
AI feedback:
Every event passes through copyStartupEntry , even after policy approval and collector enablement. Any unsupported field drops the entire event. For example, the existing “unpacked COSE1 cert chain” diagnostic contains a cwtClaims map and will never reach ETW. The underlying ETW hook supports formatting such values. Restrict startup filtering to startup buffering, or preserve these fields safely during live forwarding.
There was a problem hiding this comment.
Fixed in 580166b. Once policy is approved and ETW collection is enabled, live events now pass directly to the ETW hook; bounded copying is used only for startup-buffered entries. Added regression coverage for live cwtClaims passthrough and safe copying of buffered structured claims. Targeted Windows tests, vet, Rego build, and pinned lint passed.
| logrus.WithError(err).Error("failed to close sidecar ETW provider") | ||
| } | ||
| }() | ||
| runtimeLogHook.Store(runtimeHook) |
There was a problem hiding this comment.
AI feedback:
After publishing the hook, initialization can load false , then an ETW callback sets the hook to true , and initialization subsequently applies its stale false . With no further notification, forwarding remains disabled despite an active collector.
There was a problem hiding this comment.
Fixed in 580166b. RuntimeLoggingController serializes collector state updates with hook attachment, preserving the latest enable/disable state regardless of callback ordering. Added coverage for both enable-before-attach and attach-before-enable. Targeted Windows tests, vet, Rego build, and pinned lint passed.
Signed-off-by: Manish Ranjan Mahanta <mmahanta@microsoft.com>
Summary
Validation performed
Compatibility and coverage notes
Startup event buffering
The sidecar now retains at most 128 pre-policy events / 256 KiB (16 KiB per event). Buffered events flush only after validated
allow_runtime_loggingapproval and ETW collector enablement; policy denial discards them. Oversized or unsupported startup records are dropped. No post-policy events are queued while collection is disabled.Final VBS C-WCOW test (Secure Boot enabled, private Rego sidecar): 14 pre-policy sidecar startup events were delivered after Log Forward Service enabled; host parsed all without timestamp errors. With runtime logging denied: zero sidecar events, while other ETW providers continued forwarding. Unit coverage includes both policy/collector orderings, denial, event and byte bounds, oversized fields, and concurrent state changes.