Skip to content

Release 1.0.10: promote dev to stable - #18

Open
pjhartlieb wants to merge 6 commits into
stablefrom
dev
Open

pjhartlieb wants to merge 6 commits into
stablefrom
dev

Conversation

@pjhartlieb

Copy link
Copy Markdown
Contributor

Release 1.0.10: promotes dev to stable. This is TREVORproxy's first release on the org release flow (publishing policy 1.9.x).

Changes since 1.0.9 (published by hand):

  • fix: undefined names in ssh.py and util.py
  • fix: Python >=3.10, sh>=2.2.4, restore socks.py error logging
  • style: ruff check --fix and ruff format (no behaviour change)
  • ci: publish on merge to stable; version 1.0.10
  • licence: AGPL-3.0

What happens on merge: publish.yml checks the version, builds, and waits for approval in the release environment (a lead other than the merger). It then publishes to PyPI by trusted publishing (no token) and creates the v1.0.10 tag and GitHub release.

Approvals: one lead approves this PR (not the last pusher); a second lead approves the release pause.

- ssh.py SSHLoadBalancer.__exit__ called debug.info (NameError on leaving
  every `with` block); the module logger is `log`.
- util.clean_pool_arg used ip_network without importing it (NameError for a
  single CIDR pool); use ipaddress.ip_network.
- util.autodetect_address_pool called exclude_hosts, which doesn't exist;
  the matching function is exclude_hosts_from_subnet(subnet, hosts).
fix: undefined names in ssh.py and util.py
- 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.
- 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`.
ci: publish on merge to stable (publishing policy 1.9.0), version 1.0.10
@pjhartlieb
pjhartlieb requested a review from a team December 2, 2026 22:38

@en0f en0f left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 2707545.

🔴 The 1.0.10 release run will stop at provenance

publish.yml's check job runs release-check v1.5.0, whose provenance.py fails any first-parent commit since the latest v* tag that didn't come through a PR merged into stable. All 9 commits on stable since v1.0.9 fail: 7 were pushed directly to master (5045eac 13c0e29 f41bbf5 e88a219 11efe32 8bab795 991c95b), and #13 and #14 still report base master after the rename (V02). Any merge method keeps them on the walked line, so merging publishes and tags nothing. v1.5.1 is the same.

Without an exception: a provenance baseline option in release-workflows (here a7e9b02), pinned through a dev PR. Quicker: release-check's direct-push-paths set to the six paths those commits touch (.github/workflows/cla.yml LICENSE README.md THIRD_PARTY_NOTICES.md pyproject.toml trevorproxy/lib/socks.py). The policy records that input only for cloudcheck (D9), so it's a one-off cut-over exemption: say so in this PR so the approving lead accepts it knowingly, and remove it after 1.0.10 ships. I'll rerun the check with whatever the new head sets.

🔴 CODEOWNERS names bbot-leads; a repository joining after 1.9.0 names development-leads only

Publishing policy 1.9.1 D15 says a repository that joins the gate after 1.9.0 names development-leads only. TREVORproxy joined after it: the release environment was created on 2026-11-30, the stable-review ruleset on 2026-12-02, and this CODEOWNERS file first appears in #17 (V01). On dev, make it * @blacklanternsecurity/development-leads and cite 1.9.1 D15 instead of 1.8.0; this PR picks it up. Drop bbot-leads from the release environment's reviewers too (V07).

🟢 publish.yml keeps the publish credential in one approved job

permissions: {} at the top, id-token: write only in the pypi job, which runs in release, and BLS_RELEASE_PRIVATE_KEY mapped by name into both release-check and publish, so the App key never arrives empty. Every uses: is SHA-pinned with its tag (V04, V05). The release environment already passes release-check's own gate: no admin bypass, stable only, required reviewers, no self-review (V06).

🟢 What reaches stable is exactly what was reviewed, and it builds as 1.0.10

The head is the dev tip, and its tree is byte-identical to 6d0dc6c, approved in #17 (V09). uv build gives an sdist and a wheel with Version 1.0.10, License-Expression AGPL-3.0-or-later and Requires-Python >=3.10, and v1.0.10 is neither tagged nor on PyPI yet (V03, V08).

📝 Evidence: the PyPI trusted publisher for trevorproxy

The publisher must name this repository, publish.yml and the release environment. I can't read PyPI's settings. Attach the project's publisher list here, showing exactly one entry, and confirm that any API token from the hand-published 1.0.9 is revoked.

Reproduce this review
# save the script below as verify-18.sh and the patch as control-18.patch, then:
bash verify-18.sh blacklanternsecurity/TREVORproxy 27075459907b47f6af577c0d8325d55066c74adc
# expected: SUMMARY 6 PASS, 3 FAIL, 0 SKIP, 0 BROKEN  (V01 V02 V07 FAIL)
# control:  bash verify-18.sh blacklanternsecurity/TREVORproxy 27075459907b47f6af577c0d8325d55066c74adc "$PWD/control-18.patch"
#           -> V01 PASS, V03 V04 V05 V08 V09 FAIL (SUMMARY 2 PASS, 7 FAIL, 0 SKIP, 0 BROKEN)
# V02, V06 and V07 read GitHub state, so the patch doesn't move them. V08 needs uv 0.11.20 on PATH, or it skips.
#!/usr/bin/env bash
# verify-18.sh: reproducible checks for blacklanternsecurity/TREVORproxy#18 (Release 1.0.10, dev -> stable)
# Usage: bash verify-18.sh <owner/repo> <sha> [<control-patch>]
# Changes nothing outside a mktemp directory and nothing on GitHub (PR-VF-02).
#
# CONTROL: patch control-18.patch
# CONTROL-EXPECT: V01=PASS V03=FAIL V04=FAIL V05=FAIL V08=FAIL V09=FAIL
# AUTHOR-CODE: none
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 --version 2>&1 | cut -d' ' -f2)"

RW_SHA=4f32510b1cdfe7305aa27daa3f6fd72e4c03c21b   # release-workflows v1.5.0, the pin in publish.yml
REVIEWED=6d0dc6cd5da381ed8f3e553b5dc5fe2bc1551488 # #17 round 2 head (APPROVE)
UV_VERSION=0.11.20

WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT
export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 GIT_TERMINAL_PROMPT=0
export GIT_CONFIG_COUNT=2 GIT_CONFIG_KEY_0=credential.helper GIT_CONFIG_VALUE_0= GIT_CONFIG_KEY_1=credential.helper GIT_CONFIG_VALUE_1='!gh auth git-credential'
GIT=(git)
"${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

# ---- checks: each line states the desired property --------------------------

# V01: CODEOWNERS names only @blacklanternsecurity/development-leads for every path
#      (publishing.md 1.9.1 D15: a repository joining the gate after 1.9.0 names development-leads only)
OWN=$(grep -v '^[[:space:]]*#' .github/CODEOWNERS | grep -v '^[[:space:]]*$')
if [ "$OWN" = "* @blacklanternsecurity/development-leads" ]; then pass V01 "CODEOWNERS names development-leads only"
else fail V01 "CODEOWNERS names development-leads only" "rules: $(echo "$OWN" | tr '\n' ';')"; fi

# V02: every first-parent commit on stable since the latest v* tag arrived through a PR merged into stable,
#      judged by release-workflows provenance.py's own violations() and lookups (run by release-check on merge)
if gh api --method GET "repos/blacklanternsecurity/release-workflows/contents/scripts/provenance.py?ref=$RW_SHA" \
     -H "Accept: application/vnd.github.raw+json" > "$WORK/provenance.py" 2>/dev/null && [ -s "$WORK/provenance.py" ]; then
  R02=$(cd "$WORK" && python3 -I - "$WORK/src" "$REPO" <<'PY'
import os, sys, importlib.util
spec = importlib.util.spec_from_file_location("provenance", os.path.join(os.getcwd(), "provenance.py"))
p = importlib.util.module_from_spec(spec); spec.loader.exec_module(p)
root, repo = sys.argv[1], sys.argv[2]
tag = p.previous_tag(root, "v*")
# The merge of this PR adds one commit (associated with #18, merged into stable) on top of origin/stable;
# every older first-parent commit stays on the line release-check walks.
commits = p.git(root, "rev-list", "--first-parent", f"{tag}..origin/stable").split()
bad = p.violations(commits, p.gh_merged_pr(repo, "stable"), lambda s: [f for f in p.git(root, "diff-tree", "--no-commit-id", "--name-only", "-r", "-m", s).splitlines() if f], [])
print(f"{tag} {len(commits)} {len(bad)} " + " ".join(s[:8] for s, _ in bad))
PY
  )
  set -- $R02
  if [ -z "${1:-}" ]; then broken V02 "provenance passes" "script error"
  elif [ "${3:-x}" = 0 ]; then pass V02 "all $2 first-parent commits on stable since $1 came through PRs merged into stable"
  else fail V02 "all first-parent commits on stable since $1 came through PRs merged into stable" "$3 of $2 would fail release-check provenance: ${*:4}"; fi
else skip V02 "provenance passes" "could not fetch provenance.py at $RW_SHA"; fi

# V03: the release-check would release: pyproject version has no tag and no PyPI release yet
VER=$(python3 -I -c 'import tomllib,sys;print(tomllib.load(open("pyproject.toml","rb"))["project"]["version"])' 2>/dev/null)
TAGHIT=$(git tag --list "v$VER")
PYPI=$(curl -s -o /dev/null -w '%{http_code}' "https://pypi.org/pypi/trevorproxy/$VER/json")
if [ "$VER" = "1.0.10" ] && [ -z "$TAGHIT" ] && [ "$PYPI" = 404 ]; then pass V03 "version 1.0.10, no v1.0.10 tag, not on PyPI"
else fail V03 "version 1.0.10, no v1.0.10 tag, not on PyPI" "version=$VER tag=${TAGHIT:-none} pypi=$PYPI"; fi

# V04: every uses: in .github/workflows is a 40-hex SHA (or a local ./ path) with a tag comment
BADPIN=$(grep -hE '^[[:space:]]*(-[[:space:]]*)?uses:' .github/workflows/*.yml | grep -vE 'uses:[[:space:]]*\./' | grep -vE '@[0-9a-f]{40}[[:space:]]+#[[:space:]]*v[0-9]')
if [ -z "$BADPIN" ]; then pass V04 "every action and reusable workflow is SHA-pinned with a version comment"
else fail V04 "every action and reusable workflow is SHA-pinned with a version comment" "$(echo "$BADPIN" | tr -s ' ' | tr '\n' ';')"; fi

# V05: publish.yml: top-level permissions {}; only the pypi job holds id-token: write and it runs in the release
#      environment; check and release both map BLS_RELEASE_PRIVATE_KEY by name
R05=$(python3 -I - <<'PY'
import re
t = open(".github/workflows/publish.yml").read()
jobs = re.split(r"\n  (?=[a-z]+:\n)", t.split("\njobs:\n", 1)[1])
j = {b.split(":", 1)[0].strip(): b for b in jobs}
errs = []
if not re.search(r"^permissions: \{\}$", t, re.M): errs.append("top permissions")
for n, b in j.items():
    if "id-token: write" in b and n != "pypi": errs.append(f"{n} has id-token")
if "environment: release" not in j.get("pypi", "") or "id-token: write" not in j.get("pypi", ""): errs.append("pypi env/oidc")
for n in ("check", "release"):
    if "BLS_RELEASE_PRIVATE_KEY: ${{ secrets.BLS_RELEASE_PRIVATE_KEY }}" not in j.get(n, ""): errs.append(f"{n} key mapping")
print(",".join(errs) or "ok")
PY
)
if [ "$R05" = ok ]; then pass V05 "publish.yml: permissions {}, OIDC only in the release-env pypi job, key mapped in check and release"
else fail V05 "publish.yml: permissions {}, OIDC only in the release-env pypi job, key mapped in check and release" "$R05"; fi

# V06: the release environment passes release-check's own test: no admin bypass, stable only, reviewers, no self-review
ENVJ=$(gh api --method GET "repos/$REPO/environments/release" 2>/dev/null)
POL=$(gh api --method GET "repos/$REPO/environments/release/deployment-branch-policies" --jq '[.branch_policies[] | "\(.type // "branch"):\(.name)"] | sort | join(",")' 2>/dev/null)
if [ -z "$ENVJ" ]; then skip V06 "release environment protected" "environment unreadable"
else R06=$(echo "$ENVJ" | python3 -I -c '
import json,sys; e=json.load(sys.stdin); r=[p for p in e.get("protection_rules",[]) if p["type"]=="required_reviewers"]
print("ok" if e.get("can_admins_bypass") is False and e["deployment_branch_policy"] and e["deployment_branch_policy"].get("custom_branch_policies") and r and r[0]["reviewers"] and r[0].get("prevent_self_review") else "bad")')
  if [ "$R06" = ok ] && [ "$POL" = "branch:stable" ]; then pass V06 "release environment: no admin bypass, stable only, required reviewers, no self-review"
  else fail V06 "release environment protected as release-check requires" "env=$R06 policies=$POL"; fi
  # V07: its reviewers name development-leads only (D15, joining after 1.9.0)
  REV=$(echo "$ENVJ" | python3 -I -c 'import json,sys;e=json.load(sys.stdin);print(",".join(sorted(x["reviewer"].get("slug") or x["reviewer"].get("login") for p in e["protection_rules"] if p["type"]=="required_reviewers" for x in p["reviewers"])))')
  if [ "$REV" = "development-leads" ]; then pass V07 "release environment reviewers: development-leads only"
  else fail V07 "release environment reviewers: development-leads only" "reviewers=$REV"; fi
fi

# V08: the sdist and wheel build with a pinned uv, and the wheel's metadata carries Version 1.0.10,
#      License-Expression AGPL-3.0-or-later and Requires-Python >=3.10
if command -v uv >/dev/null && [ "$(uv --version | cut -d' ' -f2)" = "$UV_VERSION" ]; then
  echo "uv $UV_VERSION"
  export UV_CACHE_DIR="$WORK/uvcache" UV_NO_CONFIG=1 UV_PYTHON_INSTALL_DIR="$WORK/uvpy"
  if uv build --quiet --out-dir "$WORK/dist" . >"$WORK/build.log" 2>&1; then
    WHL=$(ls "$WORK"/dist/*.whl 2>/dev/null | head -1)
    META=$(python3 -I -c 'import zipfile,sys;z=zipfile.ZipFile(sys.argv[1]);n=[x for x in z.namelist() if x.endswith(".dist-info/METADATA")][0];print(z.read(n).decode())' "$WHL")
    V=$(echo "$META" | sed -n 's/^Version: //p'); L=$(echo "$META" | sed -n 's/^License-Expression: //p'); RP=$(echo "$META" | sed -n 's/^Requires-Python: //p')
    if [ "$V" = 1.0.10 ] && [ "$L" = "AGPL-3.0-or-later" ] && [ "$RP" = ">=3.10" ] && ls "$WORK"/dist/*.tar.gz >/dev/null 2>&1; then pass V08 "uv build: sdist + wheel, Version 1.0.10, AGPL-3.0-or-later, >=3.10"
    else fail V08 "uv build: sdist + wheel, Version 1.0.10, AGPL-3.0-or-later, >=3.10" "Version=$V License=$L Requires-Python=$RP"; fi
  else fail V08 "uv build succeeds" "$(tail -3 "$WORK/build.log" | tr '\n' ' ')"; fi
else skip V08 "uv build" "uv $UV_VERSION not on PATH"; fi

# V09: the files being promoted are byte-identical to the head approved in #17 round 2
if "${GIT[@]}" cat-file -e "$REVIEWED^{commit}" 2>/dev/null && git diff --quiet "$REVIEWED" -- . 2>/dev/null; then pass V09 "promoted tree equals the #17 round 2 approved head ${REVIEWED:0:8}"
else fail V09 "promoted tree equals the #17 round 2 approved head ${REVIEWED:0:8}" "$(git diff --stat "$REVIEWED" -- . 2>/dev/null | tail -1)"; fi

# ------------------------------------------------------------------------------
summary
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index bce0a9b..63e78ea 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -1,2 +1,2 @@
-# Every change needs an approval from a lead (development-leads or bbot-leads) before it reaches stable (.github-config docs/policy/publishing.md 1.8.0).
-* @blacklanternsecurity/bbot-leads @blacklanternsecurity/development-leads
+# Every change needs an approval from a lead before it reaches stable.
+* @blacklanternsecurity/development-leads
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 224261f..dfff94d 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -33,7 +33,7 @@ jobs:
     permissions:
       contents: read
     steps:
-      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+      - uses: actions/checkout@v7
         with:
           persist-credentials: false
       - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
@@ -67,8 +67,6 @@ jobs:
     permissions:
       contents: read
     uses: blacklanternsecurity/release-workflows/.github/workflows/publish.yml@4f32510b1cdfe7305aa27daa3f6fd72e4c03c21b # v1.5.0
-    secrets:
-      BLS_RELEASE_PRIVATE_KEY: ${{ secrets.BLS_RELEASE_PRIVATE_KEY }}
     with:
       tag: ${{ needs.check.outputs.tag }}
       version: ${{ needs.check.outputs.version }}
diff --git a/pyproject.toml b/pyproject.toml
index 6ca3501..72ee2a5 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,9 +1,9 @@
 [project]
 name = "trevorproxy"
-version = "1.0.10"
+version = "1.0.9"
 description = "Rotate your source IP address via SSH proxies and other methods"
 authors = [{ name = "TheTechromancer" }]
-license = "AGPL-3.0-or-later"
+license = "MIT"
 requires-python = ">=3.10"
 dependencies = ["sh>=2.2.4,<3"]
 

contents: read
actions: read
pull-requests: read
uses: blacklanternsecurity/release-workflows/.github/workflows/release-check.yml@4f32510b1cdfe7305aa27daa3f6fd72e4c03c21b # v1.5.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 release-check v1.5.0 runs provenance.py here. All 9 first-parent commits on stable since v1.0.9 have no PR merged into stable (7 direct pushes; #13 and #14 still report base master), so the run stops before build. A provenance baseline option, or a one-off direct-push-paths the approving lead accepts knowingly.

Comment thread .github/CODEOWNERS
@@ -0,0 +1,2 @@
# Every change needs an approval from a lead (development-leads or bbot-leads) before it reaches stable (.github-config docs/policy/publishing.md 1.8.0).
* @blacklanternsecurity/bbot-leads @blacklanternsecurity/development-leads

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Policy 1.9.1 D15: a repository joining the gate after 1.9.0 names development-leads only. * @blacklanternsecurity/development-leads.

@pjhartlieb pjhartlieb closed this Dec 3, 2026
@pjhartlieb pjhartlieb reopened this Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants