mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 03:01:21 +02:00
Suppress Bandit false positives in virtual printer and tests
B108: /tmp paths in test mocks (not real filesystem access). B104: string comparisons against "0.0.0.0" (not socket binds).
This commit is contained in:
@@ -276,7 +276,7 @@ class FTPSession:
|
||||
sockname = self.writer.get_extra_info("sockname")
|
||||
ip = sockname[0] if sockname else "127.0.0.1"
|
||||
# 0.0.0.0 is not routable — fall back to control connection IP
|
||||
if ip == "0.0.0.0":
|
||||
if ip == "0.0.0.0": # nosec B104
|
||||
ip = "127.0.0.1"
|
||||
|
||||
# Format IP and port for PASV response
|
||||
|
||||
@@ -390,8 +390,8 @@ class FTPTLSProxy(TLSProxy):
|
||||
|
||||
# Determine our local IP from the control connection socket
|
||||
sockname = client_writer.get_extra_info("sockname")
|
||||
local_ip = sockname[0] if sockname else "0.0.0.0"
|
||||
if local_ip in ("0.0.0.0", "::"):
|
||||
local_ip = sockname[0] if sockname else "0.0.0.0" # nosec B104
|
||||
if local_ip in ("0.0.0.0", "::"): # nosec B104
|
||||
local_ip = "127.0.0.1"
|
||||
|
||||
# Connect to target printer with TLS
|
||||
|
||||
@@ -926,7 +926,7 @@ class TestVirtualPrinterManagerServerModeIPOverride:
|
||||
patch.object(
|
||||
manager._cert_service,
|
||||
"generate_certificates",
|
||||
return_value=(Path("/tmp/cert.pem"), Path("/tmp/key.pem")),
|
||||
return_value=(Path("/tmp/cert.pem"), Path("/tmp/key.pem")), # nosec B108
|
||||
),
|
||||
):
|
||||
mock_ssdp_cls.return_value.start = AsyncMock()
|
||||
@@ -955,7 +955,7 @@ class TestVirtualPrinterManagerServerModeIPOverride:
|
||||
patch.object(
|
||||
manager._cert_service,
|
||||
"generate_certificates",
|
||||
return_value=(Path("/tmp/cert.pem"), Path("/tmp/key.pem")),
|
||||
return_value=(Path("/tmp/cert.pem"), Path("/tmp/key.pem")), # nosec B108
|
||||
) as mock_gen_certs,
|
||||
):
|
||||
await manager._start_server_mode()
|
||||
@@ -978,7 +978,7 @@ class TestVirtualPrinterManagerServerModeIPOverride:
|
||||
patch.object(
|
||||
manager._cert_service,
|
||||
"generate_certificates",
|
||||
return_value=(Path("/tmp/cert.pem"), Path("/tmp/key.pem")),
|
||||
return_value=(Path("/tmp/cert.pem"), Path("/tmp/key.pem")), # nosec B108
|
||||
) as mock_gen_certs,
|
||||
):
|
||||
await manager._start_server_mode()
|
||||
|
||||
Reference in New Issue
Block a user