Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- **`scripts/deploy-tollgate.sh`: cdk-cli 0.17.1 → 0.18.3, sha256-verified before install.** The download was the last unguarded cdk-cli fetch in the org (same class as tollgate-auth SECURITY_AUDIT_WINDOW3 M1: `curl -sL` straight to `/usr/local/bin` — a replaced GitHub release asset or build-path MITM would land in the wallet-running path undetected). The pinned SHA (`bb7a8b0f…`, x86_64) is cross-checked against the release's official `SHA256SUMS`; org-wide 0.18.3 alignment (tollgate-auth #30, cashu-audit #61). `tollgate/README.md` manual-install section mirrors the verified flow.

### Fixed
- **Backfill: the #51 security arc's user-visible changes (#53 review debt).** PR #51 restored the generated client's public enum classes (dropped in a regeneration — downstream `from shc_toolkit.generated…` imports had broken), made the cloudflared cache safe (user-owned dir, atomic unique-named download, never a shared-writable path), and landed the regression suites — but the changelog never recorded any of it. Enum contract pinned by `tests/test_generated_enum_contract.py`; cache behavior by `tests/test_tunnel_security.py` (both run in CI per the #56 entry below). Context: #51/#33/#34.
- **CI: regression test files outside every mandatory suite (#56).** `tests/test_generated_enum_contract.py` and `tests/test_tunnel_security.py` (both from the #51 security arc) were collected by neither `shc-tests.yml` (unit job ran only `tests/test_unit.py`) nor `coverage.yml` (the four legacy files) — enum/tunnel-cache regressions could pass CI unexecuted. Both files are now in both workflow commands, and the jobs install the `generated` extra (`attrs`, `python-dateutil`) the enum-contract file imports. AGENTS.md's mandated local suite updated to match.
- **typecheck.yml no longer ran on PRs at all (#58).** The trigger was `workflow_dispatch` + tag push only, so ruff/mypy config changes merged with no lint running. `pull_request` (targeting `main`) restored; stale "245 tests" verification figures in `pyproject.toml` and the 2026-07-24 CHANGELOG entry corrected to the actual collected count (491, `pytest tests/ --collect-only -q`).

Expand Down
41 changes: 37 additions & 4 deletions scripts/dev-zone-probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,24 @@
from shc_toolkit import create_client

PKG_ID = 80
PRICING_ID = 241
ORDER_FORM_ID = 11
PACKAGE_GROUP_ID = 14
MODULE_GROUP_ID = 7

# Valid (package, pricing) pairs on the order form (PR #35 review debt:
# pricing 241 belongs to package 80's tier — submitting package 81 with
# pricing 241 is an invalid pair the server rejects before probing).
# The pricing tier is DERIVED from the selected package; unknown packages
# are refused rather than paired with a wrong-tier pricing id.
PACKAGE_PRICING = {
80: 241, # daily
81: 245,
82: 249,
83: 253,
84: 257,
}
PRICING_ID = PACKAGE_PRICING[PKG_ID]


def _wait_tcp22(ip: str, timeout: int) -> tuple[bool, float]:
"""Poll TCP/22 until open or deadline. Returns (reachable, seconds_waited)."""
Expand Down Expand Up @@ -87,8 +100,8 @@ def main() -> int:
parser.add_argument(
"--pricing-id",
type=int,
default=PRICING_ID,
help="pricing tier (default 241 = daily)",
default=None,
help="pricing tier; derived from the package when omitted (241 = package 80 daily). Must agree with the derived value if given",
)
parser.add_argument(
"--net-timeout",
Expand All @@ -108,6 +121,26 @@ def main() -> int:
sid: int | None = None
t0 = time.time()

# Pricing tier is derived from the package; an explicit --pricing-id
# must agree with the derived value (anything else is an invalid pair
# the server rejects before probing — PR #35 review debt).
derived_pricing = PACKAGE_PRICING.get(args.package_id)
if derived_pricing is None:
print(
f"FATAL: package {args.package_id} has no known pricing tier "
f"(known: {', '.join(f'{k}->{v}' for k, v in sorted(PACKAGE_PRICING.items()))})",
file=sys.stderr,
)
sys.exit(2)
if args.pricing_id is not None and args.pricing_id != derived_pricing:
print(
f"FATAL: --pricing-id {args.pricing_id} does not match package "
f"{args.package_id}'s tier ({derived_pricing})",
file=sys.stderr,
)
sys.exit(2)
pricing_id = derived_pricing

def _cancel(*_args):
if sid:
try:
Expand All @@ -127,7 +160,7 @@ def _cancel(*_args):
try:
result = c.submit_order(
package_id=args.package_id,
pricing_id=args.pricing_id,
pricing_id=pricing_id,
order_form_id=ORDER_FORM_ID,
package_group_id=PACKAGE_GROUP_ID,
module_group_id=MODULE_GROUP_ID,
Expand Down
23 changes: 15 additions & 8 deletions shc_toolkit/tunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import logging
import os
import subprocess
import uuid
import time
from typing import TYPE_CHECKING

Expand Down Expand Up @@ -420,18 +421,24 @@ def _check_ssh(
def _find_cloudflared() -> str:
"""Find or download the cloudflared binary.

Search order: system installs, then the validated user cache. The
download lands in the user-owned cache dir via an atomic
temp-file-and-rename — never in a shared directory where another
local user could plant or swap the executable that connect_local()
runs (PR #33 review).
Search order: system installs first; only when none is found is the
user cache dir consulted (and created) — a missing/read-only/foreign-
owned cache dir must never shadow an already-installed binary (PR #51
review). The download lands in the user-owned cache dir via an
atomic temp-file-and-rename with a UNIQUE temp name per download —
never in a shared directory where another local user could plant or
swap the executable that connect_local() runs, and never on a shared
partial path two racing invocations would fight over (PR #33/#51
review).
"""
cached = os.path.join(_cloudflared_cache_dir(), "cloudflared")
for path in [*_CF_BINARY_PATHS, cached]:
for path in _CF_BINARY_PATHS:
if os.path.isfile(path) and os.access(path, os.X_OK):
return path
cached = os.path.join(_cloudflared_cache_dir(), "cloudflared")
if os.path.isfile(cached) and os.access(cached, os.X_OK):
return cached
log.info("Downloading cloudflared binary to %s ...", cached)
partial = cached + ".download"
partial = cached + f".download.{os.getpid()}.{uuid.uuid4().hex[:8]}"
subprocess.run(
["wget", "-q", "-O", partial, _CLOUDFLARED_URL],
check=True,
Expand Down
Loading