Repository navigation
ci: publish on merge to stable (publishing policy 1.9.0), version 1.0.10 - #17
Conversation
- pyproject: PEP 621 [project] (poetry-core 2 builds it; uv and release-workflows read it), dev group pytest + ruff 0.15.10, ruff baseline (line length 119, structural legacy rules ignored with a note). uv.lock replaces poetry.lock. - publish.yml (release-workflows v1.5.0): release-check -> tests -> build -> PyPI by trusted publishing in the `release` environment -> v<version> tag and GitHub release by the release App. - tests.yml (shared python-tests) + a smoke test (import, --help), the first tests. - stable-guard.yml, dev-security.yml, CODEOWNERS (both lead teams, policy 1.9.0 D15), Dependabot (uv + actions into dev, cooldown), .gitignore.
Safe fixes (unused imports, f-strings without placeholders, `not in`, unused `as e`) plus three dead assignments (literal values never read). The side-effect import `import lib.logger` in cli.py stays (it sets up the log handlers); ruff removed it as unused, so it is restored with a noqa comment.
en0f
left a comment
There was a problem hiding this comment.
Reviewed at 8067a26.
🔴 dependency-review fails: uv.lock pins pytest 8.4.2 (GHSA-6w46-j5rx-g56g) for Python 3.9
The only red check is dev-security / dependency-review. It flags uv.lock » [email protected] – pytest has vulnerable tmpdir handling (moderate severity). 8.4.2 is locked only for python_full_version < '3.10', because requires-python = ">=3.9". The fixed release, 9.0.3, needs Python >=3.10, so while 3.9 is in range every lock of the dev group keeps a vulnerable pytest. Dependency review reports only what a pull request changes, so this is the one pull request that will flag it. dev has no ruleset yet, so a red merge would put the pin on dev, and nothing would report it again.
Fix: set requires-python = ">=3.10" (toolchain.md's floor is 3.10) and run uv lock. pytest 8.4.2, pluggy 1.6.0 and sh 2.3.0 drop out, and uv lock --check and ruff stay clean. Python 3.9 users keep 1.0.9.
🔴 ruff --fix broke the error logging in socks.py's four except handlers
The style commit turned except Exception as e: into except Exception: at socks.py:51, 101, 142 and 224, but each handler still logs {e}, which is assigned only under if log.level <= logging.DEBUG. F841 took the read for the later assignment. Under the CLI's logging, or with none configured, the socks logger stays NOTSET and nothing changes. Set it to INFO or higher and the greeting, request and reply handlers raise UnboundLocalError instead of logging, and exchange_loop logs select's leftover list (Error in data exchange: []) where the base logged [Errno 32] Broken pipe.
Fix, in all four handlers (restoring as e alone trips F841 again):
except Exception as e:
log.error(f"Error in greeting: {traceback.format_exc() if log.level <= logging.DEBUG else e}")This matches the base in every logging setup (V05, V06, V10, V11), and ruff 0.15.10 is clean.
🟢 The poetry → PEP 621 move keeps the package shippable
uv build gives the 1.0.10 wheel and sdist. The wheel holds trevorproxy/cli.py and trevorproxy/lib/*, the trevorproxy = trevorproxy.cli:main script, and Requires-Dist: sh. uv.lock matches pyproject.toml, every uses: is a SHA pin with its tag, and the four new workflows pin release-workflows at the v1.5.0 commit.
Reproduce this review
# save the script below as verify-17.sh and the patch as control-17.patch, then:
bash verify-17.sh blacklanternsecurity/TREVORproxy 8067a262497ae8c9c64bb049e35309b7ebcd2dcf
# expected: SUMMARY 7 PASS, 5 FAIL, 0 SKIP, 0 BROKEN
# V09 FAIL is repository history since v1.0.9, not this diff
# control: bash verify-17.sh blacklanternsecurity/TREVORproxy 8067a262497ae8c9c64bb049e35309b7ebcd2dcf control-17.patch -> V01 V02 V05 V11 PASS#!/usr/bin/env bash
# verify-17.sh: reproducible checks for blacklanternsecurity/TREVORproxy#17
# Usage: bash verify-17.sh <owner/repo> <sha> [<control-patch>]
# Changes nothing outside a mktemp directory and nothing on GitHub (PR-VF-02).
# GitHub reads are GET-only (gh api defaults to GET with no fields); OSV and PyPI reads are anonymous.
#
# CONTROL: patch control-17.patch
# CONTROL-EXPECT: V01=PASS V02=PASS V05=PASS V11=PASS
set -uo pipefail
REPO="${1:?owner/repo}"; SHA="${2:?sha}"; PATCH="${3:-}"
PASS=0; FAIL=0; SKIP=0; BROKEN=0
pass() { echo "PASS $1 $2"; PASS=$((PASS+1)); }
fail() { echo "FAIL $1 $2 -- $3"; FAIL=$((FAIL+1)); }
skip() { echo "SKIP $1 $2 -- $3"; SKIP=$((SKIP+1)); }
broken() { echo "BROKEN $1 $2 -- $3"; BROKEN=$((BROKEN+1)); }
summary() { echo "SUMMARY $PASS PASS, $FAIL FAIL, $SKIP SKIP, $BROKEN BROKEN"; [ "$FAIL" -eq 0 ] && [ "$BROKEN" -eq 0 ]; }
echo "script_sha256 $(shasum -a 256 "$0" | cut -d' ' -f1)"
echo "git $(git --version | cut -d' ' -f3)"
echo "python $(python3 -c 'import platform; print(platform.python_version())')"
WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT
case "$PATCH" in ""|/*) ;; *) PATCH="$PWD/$PATCH" ;; esac
export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 GIT_TERMINAL_PROMPT=0
GIT=(git -c credential.helper= -c 'credential.helper=!gh auth git-credential')
"${GIT[@]}" clone --quiet --filter=blob:none --no-checkout "https://github.com/$REPO.git" "$WORK/src" || { broken V00 "clone" "clone failed"; summary; exit 1; }
cd "$WORK/src"
"${GIT[@]}" cat-file -e "$SHA^{commit}" 2>/dev/null || "${GIT[@]}" fetch --quiet origin "+refs/pull/*/head:refs/remotes/pr/*" || true
"${GIT[@]}" checkout --quiet --detach "$SHA" || { broken V00 "checkout $SHA" "checkout failed"; summary; exit 1; }
[ "$(git rev-parse HEAD)" = "$SHA" ] || { broken V00 "HEAD is $SHA" "HEAD mismatch"; summary; exit 1; }
if [ -n "$PATCH" ]; then git apply "$PATCH" || { broken V00 "apply control patch" "git apply failed"; summary; exit 1; }; fi
# ---- pinned uv 0.11.20 (checksum-verified, with a wrong-hash control) ----
UV_VERSION=0.11.20
case "$(uname -s)-$(uname -m)" in
Darwin-x86_64) UV_ASSET=uv-x86_64-apple-darwin; UV_SHA=bef01a86faab997f6022b45cfa29bfc5b090f2f72cd4a91d2ecefe641efdabe7 ;;
Darwin-arm64) UV_ASSET=uv-aarch64-apple-darwin; UV_SHA=0a2b6a757d5693671a7ce0002554ae869604e1e69acb10313ac14d08374be01a ;;
Linux-x86_64) UV_ASSET=uv-x86_64-unknown-linux-gnu; UV_SHA=5de211d9278af365497d387e25316907b3b4a9f25b4476dd6dbf238d6f85cff3 ;;
Linux-aarch64) UV_ASSET=uv-aarch64-unknown-linux-gnu; UV_SHA=c8b5b7f9c804b640da0bb66cddddf0a00ce971f64d8076622d70bd141bc80857 ;;
*) UV_ASSET="" ;;
esac
UV=""
if [ -n "$UV_ASSET" ] && curl -fsSLo "$WORK/uv.tgz" "https://github.com/astral-sh/uv/releases/download/$UV_VERSION/$UV_ASSET.tar.gz"; then
if echo "$UV_SHA $WORK/uv.tgz" | shasum -a 256 -c - >/dev/null 2>&1; then
if echo "0000000000000000000000000000000000000000000000000000000000000000 $WORK/uv.tgz" | shasum -a 256 -c - >/dev/null 2>&1; then broken V90 "uv wrong-hash control fails" "accepted a wrong hash"; else pass V90 "uv $UV_VERSION checksum matches; wrong-hash control fails"; fi
mkdir -p "$WORK/uvbin" && tar -xzf "$WORK/uv.tgz" -C "$WORK/uvbin" --strip-components 1 && UV="$WORK/uvbin/uv"
else broken V90 "uv checksum matches" "mismatch"; fi
fi
# uv's cache and config stay in $WORK, set per call (exporting XDG_CONFIG_HOME would hide gh's login)
uvc() { UV_CACHE_DIR="$WORK/uv/cache" UV_NO_CONFIG=1 UV_PYTHON_INSTALL_DIR="$WORK/uv/python" UV_TOOL_DIR="$WORK/uv/tools" XDG_CONFIG_HOME="$WORK/uv/config" "$UV" "$@"; }
# ---- checks: each line states the desired property --------------------------
# V01: uv.lock locks no package inside GHSA-6w46-j5rx-g56g's affected range (the advisory dependency review fails on)
curl -fsS -o "$WORK/osv.json" "https://api.osv.dev/v1/vulns/GHSA-6w46-j5rx-g56g" 2>/dev/null || true
R01=$(python3 - "$WORK/osv.json" uv.lock <<'PY'
import json, sys, tomllib
try:
adv = json.load(open(sys.argv[1]))
except Exception as e:
print(f"ERR osv {e}"); sys.exit()
def key(v):
return tuple(int(x) for x in v.split(".")[:3])
ranges = []
for a in adv.get("affected", []):
if a["package"]["name"].lower() != "pytest": continue
for r in a.get("ranges", []):
intro = fixed = None
for ev in r.get("events", []):
intro = ev.get("introduced", intro); fixed = ev.get("fixed", fixed)
ranges.append((intro, fixed))
if not ranges:
print("ERR no pytest range in advisory"); sys.exit()
lock = tomllib.load(open(sys.argv[2], "rb"))
hit = []
for p in lock.get("package", []):
if p["name"] != "pytest": continue
for intro, fixed in ranges:
lo = key(intro) if intro and intro != "0" else (0, 0, 0)
if key(p["version"]) >= lo and (fixed is None or key(p["version"]) < key(fixed)):
hit.append(f"pytest {p['version']} (fixed {fixed})")
print("ok" if not hit else "BAD " + "; ".join(hit))
PY
)
case "$R01" in
ok) pass V01 "uv.lock locks no pytest inside GHSA-6w46-j5rx-g56g's range" ;;
ERR*) skip V01 "uv.lock locks no pytest inside GHSA-6w46-j5rx-g56g's range" "$R01" ;;
*) fail V01 "uv.lock locks no pytest inside GHSA-6w46-j5rx-g56g's range" "$R01" ;;
esac
# V02: requires-python starts at 3.10, the org toolchain's floor (standards/toolchain.md: 3.10 through 3.14),
# and no patched pytest (>=9.0.3) installs on 3.9, so a 3.9 floor always locks a vulnerable pytest
RP=$(python3 -c 'import tomllib;print(tomllib.load(open("pyproject.toml","rb"))["project"].get("requires-python",""))')
PYTEST_RP=$(curl -fsS "https://pypi.org/pypi/pytest/9.0.3/json" 2>/dev/null | python3 -c 'import json,sys;print(json.load(sys.stdin)["info"]["requires_python"])' 2>/dev/null || echo "?")
if [ "$RP" = ">=3.10" ]; then pass V02 "requires-python is >=3.10 (pytest 9.0.3 requires $PYTEST_RP)"
else fail V02 "requires-python is >=3.10 (pytest 9.0.3 requires $PYTEST_RP)" "requires-python = '$RP'"; fi
# V03: uv.lock matches pyproject.toml
if [ -z "$UV" ]; then skip V03 "uv lock --check passes" "no pinned uv"
else OUT=$(uvc lock --check 2>&1); RC=$?
if [ "$RC" -eq 0 ]; then pass V03 "uv lock --check passes (uv.lock matches pyproject.toml)"; else fail V03 "uv lock --check passes" "$(echo "$OUT" | tail -2 | tr '\n' ' ' | cut -c1-200)"; fi
fi
# V04: ruff (the pyproject pin, 0.15.10) reports a clean check and format
if [ -z "$UV" ]; then skip V04 "ruff 0.15.10 check and format --check are clean" "no pinned uv"
else O1=$(uvc tool run [email protected] check 2>&1); R1=$?; O2=$(uvc tool run [email protected] format --check 2>&1); R2=$?
if [ "$R1" -eq 0 ] && [ "$R2" -eq 0 ]; then pass V04 "ruff 0.15.10 check and format --check are clean"
else fail V04 "ruff 0.15.10 check and format --check are clean" "$(echo "$O1 $O2" | tail -3 | tr '\n' ' ' | cut -c1-200)"; fi
fi
# Socks handler probe: drive SocksProxy.handle() with a bad SOCKS greeting (version 4) over a fake connection.
cat > "$WORK/socks_probe.py" <<'PY'
import sys, logging, types
sys.path.insert(0, sys.argv[1]); sys.dont_write_bytecode = True
from trevorproxy.lib import socks
mode = sys.argv[2]
records = []
class H(logging.Handler):
def emit(self, r): records.append(r.getMessage())
lg = logging.getLogger("trevorproxy.socks"); lg.addHandler(H()); lg.propagate = False
# as the CLI does: trevorproxy/lib/logger.py:20 sets the "trevorproxy" logger to DEBUG (its file handlers are left out)
logging.getLogger("trevorproxy").setLevel(logging.DEBUG)
if mode == "info":
lg.setLevel(logging.INFO) # a caller that turns socks logging down to INFO
class Conn:
def __init__(self, data): self.data = data
def recv(self, n):
out, self.data = self.data[:n], self.data[n:]; return out
h = object.__new__(socks.SocksProxy)
h.connection = Conn(b"\x04\x01"); h.client_address = ("192.0.2.1", 1234)
try:
h.handle()
except Exception as e:
print(f"RAISED {type(e).__name__}: {e}"); sys.exit()
msg = [m for m in records if m.startswith("Error in greeting")]
if not msg: print("NOLOG " + repr(records)); sys.exit()
print(("TB " if "Traceback" in msg[0] else "MSG ") + msg[0].splitlines()[0][:120])
PY
# V05: with the socks logger at INFO, a bad greeting is logged, not turned into UnboundLocalError
R05=$(python3 "$WORK/socks_probe.py" "$WORK/src" info 2>&1 | tail -1)
case "$R05" in
MSG\ Error\ in\ greeting:\ Only\ SOCKS\ version\ 5*) pass V05 "socks logger at INFO: bad greeting logged as '${R05#MSG }'" ;;
*) fail V05 "socks logger at INFO: bad greeting is logged, not raised" "$R05" ;;
esac
# V06: with the logging the CLI sets up ("trevorproxy" at DEBUG, socks logger NOTSET), a bad greeting still logs the traceback
R06=$(python3 "$WORK/socks_probe.py" "$WORK/src" default 2>&1 | tail -1)
case "$R06" in
TB\ Error\ in\ greeting:*) pass V06 "default logging: bad greeting logs the traceback (unchanged)" ;;
*) fail V06 "default logging: bad greeting logs the traceback" "$R06" ;;
esac
# V07: the build ships the package, lib/ and the console script
if [ -z "$UV" ]; then skip V07 "uv build ships trevorproxy, trevorproxy/lib and the trevorproxy script" "no pinned uv"
else OUT=$(uvc build --out-dir "$WORK/dist" 2>&1); RC=$?
R07=$(python3 - "$WORK/dist" <<'PY'
import sys, glob, zipfile
w = glob.glob(sys.argv[1] + "/*.whl"); s = glob.glob(sys.argv[1] + "/*.tar.gz")
if len(w) != 1 or len(s) != 1: print(f"BAD wheels={w} sdists={s}"); sys.exit()
z = zipfile.ZipFile(w[0]); names = z.namelist()
need = ["trevorproxy/cli.py", "trevorproxy/lib/socks.py", "trevorproxy/lib/ssh.py", "trevorproxy/lib/logger.py"]
miss = [n for n in need if n not in names]
ep = [n for n in names if n.endswith("entry_points.txt")]
meta = [n for n in names if n.endswith("METADATA")]
eps = z.read(ep[0]).decode() if ep else ""
md = z.read(meta[0]).decode() if meta else ""
probs = miss[:]
if "trevorproxy=trevorproxy.cli:main" not in eps.replace(" ", ""): probs.append("no console script")
if "Version: 1.0.10" not in md: probs.append("version")
if "Requires-Dist: sh" not in md: probs.append("no sh dependency")
print("ok " + w[0].rsplit("/", 1)[-1] if not probs else "BAD " + ",".join(probs))
PY
)
if [ "$RC" -eq 0 ] && [ "${R07%% *}" = ok ]; then pass V07 "uv build ships trevorproxy, trevorproxy/lib and the trevorproxy script (${R07#ok })"
else fail V07 "uv build ships trevorproxy, trevorproxy/lib and the trevorproxy script" "rc=$RC $R07 $(echo "$OUT" | tail -1 | cut -c1-120)"; fi
fi
# V08: every uses: in the workflows is a 40-character SHA with a version comment, and the
# release-workflows pin is the v1.5.0 tag's commit
BAD=$(cat .github/workflows/*.yml | /usr/bin/grep -E '^[[:space:]-]*uses:' | /usr/bin/grep -vE 'uses: \./' | /usr/bin/grep -vE '@[0-9a-f]{40} # v[0-9]' || true)
RWPINS=$(cat .github/workflows/dev-security.yml .github/workflows/publish.yml .github/workflows/stable-guard.yml .github/workflows/tests.yml | /usr/bin/grep -oE 'release-workflows/[^@]+@[0-9a-f]{40}' | sed 's/.*@//' | sort -u)
TAGSHA=$(gh api repos/blacklanternsecurity/release-workflows/git/ref/tags/v1.5.0 --jq '.object.sha' 2>/dev/null || echo "")
if [ -n "$BAD" ]; then fail V08 "every uses: pinned to a SHA with a version comment" "$(echo "$BAD" | head -2 | tr '\n' ' ')"
elif [ -z "$TAGSHA" ]; then skip V08 "release-workflows pin equals v1.5.0" "tag read failed"
elif [ "$RWPINS" = "$TAGSHA" ]; then pass V08 "every uses: SHA-pinned with a version comment; release-workflows pin $TAGSHA is v1.5.0"
else fail V08 "release-workflows pin equals v1.5.0 ($TAGSHA)" "pins: $(echo $RWPINS)"; fi
# V09: every first-parent commit since v1.0.9 on master (the branch to be renamed stable) arrived through a merged
# pull request, which release-workflows provenance.py requires before the first release
MT=$(gh api repos/blacklanternsecurity/TREVORproxy/compare/v1.0.9...master --jq '[.commits[] | select((.parents|length)==1) | .sha] | .[]' 2>/dev/null || echo "ERR")
if [ "$MT" = ERR ] || [ -z "$MT" ]; then skip V09 "commits since v1.0.9 arrived through merged PRs" "compare read failed"
else NOPR=""; N=0
# merged-PR commits on the first-parent line are the merges; single-parent commits on it are direct pushes unless a PR lists them
for c in $MT; do N=$((N+1)); P=$(gh api "repos/blacklanternsecurity/TREVORproxy/commits/$c/pulls" --jq '[.[] | select(.merged_at != null)] | length' 2>/dev/null || echo "?")
[ "$P" = 0 ] && NOPR="$NOPR ${c:0:8}"; done
FP=$(git rev-list --first-parent v1.0.9..origin/master 2>/dev/null | wc -l | tr -d ' ')
if [ -z "$NOPR" ]; then pass V09 "all single-parent commits since v1.0.9 on master came through merged PRs"
else fail V09 "all commits since v1.0.9 on master came through merged PRs" "no merged PR:$NOPR ($FP first-parent commits since v1.0.9)"; fi
fi
# ---- checks added to answer the challenge ----
# V10 (C6): with no logging configured (library use: "trevorproxy" and the socks logger NOTSET),
# a bad greeting still logs the traceback, as at the base 4bc8c6a7
R10=$(python3 - "$WORK/src" <<'PY'
import sys, logging
sys.path.insert(0, sys.argv[1]); sys.dont_write_bytecode = True
from trevorproxy.lib import socks
recs = []
class H(logging.Handler):
def emit(self, r): recs.append(r.getMessage())
lg = logging.getLogger("trevorproxy.socks"); lg.addHandler(H()); lg.propagate = False
class Conn:
def __init__(s, d): s.d = d
def recv(s, n):
o, s.d = s.d[:n], s.d[n:]; return o
h = object.__new__(socks.SocksProxy); h.connection = Conn(b"\x04\x01"); h.client_address = ("192.0.2.1", 1)
try:
h.handle()
except Exception as ex:
print(f"RAISED {type(ex).__name__}"); sys.exit()
m = [x for x in recs if x.startswith("Error in greeting")]
print(("TB " if m and "Traceback" in m[0] else "NOTB ") + (m[0].splitlines()[0] if m else repr(recs)))
PY
)
case "$R10" in
TB*) pass V10 "no logging configured: bad greeting logs the traceback (as at base)" ;;
*) fail V10 "no logging configured: bad greeting logs the traceback (as at base)" "$R10" ;;
esac
# V11 (C4): with the socks logger at INFO, a broken pipe in exchange_loop logs the socket error,
# not select()'s leftover list (head reuses `e` from `r, w, e = select.select(...)`)
R11=$(python3 - "$WORK/src" <<'PY'
import sys, logging, socket
sys.path.insert(0, sys.argv[1]); sys.dont_write_bytecode = True
from trevorproxy.lib import socks
recs = []
class H(logging.Handler):
def emit(self, r): recs.append(r.getMessage())
lg = logging.getLogger("trevorproxy.socks"); lg.addHandler(H()); lg.propagate = False; lg.setLevel(logging.INFO)
h = object.__new__(socks.SocksProxy)
c, peer = socket.socketpair(); r, rpeer = socket.socketpair(); peer.send(b"x"); rpeer.close()
try:
h.exchange_loop(c, r)
except Exception as ex:
print(f"RAISED {type(ex).__name__}"); sys.exit()
m = [x for x in recs if x.startswith("Error in data exchange")]
print(m[0] if m else "NOLOG " + repr(recs))
PY
)
case "$R11" in
"Error in data exchange: [Errno"*) pass V11 "socks logger at INFO: exchange_loop logs the socket error ('$R11')" ;;
*) fail V11 "socks logger at INFO: exchange_loop logs the socket error" "$R11" ;;
esac
# ------------------------------------------------------------------------------
summarycontrol-17.patch (both fixes above, with the relocked uv.lock):
diff --git a/pyproject.toml b/pyproject.toml
index e825654..5a568c7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ version = "1.0.10"
description = "Rotate your source IP address via SSH proxies and other methods"
authors = [{ name = "TheTechromancer" }]
license = "AGPL-3.0-or-later"
-requires-python = ">=3.9"
+requires-python = ">=3.10"
dependencies = ["sh>=2.2.1,<3"]
[project.urls]
diff --git a/trevorproxy/lib/socks.py b/trevorproxy/lib/socks.py
index 68d0aea..099d8ef 100644
--- a/trevorproxy/lib/socks.py
+++ b/trevorproxy/lib/socks.py
@@ -48,10 +48,8 @@ class SocksProxy(StreamRequestHandler):
if not self.verify_credentials(methods):
return
- except Exception:
- if log.level <= logging.DEBUG:
- e = traceback.format_exc()
- log.error(f"Error in greeting: {e}")
+ except Exception as e:
+ log.error(f"Error in greeting: {traceback.format_exc() if log.level <= logging.DEBUG else e}")
return
# request
@@ -98,10 +96,8 @@ class SocksProxy(StreamRequestHandler):
log.debug(f"Destination address: {address}")
port = struct.unpack("!H", self.connection.recv(2))[0]
- except Exception:
- if log.level <= logging.DEBUG:
- e = traceback.format_exc()
- log.error(f"Error in request: {e}")
+ except Exception as e:
+ log.error(f"Error in request: {traceback.format_exc() if log.level <= logging.DEBUG else e}")
return
# reply
@@ -139,10 +135,8 @@ class SocksProxy(StreamRequestHandler):
addr, port = bind_address[:2]
reply = struct.pack("!BBBBIH", SOCKS_VERSION, 0, 0, 1, address_type, port)
- except Exception:
- if log.level <= logging.DEBUG:
- e = traceback.format_exc()
- log.error(f"Error in reply: {e}")
+ except Exception as e:
+ log.error(f"Error in reply: {traceback.format_exc() if log.level <= logging.DEBUG else e}")
# return connection refused error
reply = self.generate_failed_reply(address_type, 5)
return
@@ -221,10 +215,8 @@ class SocksProxy(StreamRequestHandler):
data = remote.recv(4096)
if client.send(data) <= 0:
break
- except Exception:
- if log.level <= logging.DEBUG:
- e = traceback.format_exc()
- log.error(f"Error in data exchange: {e}")
+ except Exception as e:
+ log.error(f"Error in data exchange: {traceback.format_exc() if log.level <= logging.DEBUG else e}")
finally:
# Ensure remote socket is properly closed
try:
diff --git a/uv.lock b/uv.lock
index 77d3128..b485619 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1,10 +1,6 @@
version = 1
-revision = 5
-requires-python = ">=3.9"
-resolution-markers = [
- "python_full_version >= '3.10'",
- "python_full_version < '3.10'",
-]
+revision = 3
+requires-python = ">=3.10"
[[package]]
name = "colorama"
@@ -20,80 +16,35 @@ name = "exceptiongroup"
version = "1.3.2"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "typing-extensions" },
+ { name = "typing-extensions", marker = "python_full_version < '3.13'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/85/ac/f882fe3234606340c8729372da0fb98c634b97a560c9d375d9afea21496b/exceptiongroup-1.3.2.tar.gz", hash = "sha256:ca82e69f0cb535fbde934885744b67669a3efddd50fe7bc00d3398839fcaddec", size = 34687, upload-time = "2026-11-19T22:10:16.815Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/a0/7d/0fb19ccdf794c448141461180d5992c50402f69f8515a801bfac7ad65f45/exceptiongroup-1.3.2-py3-none-any.whl", hash = "sha256:41c6a70dfec22050d3d8b43386b059a4dc0bca3f3d40a40971cb206fff1785af", size = 16854, upload-time = "2026-11-19T22:10:15.746Z" },
]
-[[package]]
-name = "iniconfig"
-version = "2.1.0"
-source = { registry = "https://pypi.org/simple" }
-resolution-markers = [
- "python_full_version < '3.10'",
-]
-sdist = { url = "https://files.pythonhosted.org/packages/f2/97/ebf4da567aa6827c909642694d71c9fcf53e5b504f2d96afea02718862f3/iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7", size = 4793, upload-time = "2025-03-19T20:09:59.721Z" }
-wheels = [
- { url = "https://files.pythonhosted.org/packages/2c/e1/e6716421ea10d38022b952c159d5161ca1193197fb744506875fbb87ea7b/iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760", size = 6050, upload-time = "2025-03-19T20:10:01.071Z" },
-]
-
[[package]]
name = "iniconfig"
version = "2.3.1"
source = { registry = "https://pypi.org/simple" }
-resolution-markers = [
- "python_full_version >= '3.10'",
-]
sdist = { url = "https://files.pythonhosted.org/packages/01/e1/2069291243c926a2ff1cd706c7f3eeb9b62144bf60f77c9fb9ff2fb26bd3/iniconfig-2.3.1.tar.gz", hash = "sha256:67f4b9c50da0dedf52af349e7749a80a9057a5031199791b906c3bb3ae878960", size = 21209, upload-time = "2026-10-06T22:48:38.076Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/56/43/4ca9e49d27a1fcf6bece6f6aec0ea46bb9112489b93d4b688fb415457bdb/iniconfig-2.3.1-py3-none-any.whl", hash = "sha256:9121e2c1fdb355232495be3194c8dfe87ccc2d5dee45947b78e68f499790d7a7", size = 7552, upload-time = "2026-10-06T22:48:36.959Z" },
]
-[[package]]
-name = "packaging"
-version = "26.3"
-source = { registry = "https://pypi.org/simple" }
-resolution-markers = [
- "python_full_version < '3.10'",
-]
-sdist = { url = "https://files.pythonhosted.org/packages/7d/fa/3944b40b07da9ce895c0e6303a5ab7d53da063554f534556b134a54d6093/packaging-26.3.tar.gz", hash = "sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79", size = 313412, upload-time = "2026-08-04T18:15:28.737Z" }
-wheels = [
- { url = "https://files.pythonhosted.org/packages/63/34/ba1c580383c9eada3711951fef0795c80b829a078d72188184bcab9dd527/packaging-26.3-py3-none-any.whl", hash = "sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c", size = 129956, upload-time = "2026-08-04T18:15:27.159Z" },
-]
-
[[package]]
name = "packaging"
version = "26.4"
source = { registry = "https://pypi.org/simple" }
-resolution-markers = [
- "python_full_version >= '3.10'",
-]
sdist = { url = "https://files.pythonhosted.org/packages/c3/75/ffb1dc0ed12352139fb4ca0e3fde4325a23e3d0f3f40efe89717bc4f557b/packaging-26.4.tar.gz", hash = "sha256:c4b671c41ddb9bf26e543c37723610d28fb6bf7affc4da17cf048d419d2c062a", size = 355877, upload-time = "2026-11-23T21:44:11.152Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/ba/7b/5504f91c9c2733f693d7759e50ede5d27119d4da7e5836c46d3b5ff81d56/packaging-26.4-py3-none-any.whl", hash = "sha256:81383611a09c1bc0b08b76e0fd5829d7c6824c65b27a6aee339da133f4233ea2", size = 140049, upload-time = "2026-11-23T21:44:09.531Z" },
]
-[[package]]
-name = "pluggy"
-version = "1.6.0"
-source = { registry = "https://pypi.org/simple" }
-resolution-markers = [
- "python_full_version < '3.10'",
-]
-sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412, upload-time = "2025-05-15T12:30:07.975Z" }
-wheels = [
- { url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" },
-]
-
[[package]]
name = "pluggy"
version = "1.7.0"
source = { registry = "https://pypi.org/simple" }
-resolution-markers = [
- "python_full_version >= '3.10'",
-]
sdist = { url = "https://files.pythonhosted.org/packages/bf/db/7fc19e6f2dc92a966727031389fc2e08b558f0f25eb7403c1119ad4713cd/pluggy-1.7.0.tar.gz", hash = "sha256:d1eaa46ebb595891b860ab086b4d09c8588af65ebd4361b8e8f4bb8920b90ba8", size = 123304, upload-time = "2026-10-15T09:50:58.343Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/40/9e/2b38731e0fc536806f16490e1a12d7f0dc2a1235aa8cc07bcc75416a7daa/pluggy-1.7.0-py3-none-any.whl", hash = "sha256:7dd7b0d8832ba3cb632c306926ded123429211b83641b35dc5c41ad2d34f9bec", size = 27082, upload-time = "2026-10-15T09:50:56.808Z" },
@@ -108,40 +59,16 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/71/46/17f022dd3e953bf20a04a028a21ec746d942f8d2af30fa0f124fa0e6a684/pygments-2.21.0-py3-none-any.whl", hash = "sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9", size = 1250147, upload-time = "2026-08-17T08:02:44.912Z" },
]
-[[package]]
-name = "pytest"
-version = "8.4.2"
-source = { registry = "https://pypi.org/simple" }
-resolution-markers = [
- "python_full_version < '3.10'",
-]
-dependencies = [
- { name = "colorama", marker = "sys_platform == 'win32'" },
- { name = "exceptiongroup" },
- { name = "iniconfig", version = "2.1.0", source = { registry = "https://pypi.org/simple" } },
- { name = "packaging", version = "26.3", source = { registry = "https://pypi.org/simple" } },
- { name = "pluggy", version = "1.6.0", source = { registry = "https://pypi.org/simple" } },
- { name = "pygments" },
- { name = "tomli" },
-]
-sdist = { url = "https://files.pythonhosted.org/packages/a3/5c/00a0e072241553e1a7496d638deababa67c5058571567b92a7eaa258397c/pytest-8.4.2.tar.gz", hash = "sha256:86c0d0b93306b961d58d62a4db4879f27fe25513d4b969df351abdddb3c30e01", size = 1519618, upload-time = "2025-09-04T14:34:22.711Z" }
-wheels = [
- { url = "https://files.pythonhosted.org/packages/a8/a4/20da314d277121d6534b3a980b29035dcd51e6744bd79075a6ce8fa4eb8d/pytest-8.4.2-py3-none-any.whl", hash = "sha256:872f880de3fc3a5bdc88a11b39c9710c3497a547cfa9320bc3c5e62fbf272e79", size = 365750, upload-time = "2025-09-04T14:34:20.226Z" },
-]
-
[[package]]
name = "pytest"
version = "9.2.0"
source = { registry = "https://pypi.org/simple" }
-resolution-markers = [
- "python_full_version >= '3.10'",
-]
dependencies = [
{ name = "colorama", marker = "sys_platform == 'win32'" },
{ name = "exceptiongroup", marker = "python_full_version < '3.11'" },
- { name = "iniconfig", version = "2.3.1", source = { registry = "https://pypi.org/simple" } },
- { name = "packaging", version = "26.4", source = { registry = "https://pypi.org/simple" } },
- { name = "pluggy", version = "1.7.0", source = { registry = "https://pypi.org/simple" } },
+ { name = "iniconfig" },
+ { name = "packaging" },
+ { name = "pluggy" },
{ name = "pygments" },
{ name = "tomli", marker = "python_full_version < '3.11'" },
]
@@ -175,25 +102,10 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/58/ed/dea90a65b7d9e69888890fb14c90d7f51bf0c1e82ad800aeb0160e4bacfd/ruff-0.15.10-py3-none-win_arm64.whl", hash = "sha256:601d1610a9e1f1c2165a4f561eeaa2e2ea1e97f3287c5aa258d3dab8b57c6188", size = 11035607, upload-time = "2026-04-09T14:05:47.593Z" },
]
-[[package]]
-name = "sh"
-version = "2.3.0"
-source = { registry = "https://pypi.org/simple" }
-resolution-markers = [
- "python_full_version < '3.10'",
-]
-sdist = { url = "https://files.pythonhosted.org/packages/fa/56/6cedf4704590ac9c8ab57089ffa95895c21e82499981008ad369c43c9cc4/sh-2.3.0.tar.gz", hash = "sha256:402af9087bf8a5557562913ca83d715bfa0646cb93865c5d60c5578b07b17871", size = 135995, upload-time = "2026-06-09T04:22:34.431Z" }
-wheels = [
- { url = "https://files.pythonhosted.org/packages/47/85/d06247fc88ba278227397da5604287e4762f130347dc968f6d205eb15ee6/sh-2.3.0-py3-none-any.whl", hash = "sha256:9b9c51f988fa91ba09e2a78edc48810d0b5a34c8cf383408e4e8c4352169f26e", size = 48045, upload-time = "2026-06-09T04:22:33.069Z" },
-]
-
[[package]]
name = "sh"
version = "2.4.0"
source = { registry = "https://pypi.org/simple" }
-resolution-markers = [
- "python_full_version >= '3.10'",
-]
sdist = { url = "https://files.pythonhosted.org/packages/e9/c8/137093889a8b8c9a66c9b46079cf2a0e155a8be027df212a4041e3b7b09c/sh-2.4.0.tar.gz", hash = "sha256:a250aef68509ed93419c9a1d90b0647cd5cbe26107ba94d3717ef5b6d595ffd9", size = 136950, upload-time = "2026-07-25T21:44:42.705Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/23/dd/6b9aceecddbb3df894003d6a5005bd90bce3cf4743c28c406ebecc8d80f6/sh-2.4.0-py3-none-any.whl", hash = "sha256:98eba32eeb5ecdd310668737d7461e668afc42b273550d0bc198a1c5c2b1ab36", size = 48619, upload-time = "2026-07-25T21:44:41.216Z" },
@@ -276,14 +188,12 @@ name = "trevorproxy"
version = "1.0.10"
source = { editable = "." }
dependencies = [
- { name = "sh", version = "2.3.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" },
- { name = "sh", version = "2.4.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" },
+ { name = "sh" },
]
[package.dev-dependencies]
dev = [
- { name = "pytest", version = "8.4.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" },
- { name = "pytest", version = "9.2.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" },
+ { name = "pytest" },
{ name = "ruff" },
]
- requires-python >=3.10: the fixed pytest (GHSA-6w46-j5rx-g56g) needs 3.10; 3.9 is end of life. Python 3.9 users keep 1.0.9. - sh>=2.2.4: no install can resolve an sh affected by the incomplete privilege drop (Dependabot alert #1, HIGH). - uv.lock relocked (uv 0.13.10): only the Python <3.10 branches drop out (pytest 8.4.2, pluggy 1.6.0, sh 2.3.0, iniconfig 2.1.0, packaging 26.3). - socks.py: the style commit removed `as e` from four handlers that still log `{e}`, so at log level INFO or above they raised UnboundLocalError. Each handler now binds `e` and logs the traceback at DEBUG, else `e`.
|
Both fixed in 6d0dc6c:
ruff 0.15.10, pytest (3.10, 3.13), |
en0f
left a comment
There was a problem hiding this comment.
Reviewed at 6d0dc6c.
🔴 dependency-review fails: uv.lock pins pytest 8.4.2 (GHSA-6w46-j5rx-g56g) for Python 3.9
Resolved. requires-python = ">=3.10" and the relock drop pytest 8.4.2, and dev-security / dependency-review is green.
🔴 ruff --fix broke the error logging in socks.py's four except handlers
Resolved. All four handlers bind e again. With the socks logger at INFO, a bad greeting logs Error in greeting: Only SOCKS version 5 is supported (socks5://) and exchange_loop logs [Errno 32] Broken pipe. With the CLI's logging, or none, the traceback is logged as before.
🟢 The sh>=2.2.4 floor shuts out GHSA-q38v-wp89-2w55
GHSA-q38v-wp89-2w55 (_uid does not drop supplementary groups) affects every sh before 2.2.4, so the floor now keeps a plain pip install trevorproxy off a vulnerable sh, not just the lock. uv sync --frozen --no-dev installs and trevorproxy --help runs.
Reproduce this review
# save the script below as verify-17.sh, then:
bash verify-17.sh blacklanternsecurity/TREVORproxy 6d0dc6cd5da381ed8f3e553b5dc5fe2bc1551488
# expected: SUMMARY 13 PASS, 1 FAIL, 0 SKIP, 0 BROKEN
# V09 FAIL is repository history since v1.0.9, not this diff
# control: bash verify-17.sh blacklanternsecurity/TREVORproxy 8067a262497ae8c9c64bb049e35309b7ebcd2dcf -> V01 V02 V05 V11 V12 FAIL#!/usr/bin/env bash
# verify-17.sh: reproducible checks for blacklanternsecurity/TREVORproxy#17
# Usage: bash verify-17.sh <owner/repo> <sha> [<control-patch>]
# Changes nothing outside a mktemp directory and nothing on GitHub (PR-VF-02).
# GitHub reads are GET-only (gh api defaults to GET with no fields); OSV and PyPI reads are anonymous.
#
# Round 2. Control: the head changes were requested on in round 1 (8067a262).
# CONTROL: sha 8067a262497ae8c9c64bb049e35309b7ebcd2dcf
# CONTROL-EXPECT: V01=FAIL V02=FAIL V05=FAIL V11=FAIL V12=FAIL
set -uo pipefail
REPO="${1:?owner/repo}"; SHA="${2:?sha}"; PATCH="${3:-}"
PASS=0; FAIL=0; SKIP=0; BROKEN=0
pass() { echo "PASS $1 $2"; PASS=$((PASS+1)); }
fail() { echo "FAIL $1 $2 -- $3"; FAIL=$((FAIL+1)); }
skip() { echo "SKIP $1 $2 -- $3"; SKIP=$((SKIP+1)); }
broken() { echo "BROKEN $1 $2 -- $3"; BROKEN=$((BROKEN+1)); }
summary() { echo "SUMMARY $PASS PASS, $FAIL FAIL, $SKIP SKIP, $BROKEN BROKEN"; [ "$FAIL" -eq 0 ] && [ "$BROKEN" -eq 0 ]; }
echo "script_sha256 $(shasum -a 256 "$0" | cut -d' ' -f1)"
echo "git $(git --version | cut -d' ' -f3)"
echo "python $(python3 -c 'import platform; print(platform.python_version())')"
WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT
case "$PATCH" in ""|/*) ;; *) PATCH="$PWD/$PATCH" ;; esac
export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 GIT_TERMINAL_PROMPT=0
GIT=(git -c credential.helper= -c 'credential.helper=!gh auth git-credential')
"${GIT[@]}" clone --quiet --filter=blob:none --no-checkout "https://github.com/$REPO.git" "$WORK/src" || { broken V00 "clone" "clone failed"; summary; exit 1; }
cd "$WORK/src"
"${GIT[@]}" cat-file -e "$SHA^{commit}" 2>/dev/null || "${GIT[@]}" fetch --quiet origin "+refs/pull/*/head:refs/remotes/pr/*" || true
"${GIT[@]}" checkout --quiet --detach "$SHA" || { broken V00 "checkout $SHA" "checkout failed"; summary; exit 1; }
[ "$(git rev-parse HEAD)" = "$SHA" ] || { broken V00 "HEAD is $SHA" "HEAD mismatch"; summary; exit 1; }
if [ -n "$PATCH" ]; then git apply "$PATCH" || { broken V00 "apply control patch" "git apply failed"; summary; exit 1; }; fi
# ---- pinned uv 0.11.20 (checksum-verified, with a wrong-hash control) ----
UV_VERSION=0.11.20
case "$(uname -s)-$(uname -m)" in
Darwin-x86_64) UV_ASSET=uv-x86_64-apple-darwin; UV_SHA=bef01a86faab997f6022b45cfa29bfc5b090f2f72cd4a91d2ecefe641efdabe7 ;;
Darwin-arm64) UV_ASSET=uv-aarch64-apple-darwin; UV_SHA=0a2b6a757d5693671a7ce0002554ae869604e1e69acb10313ac14d08374be01a ;;
Linux-x86_64) UV_ASSET=uv-x86_64-unknown-linux-gnu; UV_SHA=5de211d9278af365497d387e25316907b3b4a9f25b4476dd6dbf238d6f85cff3 ;;
Linux-aarch64) UV_ASSET=uv-aarch64-unknown-linux-gnu; UV_SHA=c8b5b7f9c804b640da0bb66cddddf0a00ce971f64d8076622d70bd141bc80857 ;;
*) UV_ASSET="" ;;
esac
UV=""
if [ -n "$UV_ASSET" ] && curl -fsSLo "$WORK/uv.tgz" "https://github.com/astral-sh/uv/releases/download/$UV_VERSION/$UV_ASSET.tar.gz"; then
if echo "$UV_SHA $WORK/uv.tgz" | shasum -a 256 -c - >/dev/null 2>&1; then
if echo "0000000000000000000000000000000000000000000000000000000000000000 $WORK/uv.tgz" | shasum -a 256 -c - >/dev/null 2>&1; then broken V90 "uv wrong-hash control fails" "accepted a wrong hash"; else pass V90 "uv $UV_VERSION checksum matches; wrong-hash control fails"; fi
mkdir -p "$WORK/uvbin" && tar -xzf "$WORK/uv.tgz" -C "$WORK/uvbin" --strip-components 1 && UV="$WORK/uvbin/uv"
else broken V90 "uv checksum matches" "mismatch"; fi
fi
# uv's cache and config stay in $WORK, set per call (exporting XDG_CONFIG_HOME would hide gh's login)
uvc() { UV_CACHE_DIR="$WORK/uv/cache" UV_NO_CONFIG=1 UV_PYTHON_INSTALL_DIR="$WORK/uv/python" UV_TOOL_DIR="$WORK/uv/tools" XDG_CONFIG_HOME="$WORK/uv/config" "$UV" "$@"; }
# ---- checks: each line states the desired property --------------------------
# V01: uv.lock locks no package inside GHSA-6w46-j5rx-g56g's affected range (the advisory dependency review fails on)
curl -fsS -o "$WORK/osv.json" "https://api.osv.dev/v1/vulns/GHSA-6w46-j5rx-g56g" 2>/dev/null || true
R01=$(python3 - "$WORK/osv.json" uv.lock <<'PY'
import json, sys, tomllib
try:
adv = json.load(open(sys.argv[1]))
except Exception as e:
print(f"ERR osv {e}"); sys.exit()
def key(v):
return tuple(int(x) for x in v.split(".")[:3])
ranges = []
for a in adv.get("affected", []):
if a["package"]["name"].lower() != "pytest": continue
for r in a.get("ranges", []):
intro = fixed = None
for ev in r.get("events", []):
intro = ev.get("introduced", intro); fixed = ev.get("fixed", fixed)
ranges.append((intro, fixed))
if not ranges:
print("ERR no pytest range in advisory"); sys.exit()
lock = tomllib.load(open(sys.argv[2], "rb"))
hit = []
for p in lock.get("package", []):
if p["name"] != "pytest": continue
for intro, fixed in ranges:
lo = key(intro) if intro and intro != "0" else (0, 0, 0)
if key(p["version"]) >= lo and (fixed is None or key(p["version"]) < key(fixed)):
hit.append(f"pytest {p['version']} (fixed {fixed})")
print("ok" if not hit else "BAD " + "; ".join(hit))
PY
)
case "$R01" in
ok) pass V01 "uv.lock locks no pytest inside GHSA-6w46-j5rx-g56g's range" ;;
ERR*) skip V01 "uv.lock locks no pytest inside GHSA-6w46-j5rx-g56g's range" "$R01" ;;
*) fail V01 "uv.lock locks no pytest inside GHSA-6w46-j5rx-g56g's range" "$R01" ;;
esac
# V02: requires-python starts at 3.10, the org toolchain's floor (standards/toolchain.md: 3.10 through 3.14),
# and no patched pytest (>=9.0.3) installs on 3.9, so a 3.9 floor always locks a vulnerable pytest
RP=$(python3 -c 'import tomllib;print(tomllib.load(open("pyproject.toml","rb"))["project"].get("requires-python",""))')
PYTEST_RP=$(curl -fsS "https://pypi.org/pypi/pytest/9.0.3/json" 2>/dev/null | python3 -c 'import json,sys;print(json.load(sys.stdin)["info"]["requires_python"])' 2>/dev/null || echo "?")
if [ "$RP" = ">=3.10" ]; then pass V02 "requires-python is >=3.10 (pytest 9.0.3 requires $PYTEST_RP)"
else fail V02 "requires-python is >=3.10 (pytest 9.0.3 requires $PYTEST_RP)" "requires-python = '$RP'"; fi
# V03: uv.lock matches pyproject.toml
if [ -z "$UV" ]; then skip V03 "uv lock --check passes" "no pinned uv"
else OUT=$(uvc lock --check 2>&1); RC=$?
if [ "$RC" -eq 0 ]; then pass V03 "uv lock --check passes (uv.lock matches pyproject.toml)"; else fail V03 "uv lock --check passes" "$(echo "$OUT" | tail -2 | tr '\n' ' ' | cut -c1-200)"; fi
fi
# V04: ruff (the pyproject pin, 0.15.10) reports a clean check and format
if [ -z "$UV" ]; then skip V04 "ruff 0.15.10 check and format --check are clean" "no pinned uv"
else O1=$(uvc tool run [email protected] check 2>&1); R1=$?; O2=$(uvc tool run [email protected] format --check 2>&1); R2=$?
if [ "$R1" -eq 0 ] && [ "$R2" -eq 0 ]; then pass V04 "ruff 0.15.10 check and format --check are clean"
else fail V04 "ruff 0.15.10 check and format --check are clean" "$(echo "$O1 $O2" | tail -3 | tr '\n' ' ' | cut -c1-200)"; fi
fi
# Socks handler probe: drive SocksProxy.handle() with a bad SOCKS greeting (version 4) over a fake connection.
cat > "$WORK/socks_probe.py" <<'PY'
import sys, logging, types
sys.path.insert(0, sys.argv[1]); sys.dont_write_bytecode = True
from trevorproxy.lib import socks
mode = sys.argv[2]
records = []
class H(logging.Handler):
def emit(self, r): records.append(r.getMessage())
lg = logging.getLogger("trevorproxy.socks"); lg.addHandler(H()); lg.propagate = False
# as the CLI does: trevorproxy/lib/logger.py:20 sets the "trevorproxy" logger to DEBUG (its file handlers are left out)
logging.getLogger("trevorproxy").setLevel(logging.DEBUG)
if mode == "info":
lg.setLevel(logging.INFO) # a caller that turns socks logging down to INFO
class Conn:
def __init__(self, data): self.data = data
def recv(self, n):
out, self.data = self.data[:n], self.data[n:]; return out
h = object.__new__(socks.SocksProxy)
h.connection = Conn(b"\x04\x01"); h.client_address = ("192.0.2.1", 1234)
try:
h.handle()
except Exception as e:
print(f"RAISED {type(e).__name__}: {e}"); sys.exit()
msg = [m for m in records if m.startswith("Error in greeting")]
if not msg: print("NOLOG " + repr(records)); sys.exit()
print(("TB " if "Traceback" in msg[0] else "MSG ") + msg[0].splitlines()[0][:120])
PY
# V05: with the socks logger at INFO, a bad greeting is logged, not turned into UnboundLocalError
R05=$(python3 "$WORK/socks_probe.py" "$WORK/src" info 2>&1 | tail -1)
case "$R05" in
MSG\ Error\ in\ greeting:\ Only\ SOCKS\ version\ 5*) pass V05 "socks logger at INFO: bad greeting logged as '${R05#MSG }'" ;;
*) fail V05 "socks logger at INFO: bad greeting is logged, not raised" "$R05" ;;
esac
# V06: with the logging the CLI sets up ("trevorproxy" at DEBUG, socks logger NOTSET), a bad greeting still logs the traceback
R06=$(python3 "$WORK/socks_probe.py" "$WORK/src" default 2>&1 | tail -1)
case "$R06" in
TB\ Error\ in\ greeting:*) pass V06 "default logging: bad greeting logs the traceback (unchanged)" ;;
*) fail V06 "default logging: bad greeting logs the traceback" "$R06" ;;
esac
# V07: the build ships the package, lib/ and the console script
if [ -z "$UV" ]; then skip V07 "uv build ships trevorproxy, trevorproxy/lib and the trevorproxy script" "no pinned uv"
else OUT=$(uvc build --out-dir "$WORK/dist" 2>&1); RC=$?
R07=$(python3 - "$WORK/dist" <<'PY'
import sys, glob, zipfile
w = glob.glob(sys.argv[1] + "/*.whl"); s = glob.glob(sys.argv[1] + "/*.tar.gz")
if len(w) != 1 or len(s) != 1: print(f"BAD wheels={w} sdists={s}"); sys.exit()
z = zipfile.ZipFile(w[0]); names = z.namelist()
need = ["trevorproxy/cli.py", "trevorproxy/lib/socks.py", "trevorproxy/lib/ssh.py", "trevorproxy/lib/logger.py"]
miss = [n for n in need if n not in names]
ep = [n for n in names if n.endswith("entry_points.txt")]
meta = [n for n in names if n.endswith("METADATA")]
eps = z.read(ep[0]).decode() if ep else ""
md = z.read(meta[0]).decode() if meta else ""
probs = miss[:]
if "trevorproxy=trevorproxy.cli:main" not in eps.replace(" ", ""): probs.append("no console script")
if "Version: 1.0.10" not in md: probs.append("version")
if "Requires-Dist: sh" not in md: probs.append("no sh dependency")
print("ok " + w[0].rsplit("/", 1)[-1] if not probs else "BAD " + ",".join(probs))
PY
)
if [ "$RC" -eq 0 ] && [ "${R07%% *}" = ok ]; then pass V07 "uv build ships trevorproxy, trevorproxy/lib and the trevorproxy script (${R07#ok })"
else fail V07 "uv build ships trevorproxy, trevorproxy/lib and the trevorproxy script" "rc=$RC $R07 $(echo "$OUT" | tail -1 | cut -c1-120)"; fi
fi
# V08: every uses: in the workflows is a 40-character SHA with a version comment, and the
# release-workflows pin is the v1.5.0 tag's commit
BAD=$(cat .github/workflows/*.yml | /usr/bin/grep -E '^[[:space:]-]*uses:' | /usr/bin/grep -vE 'uses: \./' | /usr/bin/grep -vE '@[0-9a-f]{40} # v[0-9]' || true)
RWPINS=$(cat .github/workflows/dev-security.yml .github/workflows/publish.yml .github/workflows/stable-guard.yml .github/workflows/tests.yml | /usr/bin/grep -oE 'release-workflows/[^@]+@[0-9a-f]{40}' | sed 's/.*@//' | sort -u)
TAGSHA=$(gh api repos/blacklanternsecurity/release-workflows/git/ref/tags/v1.5.0 --jq '.object.sha' 2>/dev/null || echo "")
if [ -n "$BAD" ]; then fail V08 "every uses: pinned to a SHA with a version comment" "$(echo "$BAD" | head -2 | tr '\n' ' ')"
elif [ -z "$TAGSHA" ]; then skip V08 "release-workflows pin equals v1.5.0" "tag read failed"
elif [ "$RWPINS" = "$TAGSHA" ]; then pass V08 "every uses: SHA-pinned with a version comment; release-workflows pin $TAGSHA is v1.5.0"
else fail V08 "release-workflows pin equals v1.5.0 ($TAGSHA)" "pins: $(echo $RWPINS)"; fi
# V09: every first-parent commit since v1.0.9 on master (the branch to be renamed stable) arrived through a merged
# pull request, which release-workflows provenance.py requires before the first release
MT=$(gh api repos/blacklanternsecurity/TREVORproxy/compare/v1.0.9...master --jq '[.commits[] | select((.parents|length)==1) | .sha] | .[]' 2>/dev/null || echo "ERR")
if [ "$MT" = ERR ] || [ -z "$MT" ]; then skip V09 "commits since v1.0.9 arrived through merged PRs" "compare read failed"
else NOPR=""; N=0
# merged-PR commits on the first-parent line are the merges; single-parent commits on it are direct pushes unless a PR lists them
for c in $MT; do N=$((N+1)); P=$(gh api "repos/blacklanternsecurity/TREVORproxy/commits/$c/pulls" --jq '[.[] | select(.merged_at != null)] | length' 2>/dev/null || echo "?")
[ "$P" = 0 ] && NOPR="$NOPR ${c:0:8}"; done
FP=$(git rev-list --first-parent v1.0.9..origin/master 2>/dev/null | wc -l | tr -d ' ')
if [ -z "$NOPR" ]; then pass V09 "all single-parent commits since v1.0.9 on master came through merged PRs"
else fail V09 "all commits since v1.0.9 on master came through merged PRs" "no merged PR:$NOPR ($FP first-parent commits since v1.0.9)"; fi
fi
# ---- checks added to answer the challenge ----
# V10 (C6): with no logging configured (library use: "trevorproxy" and the socks logger NOTSET),
# a bad greeting still logs the traceback, as at the base 4bc8c6a7
R10=$(python3 - "$WORK/src" <<'PY'
import sys, logging
sys.path.insert(0, sys.argv[1]); sys.dont_write_bytecode = True
from trevorproxy.lib import socks
recs = []
class H(logging.Handler):
def emit(self, r): recs.append(r.getMessage())
lg = logging.getLogger("trevorproxy.socks"); lg.addHandler(H()); lg.propagate = False
class Conn:
def __init__(s, d): s.d = d
def recv(s, n):
o, s.d = s.d[:n], s.d[n:]; return o
h = object.__new__(socks.SocksProxy); h.connection = Conn(b"\x04\x01"); h.client_address = ("192.0.2.1", 1)
try:
h.handle()
except Exception as ex:
print(f"RAISED {type(ex).__name__}"); sys.exit()
m = [x for x in recs if x.startswith("Error in greeting")]
print(("TB " if m and "Traceback" in m[0] else "NOTB ") + (m[0].splitlines()[0] if m else repr(recs)))
PY
)
case "$R10" in
TB*) pass V10 "no logging configured: bad greeting logs the traceback (as at base)" ;;
*) fail V10 "no logging configured: bad greeting logs the traceback (as at base)" "$R10" ;;
esac
# V11 (C4): with the socks logger at INFO, a broken pipe in exchange_loop logs the socket error,
# not select()'s leftover list (head reuses `e` from `r, w, e = select.select(...)`)
R11=$(python3 - "$WORK/src" <<'PY'
import sys, logging, socket
sys.path.insert(0, sys.argv[1]); sys.dont_write_bytecode = True
from trevorproxy.lib import socks
recs = []
class H(logging.Handler):
def emit(self, r): recs.append(r.getMessage())
lg = logging.getLogger("trevorproxy.socks"); lg.addHandler(H()); lg.propagate = False; lg.setLevel(logging.INFO)
h = object.__new__(socks.SocksProxy)
c, peer = socket.socketpair(); r, rpeer = socket.socketpair(); peer.send(b"x"); rpeer.close()
try:
h.exchange_loop(c, r)
except Exception as ex:
print(f"RAISED {type(ex).__name__}"); sys.exit()
m = [x for x in recs if x.startswith("Error in data exchange")]
print(m[0] if m else "NOLOG " + repr(recs))
PY
)
case "$R11" in
"Error in data exchange: [Errno"*) pass V11 "socks logger at INFO: exchange_loop logs the socket error ('$R11')" ;;
*) fail V11 "socks logger at INFO: exchange_loop logs the socket error" "$R11" ;;
esac
# ---- round 2 ----
# V12: the sh runtime floor excludes every release in GHSA-q38v-wp89-2w55's affected range, and the locked sh is outside it
curl -fsS -o "$WORK/osv_sh.json" "https://api.osv.dev/v1/vulns/GHSA-q38v-wp89-2w55" 2>/dev/null || true
R12=$(python3 - "$WORK/osv_sh.json" pyproject.toml uv.lock <<'PY2'
import json, sys, tomllib, re
try:
adv = json.load(open(sys.argv[1]))
except Exception as e:
print(f"ERR osv {e}"); sys.exit()
key = lambda v: tuple(int(x) for x in v.split(".")[:3])
fixed = [ev["fixed"] for a in adv.get("affected", []) if a["package"]["name"].lower() == "sh"
for r in a.get("ranges", []) for ev in r.get("events", []) if "fixed" in ev]
if len(fixed) != 1: print(f"ERR fixed={fixed}"); sys.exit()
deps = tomllib.load(open(sys.argv[2], "rb"))["project"]["dependencies"]
m = [re.search(r">=\s*([0-9.]+)", d) for d in deps if re.match(r"sh\b", d)]
if not m or not m[0]: print(f"BAD no sh floor in {deps}"); sys.exit()
floor = m[0].group(1)
locked = [p["version"] for p in tomllib.load(open(sys.argv[3], "rb"))["package"] if p["name"] == "sh"]
bad = [v for v in locked if key(v) < key(fixed[0])]
if key(floor) < key(fixed[0]) or bad: print(f"BAD floor {floor} < fixed {fixed[0]} or locked {bad}")
else: print(f"ok floor {floor}, fixed {fixed[0]}, locked {locked}")
PY2
)
case "$R12" in
ok*) pass V12 "sh floor excludes GHSA-q38v-wp89-2w55 (${R12#ok })" ;;
ERR*) skip V12 "sh floor excludes GHSA-q38v-wp89-2w55" "$R12" ;;
*) fail V12 "sh floor excludes GHSA-q38v-wp89-2w55" "$R12" ;;
esac
# V13 (C11): the package installs and runs without the dev group (install-runtime boundary)
if [ -z "$UV" ]; then skip V13 "uv sync --frozen --no-dev installs; trevorproxy --help prints usage" "no pinned uv"
else O13=$(UV_PROJECT_ENVIRONMENT="$WORK/rtenv" uvc sync --frozen --no-dev 2>&1); RC13=$?
H13=$("$WORK/rtenv/bin/trevorproxy" --help 2>&1); HR13=$?
if [ "$RC13" -eq 0 ] && [ "$HR13" -eq 0 ] && echo "$H13" | /usr/bin/grep -qi usage; then pass V13 "uv sync --frozen --no-dev installs; trevorproxy --help prints usage"
else fail V13 "uv sync --frozen --no-dev installs; trevorproxy --help prints usage" "sync rc=$RC13 help rc=$HR13 $(echo "$O13 $H13" | tail -2 | tr '\n' ' ' | cut -c1-160)"; fi
fi
# ------------------------------------------------------------------------------
summary
📝 The first release on this flow will stop at provenanceNot a blocker for this PR. Check: |
TREVORproxy moves to the publishing policy's release flow (policy 1.9.0). Nothing publishes from this PR:
publish.ymlruns only on pushes tostable, and each publish step waits for a lead's approval at thereleaseenvironment.pyproject.toml-> PEP 621[project](poetry-core 2 still builds it; uv and release-workflows read it). Version 1.0.10 (first release on the new flow). Python >=3.10 (3.9 users keep 1.0.9);sh>=2.2.4. Dev group: pytest, ruff 0.15.10.uv.lockreplacespoetry.lock.publish.yml(release-workflows v1.5.0): release-check -> tests -> build -> PyPI by trusted publishing ->v1.0.10tag + GitHub release by the release App.tests.yml(shared python-tests) +tests/test_smoke.py(import,--help): the repo's first tests.stable-guard.yml,dev-security.yml, CODEOWNERS (both lead teams, policy 1.9.0 D15), Dependabot (uv + actions into dev, cooldown),.gitignore.ruff check --fix+ruff format, and three dead assignments removed. Its F841 fix broke foursocks.pyerror handlers; the third commit restores them.import lib.loggerin cli.py is kept (it sets up the log handlers; ruff flagged it as unused). Ruff baseline: line length 119; E402, F403/F405, E722 ignored for now (structural, noted in pyproject).Already in place:
releaseenvironment (both lead teams, stable only), bls-release App + key, baseline tagv1.0.9(2a8cfee, = PyPI 1.0.9), tag rulesets, secret scanning + push protection, Dependabot alerts, CodeQL, workflow token read. Still to come: PyPI trusted publisher,master->stablerename, dev/stable rulesets.Locally: ruff clean, pytest 2 passed, actionlint + zizmor (whole repo) clean,
uv lock --checkok,uv build-> trevorproxy-1.0.10 wheel + sdist (lib/ and thetrevorproxyentry point included).