Merge pull request #357 from dinakars777/fix/windows-env-permission-warning
fix: skip POSIX secret warning on Windows
This commit is contained in:
@@ -70,6 +70,10 @@ class OpenAIAuth:
|
|||||||
|
|
||||||
def _check_file_permissions(path: Path) -> None:
|
def _check_file_permissions(path: Path) -> None:
|
||||||
"""Warn to stderr if a secrets file has overly permissive permissions."""
|
"""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:
|
try:
|
||||||
mode = path.stat().st_mode
|
mode = path.stat().st_mode
|
||||||
# Check if group or other can read (bits 0o044)
|
# Check if group or other can read (bits 0o044)
|
||||||
|
|||||||
@@ -41,6 +41,14 @@ class EnvV3Tests(unittest.TestCase):
|
|||||||
with mock.patch.dict(os.environ, {}, clear=False):
|
with mock.patch.dict(os.environ, {}, clear=False):
|
||||||
self.assertIsNone(bird_x.is_bird_authenticated())
|
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()
|
||||||
|
|
||||||
|
|
||||||
class ThreadsAvailabilityTests(unittest.TestCase):
|
class ThreadsAvailabilityTests(unittest.TestCase):
|
||||||
"""Threads is in the SC default-on family: same key, same per-call cost
|
"""Threads is in the SC default-on family: same key, same per-call cost
|
||||||
|
|||||||
Reference in New Issue
Block a user