Skip to content

Commit f99422a

Browse files
araustin01carlmontanari
authored andcommitted
censor sensitive exported JSON values
1 parent bbd4021 commit f99422a

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/ffi-options.zig

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,12 @@ fn cStr(ptr: [*c]const u8, len: usize) []const u8 {
494494
return ptr[0..len];
495495
}
496496

497+
fn redactedStr(len: usize) []const u8 {
498+
if (len == 0) return "";
499+
500+
return "REDACTED";
501+
}
502+
497503
const ffi_options_top_level_args_json_ish_placeholder =
498504
\\ "logger_level": "{s}",
499505
\\ "transport_kind": "{s}",
@@ -607,10 +613,10 @@ fn ffiOptionsAuthToJSON(allocator: std.mem.Allocator, o: *const FFIOptions) ![]u
607613
ffi_options_auth_args_json_ish_placeholder,
608614
.{
609615
cStr(o.auth.username, o.auth.username_len),
610-
cStr(o.auth.password, o.auth.password_len),
616+
redactedStr(o.auth.password_len),
611617
cStr(o.auth.private_key_path, o.auth.private_key_path_len),
612-
cStr(o.auth.private_key_passphrase, o.auth.private_key_passphrase_len),
613-
cStr(o.auth.private_key_content, o.auth.private_key_content_len),
618+
redactedStr(o.auth.private_key_passphrase_len),
619+
redactedStr(o.auth.private_key_content_len),
614620
optBool(o.auth.force_in_session_auth),
615621
optBool(o.auth.bypass_in_session_auth),
616622
cStr(o.auth.username_pattern, o.auth.username_pattern_len),

0 commit comments

Comments
 (0)