Skip to content

An always-on second brain you talk to. Voice notes in Telegram → typed, linked knowledge in your Obsidian vault. Runs 24/7 on the Claude subscription you already have.

fix(cron): jobs.json is owner-only — prompts and chat ids are private

smixsf0698ac39aae
diff --git a/src/d_brain/services/cron_store.py b/src/d_brain/services/cron_store.py
index 8455353..86eb533 100644
--- a/src/d_brain/services/cron_store.py
+++ b/src/d_brain/services/cron_store.py
@@ -163,6 +163,9 @@ class CronStore:
payload = {"version": STORE_VERSION, "jobs": [asdict(j) for j in jobs]}
tmp = self.jobs_file.with_suffix(".json.tmp")
tmp.write_text(json.dumps(payload, ensure_ascii=False, indent=2))
+ # Prompts and chat ids are private — owner-only before the rename
+ # so a world-readable window never exists.
+ os.chmod(tmp, 0o600)
os.replace(tmp, self.jobs_file)
@contextmanager
diff --git a/tests/test_cron_store.py b/tests/test_cron_store.py
index f8af6cc..42e6ded 100644
--- a/tests/test_cron_store.py
+++ b/tests/test_cron_store.py
@@ -168,3 +168,11 @@ def test_unknown_fields_in_file_are_ignored(tmp_path):
(cron_dir / "jobs.json").write_text(json.dumps(payload))
jobs = CronStore(cron_dir).load()
assert jobs[0].id == "x"
+
+
+def test_jobs_file_is_owner_only(tmp_path):
+ # Prompts and chat ids are private — never world-readable.
+ store = CronStore(tmp_path / "cron")
+ store.save([_job()])
+ mode = store.jobs_file.stat().st_mode & 0o777
+ assert mode == 0o600