chore(secrets): cover the spawn ledger and meet-node token in the private-writer invariant; drop unused import
Both writers already go through atomic_json_write(mode=0o600) but were missing from tests/test_private_credential_writers.py::_writers, so a "write then chmod" regression in either would not be caught. Also removes the `import os` left unused in agent/secret_sources/_cache.py (ruff F401).
This commit is contained in:
@@ -11,7 +11,6 @@ from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
The credential writers (auth.json, MCP OAuth tokens, secret-source cache, iron-proxy state, the
|
||||
exchanged-JWT store, the Photon sidecar record, pairing data, the vault blob, the third-party
|
||||
credential file) all funnel through ``utils.atomic_json_write`` / ``atomic_write_text`` /
|
||||
credential file, the spawn ledger, the meet-node token) all funnel through ``utils.atomic_json_write`` / ``atomic_write_text`` /
|
||||
``atomic_write_bytes`` with ``mode=0o600``. The contract under test: the *temp* file is created
|
||||
with mode 0600 (``O_EXCL``) BEFORE any byte lands and the final file carries 0600 — never
|
||||
"open at umask, then chmod" (the #19673 window). POSIX-only: mode bits are not enforced on Windows.
|
||||
@@ -49,13 +49,18 @@ def _writers(home: Path, monkeypatch):
|
||||
from agent.vault_store import VaultStore
|
||||
from gateway import pairing
|
||||
from hermes_cli import auth as auth_mod, copilot_auth
|
||||
from hermes_cli import process_identity
|
||||
from tools import mcp_oauth
|
||||
from plugins.google_meet.node.server import NodeServer
|
||||
from plugins.platforms.photon import adapter as photon_adapter
|
||||
|
||||
photon_record = home / "runtime" / "photon.json"
|
||||
monkeypatch.setattr(photon_adapter, "_runtime_record_path", lambda: photon_record)
|
||||
ledger = home / "spawn-ledger.json"
|
||||
monkeypatch.setattr(process_identity, "_ledger_path", lambda: ledger)
|
||||
cache = DiskCache("probe.json", key_serializer=str)
|
||||
vault = VaultStore(home / "vault")
|
||||
meet_node = NodeServer(token_path=home / "meetings" / "node_token.json")
|
||||
return [
|
||||
("auth.json", lambda: auth_mod._save_auth_store({"version": auth_mod.AUTH_STORE_VERSION, "providers": {}}),
|
||||
auth_mod._auth_file_path()),
|
||||
@@ -71,6 +76,8 @@ def _writers(home: Path, monkeypatch):
|
||||
("photon sidecar record", lambda: photon_adapter._write_runtime_record(1, "tok", 2), photon_record),
|
||||
("pairing", lambda: pairing._save_json_file(home / "pairing" / "p.json", {"a": 1}), home / "pairing" / "p.json"),
|
||||
("vault blob", lambda: vault._write_all([]), vault._vault_path),
|
||||
("spawn ledger", lambda: process_identity.register_self("probe"), ledger),
|
||||
("meet node token", meet_node.ensure_token, meet_node.token_path),
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user