fix(dlp-scanner): a call site that already names its arguments should say so in the signature

ruff 0.16.0 stabilized PLR0917 (too-many-positional-arguments) out of
preview. The project selects PL wholesale and CI installs ruff unpinned,
so the rule switched on by itself and four signatures went red without a
line of source changing.

Every flagged call site already passed the tail arguments by keyword, so
the signatures were understating a contract the code had already adopted.
Mark that tail keyword-only:

  DetectorRegistry.__init__   - six optional config knobs, all keyword
  _append_findings            - matches/text positional, context keyword
  _process_dns_packet         - packet data positional, context keyword
  _make_packet (test helper)  - eight defaulted fields, all keyword

_process_dns_packet was the only caller passing positionally; it now
names path/packet_num/dns_detector/result like every sibling call does.

313 tests pass, ruff clean on both 0.15.7 and 0.16.1, mypy unchanged at
its three pre-existing errors.
This commit is contained in:
CarterPerez-dev 2026-07-31 19:09:36 -04:00
parent 8d273f2694
commit 79851054fd
4 changed files with 8 additions and 4 deletions

View File

@ -39,6 +39,7 @@ class DetectorRegistry:
"""
def __init__(
self,
*,
enable_patterns: list[str] | None = None,
disable_patterns: list[str] | None = None,
allowlist_values: frozenset[str] | None = None,

View File

@ -475,6 +475,7 @@ class DatabaseScanner:
self,
matches: list[DetectorMatch],
text: str,
*,
table_name: str,
uri: str,
result: ScanResult,

View File

@ -137,10 +137,10 @@ class NetworkScanner:
packet.payload,
packet.src_ip,
packet.dst_ip,
path,
packet_count,
dns_detector,
result,
path = path,
packet_num = packet_count,
dns_detector = dns_detector,
result = result,
)
if packet.payload:
@ -175,6 +175,7 @@ class NetworkScanner:
payload: bytes,
src_ip: str,
dst_ip: str,
*,
path: Path,
packet_num: int,
dns_detector: DnsExfilDetector,

View File

@ -12,6 +12,7 @@ from dlp_scanner.network.pcap import PacketInfo
def _make_packet(
*,
src_ip: str = "192.168.1.1",
dst_ip: str = "10.0.0.1",
src_port: int = 12345,