From 8ea207b3481d748971725b3833785cf5e48555e9 Mon Sep 17 00:00:00 2001 From: Dinakar Sarbada Date: Wed, 6 May 2026 16:37:56 -0700 Subject: [PATCH] fix: skip POSIX secret warning on Windows --- skills/last30days/scripts/lib/env.py | 4 ++++ tests/test_env_v3.py | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/skills/last30days/scripts/lib/env.py b/skills/last30days/scripts/lib/env.py index 58751a4..c7abc81 100644 --- a/skills/last30days/scripts/lib/env.py +++ b/skills/last30days/scripts/lib/env.py @@ -70,6 +70,10 @@ class OpenAIAuth: def _check_file_permissions(path: Path) -> None: """Warn to stderr if a secrets file has overly permissive permissions.""" + if os.name == "nt": + # Windows reports synthesized POSIX mode bits that do not reflect NTFS ACLs. + return + try: mode = path.stat().st_mode # Check if group or other can read (bits 0o044) diff --git a/tests/test_env_v3.py b/tests/test_env_v3.py index a79ec69..811e3f8 100644 --- a/tests/test_env_v3.py +++ b/tests/test_env_v3.py @@ -41,6 +41,14 @@ class EnvV3Tests(unittest.TestCase): with mock.patch.dict(os.environ, {}, clear=False): self.assertIsNone(bird_x.is_bird_authenticated()) + def test_file_permission_check_skips_windows_posix_mode_bits(self): + path = mock.Mock(spec=Path) + with mock.patch.object(env.os, "name", "nt"), mock.patch.object(env.sys.stderr, "write") as write: + env._check_file_permissions(path) + + path.stat.assert_not_called() + write.assert_not_called() + if __name__ == "__main__": unittest.main()