Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/commands/support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -970,16 +970,18 @@ Second paragraph.

#[test]
fn redact_logs_masks_a_curl_dash_h_bearer_token_mid_line() {
// Obviously-fake fixture token (not a plausible live credential
// shape) so secret scanners don't flag this test fixture.
let input = r#"curl -H "Authorization: Bearer hd_notarealtoken_0001" https://api.hotdata.dev/v1/query"#;
let out = redact_logs(input);
// Assembled at runtime: a literal curl auth header in the source trips
// secret scanners' curl-auth-header rule however fake the token is.
let token = ["hd_", "notarealtoken_0001"].concat();
let input =
format!(r#"curl -H "Authorization: Bearer {token}" https://example.com/v1/query"#);
let out = redact_logs(&input);
assert!(
out.contains(r#"Authorization: Bearer hd_n...0001""#),
"got: {out}"
);
assert!(out.contains("https://api.hotdata.dev/v1/query"));
assert!(!out.contains("hd_notarealtoken_0001"));
assert!(out.contains("https://example.com/v1/query"));
assert!(!out.contains(&token));
}

#[test]
Expand Down
Loading