Skip to content

Commit 463fb0c

Browse files
committed
feat(redaction): Add name field to redaction logic and corresponding tests
- Updated the redaction function to include the "name" field in the list of sensitive keys, ensuring it is redacted from JSON bodies. - Added a new test case to verify that the "name" field is properly redacted, along with the email field, confirming the expected output format.
1 parent f2d1e9e commit 463fb0c

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src-tauri/src/plugin_engine/host_api.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn redact_body(body: &str) -> String {
6464

6565
// Redact JSON values for sensitive keys
6666
let sensitive_keys = [
67-
"password", "token", "access_token", "refresh_token", "secret",
67+
"name", "password", "token", "access_token", "refresh_token", "secret",
6868
"api_key", "apiKey", "authorization", "bearer", "credential",
6969
"session_token", "sessionToken", "auth_token", "authToken",
7070
"user_id", "account_id", "email", "login", "analytics_tracking_id",
@@ -1286,4 +1286,14 @@ mod tests {
12861286
assert!(redacted.contains("[REDACTED]"), "login should be redacted, got: {}", redacted);
12871287
assert!(redacted.contains("c9df...a6cf"), "analytics_tracking_id should show first4...last4, got: {}", redacted);
12881288
}
1289+
1290+
#[test]
1291+
fn redact_body_redacts_name_field() {
1292+
let body = r#"{"userStatus":{"name":"Robin Ebers","email":"rob@sunstory.com","planStatus":{}}}"#;
1293+
let redacted = redact_body(body);
1294+
assert!(!redacted.contains("Robin Ebers"), "name should be redacted, got: {}", redacted);
1295+
assert!(!redacted.contains("rob@sunstory.com"), "email should be redacted, got: {}", redacted);
1296+
// "Robin Ebers" is 11 chars (<=12) so becomes [REDACTED]
1297+
assert!(redacted.contains("\"name\": \"[REDACTED]\""), "name should show [REDACTED], got: {}", redacted);
1298+
}
12891299
}

0 commit comments

Comments
 (0)