Skip to content

Commit 78cf3fa

Browse files
swernerclaude
andcommitted
event redaction: document content-only vs exact-match entry points
build_redacted_event_payload and redacted_event_json apply only the content-based pass; redacted_run_event additionally applies the per-run exact-match SecretRedactor. The names didn't signal that difference, so a caller holding a run redactor could silently pick a content-only path. Document each entry point and steer such callers to redacted_run_event. Also drop a no-op guard in the node_label branch: the redacted value was already computed, so the conditional assignment saved nothing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4242d2e commit 78cf3fa

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

lib/crates/fabro-workflow/src/event/redaction.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ use fabro_store::EventPayload;
55
use fabro_util::json::normalize_json_value;
66
use serde_json::Value;
77

8+
/// Build a stored event payload with **content-based** redaction only.
9+
///
10+
/// This does not apply the per-run exact-match [`SecretRedactor`]; on any
11+
/// surface that has the run's redactor, use [`redacted_run_event`] instead so
12+
/// declared low-entropy secrets are removed as well.
813
pub fn build_redacted_event_payload(event: &RunEvent, run_id: &RunId) -> Result<EventPayload> {
914
EventPayload::new(redacted_event_value(event)?, run_id).map_err(anyhow::Error::from)
1015
}
@@ -22,6 +27,11 @@ pub fn redacted_run_event(event: &RunEvent, redactor: &SecretRedactor) -> Result
2227
RunEvent::try_from(&payload).map_err(anyhow::Error::from)
2328
}
2429

30+
/// Serialize an event to JSON with **content-based** redaction only.
31+
///
32+
/// Like [`build_redacted_event_payload`], this applies the content pass but not
33+
/// the per-run exact-match [`SecretRedactor`]. Prefer [`redacted_run_event`]
34+
/// wherever the run redactor is available.
2535
pub fn redacted_event_json(event: &RunEvent) -> Result<String> {
2636
serde_json::to_string(&redacted_event_value(event)?).map_err(anyhow::Error::from)
2737
}
@@ -42,10 +52,7 @@ fn redact_event_payload_secrets(value: &mut Value, redactor: &SecretRedactor) {
4252
redact_redactable_event_properties(properties, redactor);
4353
}
4454
if let Some(Value::String(label)) = value.get_mut("node_label") {
45-
let redacted = redactor.redact_into(label);
46-
if redacted != *label {
47-
*label = redacted;
48-
}
55+
*label = redactor.redact_into(label);
4956
}
5057
}
5158

0 commit comments

Comments
 (0)