Skip to content

Commit ab73a58

Browse files
feat(pass-tray): warn on missing/stale materialized secrets
Materialize records pass deletions that leave home files behind; tray shows materialize_warnings with the error glyph until resolved. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1a594f4 commit ab73a58

7 files changed

Lines changed: 90 additions & 33 deletions

File tree

‎docs/pass-secretspec.md‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,15 @@ Grace: SSH ed25519 → ssh-to-age recipients may still appear in
110110
| Developer vault | `pass` + private GH store | GPG-encrypted values |
111111
| Runtime | `secretspec run` / wrappers | Env vars for child processes |
112112
| Home files | materialize map | Optional `$HOME` files (e.g. `~/.shit`) |
113-
| Machine/home | sops-nix | GPG key, ntfy topic, other host secrets |
114-
| Peer wake | ntfy (+ CI backup) | Empty ping — not the password itself |
115-
| CI canaries | private-repo Actions | Template decrypt smoke (CI-only GPG) |
113+
114+
If a mapped key is **deleted from pass**, materialize leaves any existing home
115+
file in place (stale) and records `materialize_warnings` in
116+
`~/.cache/pass-store-sync.status`. The pass-store tray shows those warnings
117+
(error glyph + menu line / tooltip) until the entry returns or the file is
118+
removed.
119+
| Machine/home | sops-nix | GPG key, ntfy topic, other host secrets |
120+
| Peer wake | ntfy (+ CI backup) | Empty ping — not the password itself |
121+
| CI canaries | private-repo Actions | Template decrypt smoke (CI-only GPG) |
116122

117123
---
118124

‎modules/apps/pass-store-tray/Cargo.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎modules/apps/pass-store-tray/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pass-store-tray"
3-
version = "0.3.2"
3+
version = "0.3.3"
44
edition = "2021"
55
description = "Pass store sync native tray applet (tray-icon / muda)"
66
license = "MIT"

‎modules/apps/pass-store-tray/src/main.rs‎

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ struct SyncStatus {
4040
materialized: Vec<String>,
4141
#[serde(default)]
4242
last_materialize_at: Option<String>,
43+
/// Soft edge cases from pass-materialize (missing/stale secrets) — not sync hard errors.
44+
#[serde(default)]
45+
materialize_warnings: Vec<String>,
4346
}
4447

4548
fn default_state() -> String {
@@ -126,6 +129,10 @@ fn icon_kind(status: &SyncStatus, rebuilding: bool, lock: bool) -> IconKind {
126129
if status.error.as_ref().is_some_and(|e| !e.is_empty()) || status.state == "error" {
127130
return IconKind::Error;
128131
}
132+
// Missing/stale materialize secrets — same attention glyph as error (no amber on template icons).
133+
if !status.materialize_warnings.is_empty() {
134+
return IconKind::Error;
135+
}
129136
if status.state == "uploading" || (lock && status.direction == "up") {
130137
return IconKind::Up;
131138
}
@@ -300,6 +307,7 @@ struct NativeTray {
300307
status_headline: MenuItem,
301308
status_detail: MenuItem,
302309
status_mat: MenuItem,
310+
status_warn: MenuItem,
303311
item_qtpass: MenuItem,
304312
item_log: MenuItem,
305313
item_quit: MenuItem,
@@ -312,6 +320,7 @@ impl NativeTray {
312320
let status_headline = MenuItem::new(ui_contract::status::HEADLINE, false, None);
313321
let status_detail = MenuItem::new(ui_contract::status::DETAIL, false, None);
314322
let status_mat = MenuItem::new(ui_contract::status::MATERIALIZED, false, None);
323+
let status_warn = MenuItem::new(ui_contract::status::WARNINGS, false, None);
315324
let item_qtpass = MenuItem::new(Action::OpenQtPass.label(), true, None);
316325
let item_log = MenuItem::new(Action::OpenSyncLog.label(), true, None);
317326
let item_quit = MenuItem::new(Action::Quit.label(), true, None);
@@ -321,6 +330,7 @@ impl NativeTray {
321330
let _ = menu.append(&status_headline);
322331
let _ = menu.append(&status_detail);
323332
let _ = menu.append(&status_mat);
333+
let _ = menu.append(&status_warn);
324334
let _ = menu.append(&PredefinedMenuItem::separator());
325335
// Actions from shared contract order (QtPass, sync log, then Quit)
326336
debug_assert_eq!(Action::ALL[0], Action::OpenQtPass);
@@ -345,6 +355,7 @@ impl NativeTray {
345355
status_headline,
346356
status_detail,
347357
status_mat,
358+
status_warn,
348359
item_qtpass,
349360
item_log,
350361
item_quit,
@@ -366,12 +377,15 @@ impl NativeTray {
366377
}
367378

368379
let err = status.error.as_deref().filter(|e| !e.is_empty());
380+
let warn_n = status.materialize_warnings.len();
369381
let headline = if rebuilding {
370382
"Rebuilding system…".to_string()
371383
} else if lock {
372384
format!("Syncing ({})…", status.direction)
373385
} else if let Some(e) = err {
374386
format!("Error: {e}")
387+
} else if warn_n > 0 {
388+
format!("Warning: {warn_n} secret issue(s)")
375389
} else {
376390
format!("{} · {}", status.state, status.direction)
377391
};
@@ -388,12 +402,31 @@ impl NativeTray {
388402
let last_mat = status.last_materialize_at.as_deref().unwrap_or("—");
389403
let mat_line = format!("Materialized: {mats} @ {last_mat}");
390404

405+
let warn_line = if status.materialize_warnings.is_empty() {
406+
"Secrets: ok".to_string()
407+
} else {
408+
// Show first warning; tooltip gets the full set.
409+
let first = &status.materialize_warnings[0];
410+
if warn_n == 1 {
411+
format!("⚠ {first}")
412+
} else {
413+
format!("⚠ {first} (+{})", warn_n - 1)
414+
}
415+
};
416+
391417
self.status_headline.set_text(headline.clone());
392418
self.status_detail.set_text(detail);
393419
self.status_mat.set_text(mat_line);
394-
let _ = self
395-
.tray
396-
.set_tooltip(Some(format!("pass sync: {headline}")));
420+
self.status_warn.set_text(warn_line);
421+
let tip = if status.materialize_warnings.is_empty() {
422+
format!("pass sync: {headline}")
423+
} else {
424+
format!(
425+
"pass sync: {headline}\n{}",
426+
status.materialize_warnings.join("\n")
427+
)
428+
};
429+
let _ = self.tray.set_tooltip(Some(tip));
397430
}
398431

399432
fn handle_menu(&mut self) {

‎modules/apps/pass-store-tray/src/ui_contract.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub mod status {
66
pub const HEADLINE: &str = "…";
77
pub const DETAIL: &str = " ";
88
pub const MATERIALIZED: &str = " ";
9+
pub const WARNINGS: &str = " ";
910
}
1011

1112
/// Clickable actions — keep this set tiny (native menu, not a window).

‎modules/apps/pass.nix‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
'';
133133
trayPkg = pkgs.rustPlatform.buildRustPackage {
134134
pname = "pass-store-tray";
135-
version = "0.3.2";
135+
version = "0.3.3";
136136
src = ./pass-store-tray;
137137
cargoLock.lockFile = ./pass-store-tray/Cargo.lock;
138138
nativeBuildInputs = [

‎scripts/pass-secretspec-materialize.sh‎

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ fi
3434
export PASSWORD_STORE_DIR
3535

3636
materialized='[]'
37+
warnings='[]'
3738
count=0
3839
while IFS= read -r key; do
3940
[[ -n $key ]] || continue
@@ -43,13 +44,23 @@ while IFS= read -r key; do
4344
case "$rel" in
4445
/* | *..*)
4546
warn "skip unsafe path for $key: $rel"
47+
warnings="$(jq -nc --argjson arr "$warnings" --arg w "skip unsafe path: $key" '$arr + [$w]')"
4648
continue
4749
;;
4850
esac
4951
out="${HOME_DIR}/${rel}"
5052
val="$(secretspec get -f "$SECRETSPEC_TOML" "$key" 2>/dev/null || true)"
5153
if [[ -z $val ]]; then
52-
warn "$key not available yet; skip $out"
54+
if [[ -e $out ]]; then
55+
# Edge case: removed from pass but home file still present (stale secret).
56+
w="$key missing from pass; stale file remains (~/$rel)"
57+
warn "$w"
58+
warnings="$(jq -nc --argjson arr "$warnings" --arg w "$w" '$arr + [$w]')"
59+
else
60+
w="$key missing from pass; not materialized (~/$rel)"
61+
warn "$w"
62+
warnings="$(jq -nc --argjson arr "$warnings" --arg w "$w" '$arr + [$w]')"
63+
fi
5364
continue
5465
fi
5566
umask 077
@@ -61,31 +72,37 @@ while IFS= read -r key; do
6172
log "wrote $out"
6273
done < <(jq -r 'keys[]' "$MAP_FILE")
6374

64-
# Merge materialize fields into status if present (best-effort; no plaintext).
65-
if [[ -f $STATUS_FILE ]] && command -v jq >/dev/null 2>&1; then
66-
now="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
67-
tmp="$(mktemp "${STATUS_FILE}.XXXXXX")"
68-
if jq -nc \
69-
--slurpfile prev "$STATUS_FILE" \
70-
--argjson materialized "$materialized" \
71-
--arg now "$now" \
72-
--arg msg "materialized ${count} file(s)" \
73-
'
74-
($prev[0] // {})
75-
+ {
76-
last_materialize_at: $now,
77-
materialized: $materialized,
78-
updated_at: $now,
79-
message: $msg
80-
}
81-
' >"$tmp" 2>/dev/null; then
82-
mv "$tmp" "$STATUS_FILE"
83-
else
84-
rm -f "$tmp"
85-
fi
75+
# Merge materialize fields into status (best-effort; no plaintext).
76+
# Create the status file if missing so tray can still see warnings.
77+
now="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
78+
warn_count="$(jq -nr --argjson w "$warnings" '$w | length')"
79+
mkdir -p "$(dirname "$STATUS_FILE")"
80+
if [[ ! -f $STATUS_FILE ]]; then
81+
printf '%s\n' '{"state":"idle","direction":"none","message":"materialize only"}' >"$STATUS_FILE"
82+
fi
83+
tmp="$(mktemp "${STATUS_FILE}.XXXXXX")"
84+
if jq -nc \
85+
--slurpfile prev "$STATUS_FILE" \
86+
--argjson materialized "$materialized" \
87+
--argjson materialize_warnings "$warnings" \
88+
--arg now "$now" \
89+
--arg msg "materialized ${count} file(s); ${warn_count} warning(s)" \
90+
'
91+
($prev[0] // {})
92+
+ {
93+
last_materialize_at: $now,
94+
materialized: $materialized,
95+
materialize_warnings: $materialize_warnings,
96+
updated_at: $now,
97+
message: $msg
98+
}
99+
' >"$tmp" 2>/dev/null; then
100+
mv "$tmp" "$STATUS_FILE"
101+
else
102+
rm -f "$tmp"
86103
fi
87104

88-
log "done (${count} file(s))"
105+
log "done (${count} file(s), ${warn_count} warning(s))"
89106

90107
# Optional: apply Wi-Fi profiles after PSK materialize (dendritic.wifi).
91108
if command -v dendritic-wifi-ensure >/dev/null 2>&1; then

0 commit comments

Comments
 (0)