refactor(util): move is_ipv4_literal out of pipelock.py into util.py
test / run tests/run_tests.py (pull_request) Successful in 25s
test / run tests/run_tests.py (pull_request) Successful in 25s
The classifier is a pure dotted-quad regex check — nothing pipelock-specific about it. Pipelock now imports it from util. test_pipelock_classify.py retargets at the new location. Two manifest-accessor functions in pipelock.py (pipelock_bottle_allowlist, pipelock_bottle_ssh_hostnames) look generic but are 1-line wrappers used only internally; they stay for now.
This commit is contained in:
@@ -6,6 +6,7 @@ claude_bottle/backend/docker/util.py."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
def expand_tilde(path: str) -> str:
|
||||
@@ -16,3 +17,15 @@ def expand_tilde(path: str) -> str:
|
||||
home = os.environ.get("HOME", "")
|
||||
return home + path[1:]
|
||||
return path
|
||||
|
||||
|
||||
_IPV4_RE = re.compile(r"^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$")
|
||||
|
||||
|
||||
def is_ipv4_literal(s: str) -> bool:
|
||||
"""True iff `s` looks like a dotted-quad IPv4 literal. Does not
|
||||
validate octet ranges; consumers that care about that should run
|
||||
a stricter check. Empty input returns False."""
|
||||
if not s:
|
||||
return False
|
||||
return bool(_IPV4_RE.match(s))
|
||||
|
||||
Reference in New Issue
Block a user