S108: ignore our uses

This commit is contained in:
Jörg Thalheim
2025-08-20 16:06:56 +02:00
parent 136acc7901
commit 0a70ed6268
5 changed files with 6 additions and 6 deletions

View File

@@ -176,7 +176,7 @@ class ClanFlake:
self.temporary_home = temporary_home self.temporary_home = temporary_home
self.path = temporary_home / "flake" self.path = temporary_home / "flake"
if not suppress_tmp_home_warning: if not suppress_tmp_home_warning:
if "/tmp" not in str(os.environ.get("HOME")): if "/tmp" not in str(os.environ.get("HOME")): # noqa: S108 - Checking if HOME is in temp directory
log.warning( log.warning(
f"!! $HOME does not point to a temp directory!! HOME={os.environ['HOME']}", f"!! $HOME does not point to a temp directory!! HOME={os.environ['HOME']}",
) )
@@ -368,7 +368,7 @@ def create_flake(
check=True, check=True,
) )
if "/tmp" not in str(os.environ.get("HOME")): if "/tmp" not in str(os.environ.get("HOME")): # noqa: S108 - Checking if HOME is in temp directory
log.warning( log.warning(
f"!! $HOME does not point to a temp directory!! HOME={os.environ['HOME']}", f"!! $HOME does not point to a temp directory!! HOME={os.environ['HOME']}",
) )

View File

@@ -14,7 +14,7 @@ TEMPDIR = None
# macOS' default temporary directory is too long for unix sockets # macOS' default temporary directory is too long for unix sockets
# This can break applications such as gpg-agent # This can break applications such as gpg-agent
if platform == "darwin": if platform == "darwin":
TEMPDIR = Path("/tmp") TEMPDIR = Path("/tmp") # noqa: S108 - Required on macOS due to socket path length limits
@pytest.fixture @pytest.fixture

View File

@@ -13,7 +13,7 @@ def test_get_clan_details_invalid_flake() -> None:
get_clan_details(invalid_flake) get_clan_details(invalid_flake)
with pytest.raises(FlakeInvalidError): with pytest.raises(FlakeInvalidError):
get_clan_details(Flake("/tmp")) get_clan_details(Flake("/tmp")) # noqa: S108
@pytest.mark.with_core @pytest.mark.with_core

View File

@@ -139,7 +139,7 @@ class Remote:
if sys.platform == "darwin" and os.environ.get("TMPDIR", "").startswith( if sys.platform == "darwin" and os.environ.get("TMPDIR", "").startswith(
"/var/folders/", "/var/folders/",
): ):
directory = "/tmp/" directory = "/tmp/" # noqa: S108 - Required on macOS due to bugs with default TMPDIR
with TemporaryDirectory(prefix="clan-ssh", dir=directory) as temp_dir: with TemporaryDirectory(prefix="clan-ssh", dir=directory) as temp_dir:
remote = Remote( remote = Remote(
address=self.address, address=self.address,

View File

@@ -33,7 +33,7 @@ def upload(
# Exceptions: Allow depth 2 if the path starts with /tmp/, /root/, or /etc/. # Exceptions: Allow depth 2 if the path starts with /tmp/, /root/, or /etc/.
# This allows destinations like /tmp/mydir or /etc/conf.d, but not /tmp or /etc directly. # This allows destinations like /tmp/mydir or /etc/conf.d, but not /tmp or /etc directly.
is_allowed_exception = depth >= 2 and ( is_allowed_exception = depth >= 2 and (
str(remote_dest).startswith("/tmp/") str(remote_dest).startswith("/tmp/") # noqa: S108 - Path validation check
or str(remote_dest).startswith("/root/") or str(remote_dest).startswith("/root/")
or str(remote_dest).startswith("/etc/") or str(remote_dest).startswith("/etc/")
) )