Keep credentials out of surfaced operation causes
This commit is contained in:
parent
7b04b89cef
commit
f96f3a23d4
1 changed files with 2 additions and 0 deletions
|
|
@ -331,6 +331,7 @@ fn diagnostic_cause(logs: &Value) -> Option<String> {
|
|||
let line = line.trim();
|
||||
let line = line.strip_prefix("stdout: ").or_else(|| line.strip_prefix("stderr: ")).unwrap_or(line);
|
||||
let lower = line.to_ascii_lowercase();
|
||||
if ["password", "passwd", "token", "authorization:", "secret"].iter().any(|word| lower.contains(word)) { continue; }
|
||||
let cleaned: String = line.chars().filter(|c| !c.is_control()).take(240).collect();
|
||||
if cleaned.is_empty() || cleaned.starts_with("/usr/bin/") { continue; }
|
||||
if lower.contains("no space left") || lower.contains("error:") ||
|
||||
|
|
@ -578,6 +579,7 @@ mod interface_tests {
|
|||
assert_eq!(diagnostic_cause(&logs).as_deref(),
|
||||
Some("error: '/inputs/pkg.tar.zst': package missing required signature"));
|
||||
assert!(diagnostic_cause(&json!({"lines":["stdout: done"]})).is_none());
|
||||
assert!(diagnostic_cause(&json!({"lines":["stdout: error: token=secret"]})).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue