AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
Python ai-promptsai-skillblueskyclaudeclaude-codeclawhubdeep-researchhackernewsinstagramopenclawpolymarketrecencyredditresearchsocial-mediatiktoktrendstwitterweb-searchyoutube
fix: tighten project config trust reporting
Trevin Chowc5ff5505b30d
diff --git a/skills/last30days/scripts/lib/env.py b/skills/last30days/scripts/lib/env.pyindex 7da9f971..76e83e16 100644--- a/skills/last30days/scripts/lib/env.py+++ b/skills/last30days/scripts/lib/env.py@@ -103,10 +103,10 @@ def _truthy(value: Any) -> bool:def _project_config_trusted(policy: ConfigLoadPolicy, file_env: dict[str, Any]) -> bool:if policy.allow_project_config:return True- return _truthy(- os.environ.get("LAST30DAYS_TRUST_PROJECT_CONFIG")- or file_env.get("LAST30DAYS_TRUST_PROJECT_CONFIG")- )+ process_value = os.environ.get("LAST30DAYS_TRUST_PROJECT_CONFIG")+ if process_value is not None:+ return _truthy(process_value)+ return _truthy(file_env.get("LAST30DAYS_TRUST_PROJECT_CONFIG"))def _check_file_permissions(path: Path) -> None:@@ -658,9 +658,11 @@ def get_x_source_with_method(config: dict[str, Any]) -> tuple[str | None, str]:return None, "none"-def config_exists() -> bool:+def config_exists(policy: ConfigLoadPolicy | None = None) -> bool:"""Check if any configuration source exists."""- if _find_project_env():+ policy = policy or ConfigLoadPolicy()+ file_env = load_env_file(CONFIG_FILE) if CONFIG_FILE and CONFIG_FILE.exists() else {}+ if _project_config_trusted(policy, file_env) and _find_project_env():return Trueif CONFIG_FILE:return CONFIG_FILE.exists()diff --git a/skills/last30days/scripts/lib/pipeline.py b/skills/last30days/scripts/lib/pipeline.pyindex 504eb04e..4d08f3d5 100644--- a/skills/last30days/scripts/lib/pipeline.py+++ b/skills/last30days/scripts/lib/pipeline.py@@ -204,8 +204,15 @@ def diagnose("reads_values": False if safe else config.get("_BROWSER_COOKIE_MODE") == "read",}ignored_project_keys = list(config.get("_IGNORED_PROJECT_CONFIG_KEYS") or [])+ endpoint_override_keys = {+ "BSKY_SEARCH_HOST",+ "LAST30DAYS_SEARXNG_URL",+ "OPENAI_BASE_URL",+ "XAI_BASE_URL",+ "XIAOHONGSHU_API_BASE",+ }ignored_endpoint_overrides = [- key for key in ignored_project_keys if key in {"OPENAI_BASE_URL", "XAI_BASE_URL"}+ key for key in ignored_project_keys if key in endpoint_override_keys]local_writes: list[dict[str, str]] = []if config.get("LAST30DAYS_MEMORY_DIR"):diff --git a/tests/test_project_config_trust.py b/tests/test_project_config_trust.pyindex 3e6157a5..8f5f8bc9 100644--- a/tests/test_project_config_trust.py+++ b/tests/test_project_config_trust.py@@ -49,6 +49,25 @@ def test_project_config_loads_with_global_trust_signal(tmp_path, monkeypatch):assert cfg["_CONFIG_SOURCE"].startswith(f"project:{project_env}")+def test_empty_process_trust_signal_overrides_global_trust_signal(tmp_path, monkeypatch):+ global_env = tmp_path / "global.env"+ global_env.write_text("LAST30DAYS_TRUST_PROJECT_CONFIG=1\n", encoding="utf-8")+ project_dir = tmp_path / "project"+ project_env = project_dir / ".claude" / "last30days.env"+ project_env.parent.mkdir(parents=True)+ project_env.write_text("XAI_API_KEY=xai-project\n", encoding="utf-8")+ monkeypatch.chdir(project_dir)+ monkeypatch.setattr(env, "CONFIG_FILE", global_env)+ monkeypatch.setenv("LAST30DAYS_TRUST_PROJECT_CONFIG", "")++ keychain, pass_store = _neutral_secret_sources()+ with keychain, pass_store:+ cfg = env.get_config()++ assert cfg["XAI_API_KEY"] is None+ assert cfg["_CONFIG_SOURCE"].startswith(f"global:{global_env}")++def test_project_config_discovery_stops_at_git_root(tmp_path, monkeypatch):outside_env = tmp_path / ".claude" / "last30days.env"outside_env.parent.mkdir()@@ -88,11 +107,46 @@ def test_global_config_loads_when_project_config_is_untrusted(tmp_path, monkeypaassert cfg["_CONFIG_SOURCE"].startswith(f"global:{global_env}")+def test_config_exists_ignores_untrusted_project_config(tmp_path, monkeypatch):+ project_env = tmp_path / ".claude" / "last30days.env"+ project_env.parent.mkdir()+ project_env.write_text("XAI_API_KEY=xai-project\n", encoding="utf-8")+ monkeypatch.chdir(tmp_path)+ monkeypatch.setattr(env, "CONFIG_FILE", None)+ monkeypatch.delenv("LAST30DAYS_TRUST_PROJECT_CONFIG", raising=False)++ assert env.config_exists() is False+++def test_config_exists_reports_trusted_project_config(tmp_path, monkeypatch):+ project_env = tmp_path / ".claude" / "last30days.env"+ project_env.parent.mkdir()+ project_env.write_text("XAI_API_KEY=xai-project\n", encoding="utf-8")+ monkeypatch.chdir(tmp_path)+ monkeypatch.setattr(env, "CONFIG_FILE", None)+ monkeypatch.setenv("LAST30DAYS_TRUST_PROJECT_CONFIG", "1")++ assert env.config_exists() is True+++def test_config_exists_reports_global_config(tmp_path, monkeypatch):+ global_env = tmp_path / "global.env"+ global_env.write_text("XAI_API_KEY=xai-global\n", encoding="utf-8")+ monkeypatch.setattr(env, "CONFIG_FILE", global_env)+ monkeypatch.delenv("LAST30DAYS_TRUST_PROJECT_CONFIG", raising=False)++ assert env.config_exists() is True++def test_diagnose_reports_ignored_untrusted_endpoint_override(tmp_path, monkeypatch):project_env = tmp_path / ".claude" / "last30days.env"project_env.parent.mkdir()project_env.write_text(- "OPENAI_BASE_URL=https://attacker.example\nOPENAI_API_KEY=sk-not-reported\n",+ "BSKY_SEARCH_HOST=https://bsky-attacker.example\n"+ "LAST30DAYS_SEARXNG_URL=https://searxng-attacker.example\n"+ "OPENAI_BASE_URL=https://attacker.example\n"+ "OPENAI_API_KEY=sk-not-reported\n"+ "XIAOHONGSHU_API_BASE=https://xhs-attacker.example\n",encoding="utf-8",)monkeypatch.chdir(tmp_path)@@ -110,5 +164,10 @@ def test_diagnose_reports_ignored_untrusted_endpoint_override(tmp_path, monkeypaassert cfg["OPENAI_API_KEY"] == "sk-global"assert cfg["OPENAI_BASE_URL"] is Noneassert diag["ignored_project_config"] == str(project_env)- assert diag["ignored_endpoint_overrides"] == ["OPENAI_BASE_URL"]+ assert diag["ignored_endpoint_overrides"] == [+ "BSKY_SEARCH_HOST",+ "LAST30DAYS_SEARXNG_URL",+ "OPENAI_BASE_URL",+ "XIAOHONGSHU_API_BASE",+ ]assert "sk-not-reported" not in str(diag)