Skip to content

armgit / kiri

Public Imported from GitHub
0

A small, fast container runtime for macOS, Windows and Linux

Rust

Crash reports go without your account and image names; redact more (#8)

Precious Okwu77c2911a2682
diff --git a/crates/kiri-win/src/diag.rs b/crates/kiri-win/src/diag.rs
index 9987621..91874fa 100644
--- a/crates/kiri-win/src/diag.rs
+++ b/crates/kiri-win/src/diag.rs
@@ -257,7 +257,8 @@ fn send_report(text: &str) -> io::Result<String> {
}
text = format!("{MARK}{}", &text[cut..]);
};
- let (status, v) = crate::share::post_report(&body)?;
+ // A report the person sends: signed in, so it can be answered.
+ let (status, v) = crate::share::post_report(&body, true)?;
let why = v["error"].as_str().map(|e| format!(": {e}")).unwrap_or_default();
match status {
200 | 201 => v["id"]
diff --git a/crates/kiri/src/diag/redact.rs b/crates/kiri/src/diag/redact.rs
index 3ce283b..b9e1503 100644
--- a/crates/kiri/src/diag/redact.rs
+++ b/crates/kiri/src/diag/redact.rs
@@ -1,8 +1,10 @@
-//! Takes out of logs and reports what must not leave the Mac: the home
-//! folder's path (it names the person), bearer and other `Authorization`
-//! values, the values of token, password and secret keys in JSON, query
-//! strings, `KEY=value` pairs and `--flag value`, passwords in URLs, private
-//! keys, and tokens that say what they are (`ks_…`, `ghp_…`, `glpat-…`).
+//! Takes out of logs and reports what must not leave the computer: the home
+//! folder's path (it names the person), in every form Windows writes it,
+//! bearer and other `Authorization` values, the values of token, password,
+//! secret and cookie keys in JSON, query strings, `KEY=value`, `key: value`
+//! and `key = value` pairs and `--flag value`, passwords in URLs, private
+//! keys, JWTs, and tokens that say what they are (`ks_…`, `ghp_…`,
+//! `sk_live_…`, `xoxb-…`, `sk-ant-…`).
//!
//! Patterns, not parsing: it runs over any text (log lines, panic
//! messages, macOS crash reports), so it errs towards taking out too much.
@@ -11,15 +13,17 @@ const MARK: &str = "[redacted]";
#[derive(Debug, Default)]
pub struct Redactor {
- home: Option<String>,
+ /// The home folder as it may be written, and whether to match it
+ /// ignoring case (Windows paths).
+ homes: Vec<(String, bool)>,
/// Exact strings to take out wherever they appear (the signed-in token).
secrets: Vec<String>,
}
impl Redactor {
pub fn new(home: Option<String>, secrets: Vec<String>) -> Redactor {
- let home = home.map(|h| h.trim_end_matches('/').to_owned()).filter(|h| h.len() > 1);
- Redactor { home, secrets: secrets.into_iter().filter(|s| s.len() >= 8).collect() }
+ let homes = home.map(|h| home_forms(&h)).unwrap_or_default();
+ Redactor { homes, secrets: secrets.into_iter().filter(|s| s.len() >= 8).collect() }
}
/// `$HOME` → `~`, and the patterns.
@@ -37,8 +41,8 @@ impl Redactor {
for secret in &self.secrets {
s = s.replace(secret.as_str(), MARK);
}
- if let Some(home) = &self.home {
- s = replace_home(&s, home);
+ for (home, any_case) in &self.homes {
+ s = replace_home(&s, home, *any_case);
}
patterns(&s)
}
@@ -55,7 +59,10 @@ pub fn patterns(s: &str) -> String {
// The same inside a JSON string: `{\"token\":\"…\"}`.
let s = json_values(&s, "\\\"");
let s = assignments(&s);
+ let s = spaced_values(&s);
let s = flags(&s);
+ let s = jwts(&s);
+ let s = emails(&s);
TOKEN_PREFIXES.iter().fold(s, |s, prefix| prefixed_tokens(&s, prefix))
}
@@ -69,7 +76,34 @@ fn sensitive(key: &str) -> bool {
let k = key.trim_start_matches('-').to_ascii_lowercase().replace(['-', '.'], "_");
matches!(k.as_str(), "auth" | "authorization" | "pass" | "pgpass")
|| k.ends_with("_pass")
- || ["token", "password", "passwd", "passphrase", "secret", "apikey", "api_key", "access_key", "private_key", "credential", "crashreporterkey"].iter().any(|w| k.contains(w))
+ || ["token", "password", "passwd", "passphrase", "secret", "apikey", "api_key", "access_key", "private_key", "credential", "crashreporterkey", "cookie", "session"].iter().any(|w| k.contains(w))
+}
+
+/// The home folder as logs may write it. A Windows one (`C:\Users\Ada`) is
+/// also matched doubled inside JSON (`C:\\Users\\Ada`), with forward
+/// slashes, as WSL mounts it (`/mnt/c/Users/Ada`) and as the WSL home of the
+/// same name (`/home/ada`), all ignoring case, as Windows does.
+fn home_forms(home: &str) -> Vec<(String, bool)> {
+ let home = home.trim_end_matches(['/', '\\']);
+ let b = home.as_bytes();
+ if b.len() > 2 && b[0].is_ascii_alphabetic() && b[1] == b':' && (b[2] == b'\\' || b[2] == b'/') {
+ let parts: Vec<&str> = home[2..].split(['\\', '/']).filter(|p| !p.is_empty()).collect();
+ if parts.is_empty() {
+ return Vec::new();
+ }
+ let drive = &home[..2];
+ let mut forms = vec![
+ format!("{drive}\\\\{}", parts.join("\\\\")),
+ format!("{drive}\\{}", parts.join("\\")),
+ format!("{drive}/{}", parts.join("/")),
+ format!("/mnt/{}/{}", drive[..1].to_ascii_lowercase(), parts.join("/")),
+ ];
+ if let Some(user) = parts.last().filter(|u| u.len() > 1) {
+ forms.push(format!("/home/{user}"));
+ }
+ return forms.into_iter().map(|f| (f, true)).collect();
+ }
+ if home.starts_with('/') && home.len() > 1 { vec![(home.to_owned(), false)] } else { Vec::new() }
}
/// A PEM private key, whole; without its end line, everything after its
@@ -159,18 +193,25 @@ fn authorization(s: &str) -> String {
out
}
-/// `/Users/ada/x` → `~/x`, but not `/Users/adam`.
-fn replace_home(s: &str, home: &str) -> String {
+/// `/Users/ada/x` → `~/x`, but not `/Users/adam`. `any_case` matches
+/// `c:\users\ADA` too.
+fn replace_home(s: &str, home: &str, any_case: bool) -> String {
+ // ASCII lower-casing keeps every byte where it was.
+ let (hay, needle) = if any_case { (s.to_ascii_lowercase(), home.to_ascii_lowercase()) } else { (s.to_owned(), home.to_owned()) };
let mut out = String::with_capacity(s.len());
- let mut rest = s;
- while let Some(i) = rest.find(home) {
- let after = &rest[i + home.len()..];
- let whole = after.bytes().next().is_none_or(|b| !(is_word(b) || b == b'-' || b == b'.'));
- out.push_str(&rest[..i]);
- out.push_str(if whole { "~" } else { home });
- rest = after;
+ let mut last = 0;
+ let mut from = 0;
+ while let Some(i) = hay[from..].find(&needle).map(|i| i + from) {
+ let end = i + needle.len();
+ let whole = s.as_bytes().get(end).is_none_or(|&b| !(is_word(b) || b == b'-' || b == b'.'));
+ if whole {
+ out.push_str(&s[last..i]);
+ out.push('~');
+ last = end;
+ }
+ from = end;
}
- out.push_str(rest);
+ out.push_str(&s[last..]);
out
}
@@ -282,8 +323,141 @@ fn assignments(s: &str) -> String {
out.push_str(MARK);
}
last = end;
+ i = end;
+ } else {
+ // Not a secret: the value may hold one (`env=[DB_PASSWORD=x`).
+ i += 1;
+ }
+ }
+ out.push_str(&s[last..]);
+ out
+}
+
+/// `password: hunter2`, `token = "abc"`, `aws_secret_access_key = …`,
+/// `Cookie: a=b; c=d`: the value after a sensitive key, a `:` or an `=`
+/// with spaces around it. A cookie header loses the rest of its line.
+/// `Authorization` has its own pass, and `key=value` with no spaces is
+/// [`assignments`]'.
+fn spaced_values(s: &str) -> String {
+ let b = s.as_bytes();
+ let key_byte = |c: u8| is_word(c) || c == b'-' || c == b'.';
+ let blank = |c: u8| c == b' ' || c == b'\t';
+ let (mut out, mut last) = (String::with_capacity(s.len()), 0);
+ let mut i = 0;
+ while i < b.len() {
+ let sep = b[i];
+ if !(sep == b':' || sep == b'=') || i < last {
+ i += 1;
+ continue;
+ }
+ let mut j = i;
+ while j > 0 && blank(b[j - 1]) {
+ j -= 1;
+ }
+ let mut k = j;
+ while k > 0 && key_byte(b[k - 1]) {
+ k -= 1;
+ }
+ let mut start = i + 1;
+ while start < b.len() && blank(b[start]) {
+ start += 1;
+ }
+ let key = &s[k..j];
+ let lower = key.to_ascii_lowercase();
+ let spaced = j < i || start > i + 1;
+ // `=` with no spaces is `assignments`; `==`, `!=` and `<=` compare;
+ // `://` is a URL and `::` a path.
+ let next = b.get(i + 1).copied();
+ let prev = if i > 0 { Some(b[i - 1]) } else { None };
+ let skip = k == j
+ || (sep == b'=' && (!spaced || matches!(next, Some(b'=')) || matches!(prev, Some(b'=' | b'!' | b'<' | b'>'))))
+ || (sep == b':' && (matches!(next, Some(b'/' | b':')) || prev == Some(b':')))
+ || matches!(lower.as_str(), "authorization" | "proxy-authorization")
+ || !sensitive(key)
+ || start >= b.len()
+ || b[start] == b'\n'
+ || b[start] == b'\r';
+ if skip {
+ i += 1;
+ continue;
+ }
+ let cookie = lower.ends_with("cookie");
+ let quote = matches!(b[start], b'"' | b'\'').then_some(b[start] as char);
+ let end = match quote {
+ Some(q) => s[start + 1..].find(q).map_or(b.len(), |n| start + 1 + n + 1),
+ None if cookie => s[start..].find(['\n', '\r']).map_or(b.len(), |n| start + n),
+ None => s[start..].find(|c: char| c.is_whitespace() || ",;&)<>\"'".contains(c)).map_or(b.len(), |n| start + n),
+ };
+ let value = &s[start..end];
+ if end <= start || value.trim_matches(['"', '\'']).starts_with(MARK) {
+ i += 1;
+ continue;
+ }
+ out.push_str(&s[last..start]);
+ match quote {
+ Some(q) => {
+ out.push(q);
+ out.push_str(MARK);
+ out.push(q);
+ }
+ None => out.push_str(MARK),
+ }
+ last = end;
+ i = end;
+ }
+ out.push_str(&s[last..]);
+ out
+}
+
+/// `[email protected]`, whole: an email address names the person. Not
+/// `[email protected]:…`, and not `image@sha256:…`.
+fn emails(s: &str) -> String {
+ let b = s.as_bytes();
+ let local = |c: u8| c.is_ascii_alphanumeric() || b"._%+-".contains(&c);
+ let domain = |c: u8| c.is_ascii_alphanumeric() || c == b'-' || c == b'.';
+ let (mut out, mut last, mut from) = (String::with_capacity(s.len()), 0, 0);
+ while let Some(at) = s[from..].find('@').map(|i| i + from) {
+ from = at + 1;
+ let mut i = at;
+ while i > last && local(b[i - 1]) {
+ i -= 1;
+ }
+ let mut j = at + 1;
+ while j < b.len() && domain(b[j]) {
+ j += 1;
+ }
+ let host = s[at + 1..j].trim_end_matches('.');
+ let j = at + 1 + host.len();
+ let tld = host.rsplit('.').next().unwrap_or("");
+ let ok = i < at && &s[i..at] != "git" && host.contains('.') && tld.len() >= 2 && tld.bytes().all(|c| c.is_ascii_alphabetic());
+ if ok {
+ out.push_str(&s[last..i]);
+ out.push_str(MARK);
+ last = j;
+ from = j;
}
- i = end.max(i + 1);
+ }
+ out.push_str(&s[last..]);
+ out
+}
+
+/// A JWT (`eyJ….eyJ….sig`), whole.
+fn jwts(s: &str) -> String {
+ let b = s.as_bytes();
+ let part = |c: u8| c.is_ascii_alphanumeric() || c == b'_' || c == b'-';
+ let (mut out, mut last, mut from) = (String::with_capacity(s.len()), 0, 0);
+ while let Some(i) = s[from..].find("eyJ").map(|i| i + from) {
+ let (mut j, mut dots) = (i, 0);
+ while j < b.len() && (part(b[j]) || (b[j] == b'.' && dots < 2)) {
+ dots += usize::from(b[j] == b'.');
+ j += 1;
+ }
+ if (i == 0 || !is_word(b[i - 1])) && dots == 2 && j - i >= 24 && s[i..j].split('.').nth(1).is_some_and(|p| p.starts_with("eyJ")) {
+ out.push_str(&s[last..i]);
+ out.push_str(MARK);
+ last = j;
+ }
+ from = j.max(i + 3);
}
out.push_str(&s[last..]);
out
@@ -333,9 +507,13 @@ fn flags(s: &str) -> String {
out
}
-/// What starts a token that says what it is: Kiri share's, GitHub's, GitLab's,
-/// Docker Hub's, and an AWS access key id.
-const TOKEN_PREFIXES: [&str; 10] = ["ks_", "ghp_", "gho_", "ghu_", "ghs_", "ghr_", "github_pat_", "glpat-", "dckr_pat_", "AKIA"];
+/// What starts a token that says what it is: Kiri share's, GitHub's,
+/// GitLab's, Docker Hub's, an AWS access key id, Stripe's, Slack's,
+/// Anthropic's, OpenAI's, Google's, npm's and PyPI's.
+const TOKEN_PREFIXES: [&str; 26] = [
+ "ks_", "ghp_", "gho_", "ghu_", "ghs_", "ghr_", concat!("github", "_pat_"), "glpat-", "glptt-", "dckr_pat_", "AKIA", "ASIA", "sk_live_", "sk_test_", "rk_live_", "rk_test_",
+ "xoxb-", "xoxp-", "xoxa-", "xoxr-", "sk-ant-", "sk-proj-", "sk-svcacct-", "AIza", "npm_", "pypi-",
+];
/// `prefix…`, a token of that kind, wherever it appears.
fn prefixed_tokens(s: &str, prefix: &str) -> String {
@@ -486,6 +664,87 @@ mod tests {
assert!(!once.contains("abcdefghijkl") && !once.contains("0123456789abcdef") && !once.contains("/Users/ada"), "{once}");
}
+ #[test]
+ fn windows_home_in_every_form() {
+ let r = Redactor::new(Some(r"C:\Users\Alex".into()), Vec::new());
+ for (text, want) in [
+ (r"opened C:\Users\Alex\proj", r"opened ~\proj"),
+ (r#"{"path":"C:\\Users\\Alex\\proj"}"#, r#"{"path":"~\\proj"}"#),
+ ("C:/Users/Alex/proj", "~/proj"),
+ (r"c:\users\ALEX\proj", r"~\proj"),
+ ("/mnt/c/Users/Alex/proj", "~/proj"),
+ ("/home/alex/.docker/config.json", "~/.docker/config.json"),
+ ] {
+ assert_eq!(r.apply(text), want, "{text}");
+ }
+ // A longer name is someone else.
+ assert_eq!(r.apply(r"C:\Users\Alexandra\x"), r"C:\Users\Alexandra\x");
+ assert_eq!(Redactor::new(Some(r"C:\".into()), Vec::new()).apply(r"C:\x"), r"C:\x");
+ }
+
+ #[test]
+ fn colon_and_spaced_values() {
+ for (text, want) in [
+ ("password: hunter2", "password: [redacted]"),
+ ("token : abc123 next", "token : [redacted] next"),
+ (r#"token: "two words""#, r#"token: "[redacted]""#),
+ ("aws_secret_access_key = wJalrXUtnFEMI/K7MDENG", "aws_secret_access_key = [redacted]"),
+ (r#"Config { password: "x", port: 5432 }"#, r#"Config { password: "[redacted]", port: 5432 }"#),
+ ("X-Api-Key: abcdef0123456789", "X-Api-Key: [redacted]"),
+ ("Cookie: session=abc; theme=dark\nnext", "Cookie: [redacted]\nnext"),
+ ("Set-Cookie: sg_session=abc; Path=/", "Set-Cookie: [redacted]"),
+ ] {
+ assert_eq!(patterns(text), want, "{text}");
+ }
+ for text in ["error: could not connect", "at 12:30: done", "see https://runkiri.com/token", "token refresh failed", "port = 5432", "password:\nnext"] {
+ assert_eq!(patterns(text), text);
+ }
+ }
+
+ #[test]
+ fn a_secret_inside_another_value() {
+ assert_eq!(patterns("env=[DB_PASSWORD=hunter2 STRIPE=1]"), "env=[DB_PASSWORD=[redacted] STRIPE=1]");
+ assert_eq!(patterns("args=--password=hunter2"), "args=--password=[redacted]");
+ }
+
+ #[test]
+ fn email_addresses() {
+ assert_eq!(patterns("logged in as [email protected]."), "logged in as [redacted].");
+ for text in ["[email protected]:a/b.git", "nginx@sha256:abcd", "a @ b", "x@localhost"] {
+ assert_eq!(patterns(text), text);
+ }
+ }
+
+ #[test]
+ fn jwts_whole() {
+ let jwt = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.abcdefghijklmn";
+ assert_eq!(patterns(&format!("got {jwt} ok")), "got [redacted] ok");
+ assert_eq!(patterns("eyJustAWord and eyJx.y"), "eyJustAWord and eyJx.y");
+ }
+
+ #[test]
+ fn more_tokens_that_say_what_they_are() {
+ for (text, want) in [
+ ("sk_live_abcdefghijklmnopqrstu", "sk_live_[redacted]"),
+ ("xoxb-123456789012-abcdefghijkl", "xoxb-[redacted]"),
+ ("sk-ant-api03-abcdefghijklmnopqrstuvwxyz", "sk-ant-[redacted]"),
+ ("sk-proj-abcdefghijklmnopqrstuvwxyz012345", "sk-proj-[redacted]"),
+ ("AIzaSyA1234567890abcdefghijklmnop", "AIza[redacted]"),
+ ("npm_abcdefghijklmnopqrstuvwxyz0123456789", "npm_[redacted]"),
+ ] {
+ assert_eq!(patterns(text), want, "{text}");
+ }
+ }
+
+ #[test]
+ fn redacting_the_new_forms_twice_changes_nothing() {
+ let text = r#"password: hunter2 Cookie: a=b eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.abcdefghijklmn sk_live_abcdefghijklmnop env=[DB_PASSWORD=x [email protected] C:/Users/Ada/x"#;
+ let r = Redactor::new(Some(r"C:\Users\Ada".into()), Vec::new());
+ let once = r.apply(text);
+ assert_eq!(r.apply(&once), once);
+ assert!(!once.contains("hunter2") && !once.contains("ada@") && !once.contains("Users/Ada"), "{once}");
+ }
+
#[test]
fn leaves_other_text_and_unicode_alone() {
let text = "VM booted in 112 ms → 4 CPUs, café=ok, a = b";
diff --git a/crates/kiri/src/diag/report.rs b/crates/kiri/src/diag/report.rs
index 947bd23..0b2935a 100644
--- a/crates/kiri/src/diag/report.rs
+++ b/crates/kiri/src/diag/report.rs
@@ -17,8 +17,10 @@
//! "created_at":"<RFC 3339>","text":"<the redacted report or crash>"}
//! ```
//!
-//! with `Authorization: Bearer <token>` when signed in to Kiri Cloud. It
-//! answers `201 {"id":"rep_…"}`, the id a person can quote to us. Crash
+//! A report the person sends carries `Authorization: Bearer <token>` when
+//! signed in to Kiri Cloud, so it can be answered. A crash never does: it
+//! goes without the person's account. Crash uploads also leave out the image
+//! and container names their log lines name. It answers `201 {"id":"rep_…"}`, the id a person can quote to us. Crash
//! files that went become `<name>.sent.txt`; any other answer leaves them
//! for the next try.
@@ -532,7 +534,8 @@ pub fn body(kind: &str, part: Part, created: SystemTime, text: &str, install_id:
pub fn send(kind: &str, part: Part, created: SystemTime, text: &str) -> io::Result<String> {
let state = super::state_dir().ok_or_else(|| io::Error::other("HOME is not set"))?;
let body = body(kind, part, created, text, &install_id(&state));
- let (status, v) = crate::share::post_report(&body)?;
+ // Only a report the person sends carries their sign-in; a crash never does.
+ let (status, v) = crate::share::post_report(&body, kind == "report")?;
let why = v["error"].as_str().map(|e| format!(": {e}")).unwrap_or_default();
match status {
200 | 201 => v["id"]
@@ -637,22 +640,57 @@ fn send_claimed(dir: &Path, name: &str, claimed: &Path, redactor: &Redactor) ->
}
}
+/// Log fields that name the person's images and containers.
+const NAME_FIELDS: [&str; 5] = ["image", "name", "container", "reference", "repo"];
+
/// What a crash upload holds: the crash file, then the last lines its part
-/// logged up to the crash.
+/// logged up to the crash, without the image and container names they
+/// carry, wherever those appear.
fn crash_upload(state: &Path, secs: u64, part: Part, text: &str) -> String {
let until = time::rfc3339(UNIX_EPOCH + Duration::from_secs(secs + 1));
- let lines: Vec<String> = read_lines(state, &[part], Filter::default(), 2000)
- .iter()
+ let mut lines: Vec<Value> = read_lines(state, &[part], Filter::default(), 2000)
+ .into_iter()
.filter(|v| v["time"].as_str().is_some_and(|t| t < until.as_str()))
- .map(|v| render(v, true, false))
.collect();
- let lines = &lines[lines.len().saturating_sub(CRASH_LOG_LINES)..];
+ lines.drain(..lines.len().saturating_sub(CRASH_LOG_LINES));
let mut s = text.trim_end().to_owned();
let _ = writeln!(s, "\n\n==== The last {} log lines before it ====", lines.len());
- for l in lines {
- let _ = writeln!(s, "{l}");
+ for l in &lines {
+ let _ = writeln!(s, "{}", render(l, true, false));
}
- s
+ without_names(&s, &lines)
+}
+
+/// `text` with every image and container name that `lines` log taken out,
+/// longest first, so `web` doesn't leave half of `web-admin`.
+fn without_names(text: &str, lines: &[Value]) -> String {
+ let mut names: Vec<&str> = lines
+ .iter()
+ .flat_map(|v| NAME_FIELDS.iter().filter_map(move |k| v["fields"][*k].as_str()))
+ .map(str::trim)
+ .filter(|n| n.len() >= 3 && *n != "[redacted]")
+ .collect();
+ names.sort_by_key(|n| std::cmp::Reverse(n.len()));
+ names.dedup();
+ names.into_iter().fold(text.to_owned(), |s, n| replace_whole(&s, n, "[name]"))
+}
+
+/// Every `name` in `s` that stands alone (not inside a longer word, so a
+/// container `web` leaves `webpki` be, but not `web.kiri.local`).
+fn replace_whole(s: &str, name: &str, with: &str) -> String {
+ let joins = |c: Option<char>| c.is_some_and(|c| c.is_alphanumeric() || c == '_' || c == '-');
+ let (mut out, mut last, mut from) = (String::with_capacity(s.len()), 0, 0);
+ while let Some(i) = s[from..].find(name).map(|i| i + from) {
+ let end = i + name.len();
+ if !joins(s[..i].chars().next_back()) && !joins(s[end..].chars().next()) {
+ out.push_str(&s[last..i]);
+ out.push_str(with);
+ last = end;
+ }
+ from = end;
+ }
+ out.push_str(&s[last..]);
+ out
}
/// The id a sent crash file ends with.
@@ -794,6 +832,19 @@ mod tests {
let _ = std::fs::remove_dir_all(&home);
}
+ #[test]
+ fn crash_uploads_leave_out_image_and_container_names() {
+ let line = |msg: &str, fields: &[(&str, String)]| -> Value { serde_json::from_str(&super::super::json_line("2026-10-28T09:41:07.123Z", Level::Info, Part::Daemon, msg, fields)).unwrap() };
+ let lines = [
+ line("image pull failed", &[("image", "registry.acme.corp/secret-app:1.2".into()), ("error", "registry.acme.corp/secret-app:1.2: unauthorized".into())]),
+ line("container exited", &[("name", "web".into()), ("image", "nginx".into())]),
+ ];
+ let text = format!("panic at webpki: web.kiri.local is gone\n{}\n{}", render(&lines[0], true, false), render(&lines[1], true, false));
+ let out = without_names(&text, &lines);
+ assert!(!out.contains("secret-app") && !out.contains("acme") && !out.contains("nginx"), "{out}");
+ assert!(out.contains("webpki") && out.contains("[name].kiri.local") && out.contains("name=[name]"), "{out}");
+ }
+
#[test]
fn renders_lines_for_people() {
let v: Value = serde_json::from_str(&super::super::json_line("2026-10-28T09:41:07.123Z", Level::Warn, Part::Daemon, "container exited", &[("id", "3f2a".into()), ("error", "no such file".into())])).unwrap();
diff --git a/crates/kiri/src/share.rs b/crates/kiri/src/share.rs
index 45fe239..e69614a 100644
--- a/crates/kiri/src/share.rs
+++ b/crates/kiri/src/share.rs
@@ -429,12 +429,14 @@ fn api_error(v: &Value, status: u16) -> io::Error {
}
/// Kiri Cloud's diagnostics intake, `POST /v1/reports` on the same edge
-/// (`KIRI_SHARE_SERVER` and the config's `server` move it, as for sharing),
-/// signed in when there is a token, anonymous when not. See `crate::diag::report`
-/// (and crates/kiri-win/src/diag.rs on Windows).
-pub fn post_report(body: &Value) -> io::Result<(u16, Value)> {
+/// (`KIRI_SHARE_SERVER` and the config's `server` move it, as for sharing).
+/// `signed` sends the Kiri Cloud token when there is one, so a report the
+/// person sent can be answered; crashes always go without it, so they never
+/// name the person's GitHub account. See `crate::diag::report` (and
+/// crates/kiri-win/src/diag.rs on Windows).
+pub fn post_report(body: &Value, signed: bool) -> io::Result<(u16, Value)> {
let cfg = read_config();
- api(&server(&cfg), "POST", "/v1/reports", Some(body), cfg.token.as_deref())
+ api(&server(&cfg), "POST", "/v1/reports", Some(body), cfg.token.as_deref().filter(|_| signed))
}
// ---------------------------------------------------------------- account
diff --git a/crates/kiri/src/ui/index.html b/crates/kiri/src/ui/index.html
index d1f3760..cd90830 100644
--- a/crates/kiri/src/ui/index.html
+++ b/crates/kiri/src/ui/index.html
@@ -5474,7 +5474,7 @@ function diagPane() {
const crashes = dg.crashes == null ? `<div class="none">Looking for crash reports…</div>` : dg.crashes.length ? dg.crashes.map(crash).join("") : `<div class="none">No crashes. Kiri keeps a report here if one of its parts ever stops unexpectedly.</div>`;
return `<div class="pane diag"><h3>Diagnostics</h3>
<div class="pref"><span class="t">Send crash reports automatically</span>
- <span class="d">When part of Kiri crashes, the stack trace, versions and the last 200 log lines before it go to Kiri Cloud. Nothing from inside your containers; your home folder, tokens and passwords are blanked.</span>
+ <span class="d">When part of Kiri crashes, the stack trace and the last 200 log lines before it go to Kiri Cloud, with Kiri's and the system's versions, the computer's model and a random ID for this install. Never your Kiri Cloud account, and nothing from inside your containers. Your home folder, image and container names, tokens and passwords are taken out.</span>
<div class="seg" role="group" aria-label="Send crash reports automatically"><button data-dgauto="0" aria-pressed="${prefs.crashReports !== true}">Off</button><button data-dgauto="1" aria-pressed="${prefs.crashReports === true}">On</button></div></div>
<div class="pref"><span class="t">Diagnostics report</span>
<span class="d">Recent logs, crash reports and versions in one redacted file, for when something goes wrong.</span>
@@ -5557,7 +5557,7 @@ function drawReport() {
const item = (t, d) => `<div class="rp-item">${dgIcon("check")}<span class="t">${t}</span><span class="d">${d}</span></div>`;
scrim.innerHTML = `<div class="dialog rp-dialog" role="dialog" aria-modal="true" aria-labelledby="rp-t">
<h3 id="rp-t">${send_ ? "Send a report to Kiri" : "Create a diagnostics report"}</h3>
- <p>${send_ ? "We get the file below, redacted, and you get an ID to quote when you write to us." : "One text file, redacted, saved to your Desktop and shown in Finder. Read it before you share it."}</p>
+ <p>${send_ ? "We get the file below, redacted, and you get an ID to quote when you write to us. If you're signed in to Kiri Cloud, it says it's from you, so we can reply." : "One text file, redacted, saved to your Desktop and shown in Finder. Read it before you share it."}</p>
<div class="rp-list">${item("Kiri's logs", "The last 300 lines from the window, the engine and kiri commands, and the engine's own output")}
${item("Crash reports", "The 5 newest, and macOS's own crash reports for Kiri from the last 30 days")}
${item("Kiri and this Mac", "Versions, macOS, whether the engine runs, how many containers and images")}
diff --git a/docs/releases/0.1.16.md b/docs/releases/0.1.16.md
deleted file mode 100644
index a3710e1..0000000
--- a/docs/releases/0.1.16.md
+++ /dev/null
@@ -1,7 +0,0 @@
-## Fixed
-- **Turning off automatic updates now sticks.** On Mac, Windows and Linux, Settings showed **Off**, but the choice wasn't saved, so Kiri checked for updates again at the next launch. It's saved now.
-- **Turning on crash reports sends only new crashes.** Switching them on used to send every crash still waiting, including ones you'd answered **Not now** to. Kiri now sends only crashes from after you turned reports on. You can still send an older one yourself from its card.
-- **Logs and reports take out more secrets.** Passwords in URLs, `Authorization` values of any kind, PEM private keys, values after flags such as `--password`, GitHub, GitLab, Docker Hub and AWS access key tokens, and keys such as `PGPASS`, `API-KEY` and `*_PRIVATE_KEY` are now replaced with `[redacted]` before anything leaves your computer. It errs towards taking out too much: the whole user part of a URL goes, not only its password.
-- **Windows: updates stay on HTTPS.** Kiri no longer follows a redirect from the update feed down to plain HTTP, and release builds no longer accept a feed from a local file.
-
-Thanks to [@9trocode](https://github.com/9trocode) for all four fixes, Kiri's first outside contribution.
diff --git a/docs/releases/0.1.17.md b/docs/releases/0.1.17.md
new file mode 100644
index 0000000..f96ae39
--- /dev/null
+++ b/docs/releases/0.1.17.md
@@ -0,0 +1,14 @@
+## Fixed
+- **Turning off automatic updates now sticks.** On Mac, Windows and Linux, Settings showed **Off**, but the choice wasn't saved, so Kiri checked for updates again at the next launch. It's saved now.
+- **Turning on crash reports sends only new crashes.** Switching them on used to send every crash still waiting, including ones you'd answered **Not now** to. Kiri now sends only crashes from after you turned reports on. You can still send an older one yourself from its card.
+- **Logs and reports take out more secrets.** Passwords in URLs, `Authorization` values of any kind, PEM private keys, values after flags such as `--password`, GitHub, GitLab, Docker Hub and AWS access key tokens, and keys such as `PGPASS`, `API-KEY` and `*_PRIVATE_KEY` are now replaced with `[redacted]` before anything leaves your computer. It errs towards taking out too much: the whole user part of a URL goes, not only its password.
+- **Windows: updates stay on HTTPS.** Kiri no longer follows a redirect from the update feed down to plain HTTP, and release builds no longer accept a feed from a local file.
+- **Crash reports never carry your Kiri Cloud account.** A crash sent while you were signed in to Kiri Cloud went with your sign-in, so it named your GitHub account. Crashes now always go without it. A diagnostics report you send yourself still says it's from you, so we can reply, and the Send dialog says so.
+- **Crash reports leave out your image and container names.** The log lines a crash report carries named the images you pulled and the containers that stopped, including private registries. Those names are now taken out wherever they appear in the report.
+- **Windows: reports take out your user name in every form.** Your home folder was only blanked when written exactly as `C:\Users\you`. Now it also goes in lower case, with forward slashes, doubled inside JSON, as WSL's `/mnt/c/Users/you`, and as `/home/you` in the engine's log.
+- **Still more secrets are redacted.** `password: …` and `key = …` with spaces, `Cookie` and `Set-Cookie` headers, `X-Api-Key`, JWTs, Stripe, Slack, Anthropic, OpenAI, Google, npm and PyPI tokens, and email addresses. A secret written inside another value, such as `env=[DB_PASSWORD=…`, is no longer missed.
+- **Settings says exactly what a crash report sends**: the stack trace, the last 200 log lines, versions, the computer's model and a random ID for this install.
+
+0.1.16 was tagged but never released; its fixes are in this release.
+
+Thanks to [@9trocode](https://github.com/9trocode) for the first four fixes, Kiri's first outside contribution.