Skip to content

Reverse Engineering / Authorized Penetration Testing / Security Research Skill Router Pack AI-powered routing + On-demand toolchain bootstrapping + Self-evolving knowledge base Supports Claude Code, Kiro, Cursor, Cline, and other AI coding clients 逆向/渗透/安全技能路由包 - AI 自动路由 + 按需自举工具链 + 自动进化经验库 | 支持 Claude Code / Kiro / Cursor / Cline 等代码 AI 客户端

Shell

test: cover pwntools no-terminal version output

zhaoxuya52081c60d873675
diff --git a/docs/plans/2026-09-21-pwntools-kali-discovery.md b/docs/plans/2026-09-21-pwntools-kali-discovery.md
index 026e4c6..b3f2d66 100644
--- a/docs/plans/2026-09-21-pwntools-kali-discovery.md
+++ b/docs/plans/2026-09-21-pwntools-kali-discovery.md
@@ -4,7 +4,7 @@
**Goal:** Preserve PR #144 contributor provenance and complete pwntools discovery, version reporting, capability visibility, bootstrap listing, manifest verification, and CI coverage while keeping Kali and client-neutral indexes on the real `pwn version` CLI contract.
-**Architecture:** Treat the original PR head as the integration baseline, then drive both real refresh paths through strict hermetic `pwn` stubs that accept only the `version` subcommand. Make only targeted catalog, client-neutral index, capability-list, help-list, manifest, and workflow changes; avoid broader manifest-generation refactors.
+**Architecture:** Treat the original PR head as the integration baseline, then drive both real refresh paths through strict hermetic `pwn` stubs that accept only the `version` subcommand and reproduce the real no-terminal warning unless the probe sets `PWNLIB_NOTERM=1`. Make only targeted catalog, client-neutral index, capability-list, help-list, manifest, and workflow changes; avoid broader manifest-generation refactors.
**Tech Stack:** Bash, JSON, Python 3 assertions, GitHub Actions YAML, Git.
@@ -125,7 +125,7 @@ Change the #144 row to:
"pwntools|reverse-engineering|CTF pwn 利用开发框架|version|pwn"
```
-Change the client-neutral catalog version command from `pwn --version` to `pwn version`, and make its version runner pass only populated arguments rather than an extra empty placeholder. Both indexes must invoke the stub with exactly one argument and record the first merged stdout/stderr line from the real CLI contract, `[*] Pwntools v4.15.0`.
+Change the client-neutral catalog version command from `pwn --version` to `pwn version`, and make its version runner pass only populated arguments rather than an extra empty placeholder. Both indexes must invoke the stub with exactly one argument and record the first merged stdout/stderr line from the real CLI contract, `[*] Pwntools v4.15.0`. Preserve the generic runner's previous empty-spec semantics: parse and invoke a version specification only when it is both non-empty and not `none`.
**Step 2: Add capability visibility**
@@ -224,6 +224,40 @@ git log --oneline --decorate origin/main..HEAD
Expected: clean worktree; #144 head is an ancestor; design, merge, test, and implementation commits are visible.
+### Task 4a: Add the no-terminal warning RED regression
+
+**Objective:** Reproduce pwntools 4.15.0's successful no-`TERM` warning path and prove both production version probes must set `PWNLIB_NOTERM=1` locally.
+
+**Files:**
+- Modify: `kali/scripts/test-pwntools-discovery.sh`
+- Modify: `skills/scripts/test-client-neutral-bootstrap.sh`
+- Modify: `docs/superpowers/specs/2026-09-21-pwntools-kali-discovery-design.md`
+- Modify: `docs/plans/2026-09-21-pwntools-kali-discovery.md`
+
+**Step 1: Strengthen both strict stubs**
+
+After validating exactly one `version` argument, have each stub emit `Warning: _curses.error: setupterm: could not find terminfo database` to stderr when `${PWNLIB_NOTERM:-}` is not `1`, followed by `[*] Pwntools v4.15.0`. With `PWNLIB_NOTERM=1`, emit only the version line. Continue to reject unknown argument shapes with exit 64. Around the refresh under test, unset inherited `TERM` and `PWNLIB_NOTERM`; this fixes the no-terminal precondition without preventing production from setting `PWNLIB_NOTERM=1` locally on the child probe.
+
+Keep the generated version assertions exactly `[*] Pwntools v4.15.0`; do not accept, strip, or skip the warning in test code.
+
+**Step 2: Verify focused RED**
+
+Run:
+
+```bash
+bash kali/scripts/test-pwntools-discovery.sh
+PYTHONOPTIMIZE=1 bash kali/scripts/test-pwntools-discovery.sh
+bash skills/scripts/test-client-neutral-bootstrap.sh
+```
+
+Expected: all three invocations fail because the current production probes capture the warning as the version. The diagnostics must report the warning as the actual value, demonstrating that production needs a probe-local `PWNLIB_NOTERM=1` setting.
+
+**Step 3: Verify non-behavioural gates and commit RED**
+
+Run Bash syntax checks for both changed tests, repository-security and documentation-link checks, parse tracked JSON and YAML, and inspect the diff. Do not change production in this commit. Commit only the four files above as `test: cover pwntools no-terminal version output`.
+
+The later GREEN change must scope `PWNLIB_NOTERM=1` to the real `pwn version` process in both runners. It must not export the variable for ordinary commands or availability checks, and the generic client-neutral runner must retain the empty-version-spec behaviour described in Task 3.
+
### Task 5: Review, publish, CI, and integrate
**Objective:** Obtain independent review, publish safely, and update `main` only after green CI.
diff --git a/docs/superpowers/specs/2026-09-21-pwntools-kali-discovery-design.md b/docs/superpowers/specs/2026-09-21-pwntools-kali-discovery-design.md
index 13005c3..a89e48f 100644
--- a/docs/superpowers/specs/2026-09-21-pwntools-kali-discovery-design.md
+++ b/docs/superpowers/specs/2026-09-21-pwntools-kali-discovery-design.md
@@ -13,7 +13,7 @@ Integrate #144 while preserving its contributor commit, then complete the Kali-f
3. The generated capability table includes `pwntools`, reports runtime availability through `pwn`, and identifies its installer as `pip-package`.
4. `bootstrap-reverse.sh --list` and its human-readable help include `pwntools`.
5. Both bootstrap manifests use the executable command `pwn` for post-install verification.
-6. Both Kali and client-neutral index regressions exercise the real `pwn version` CLI contract without installing pwntools or touching the host environment.
+6. Both Kali and client-neutral index regressions exercise the real `pwn version` CLI contract without installing pwntools or touching the host environment, including its no-terminal warning behaviour.
## Non-goals
@@ -26,7 +26,7 @@ Integrate #144 while preserving its contributor commit, then complete the Kali-f
### Tool catalog
-Keep the #144 catalog entry but use the `version` subcommand and the executable fallback `pwn`. The logical tool name remains `pwntools`; the resolved executable is `pwn`. Pwntools 4.15.0 exposes its version through `pwn version`; `pwn --version` is not a valid equivalent and exits non-zero.
+Keep the #144 catalog entry but use the `version` subcommand and the executable fallback `pwn`. The logical tool name remains `pwntools`; the resolved executable is `pwn`. Pwntools 4.15.0 exposes its version through `pwn version`; `pwn --version` is not a valid equivalent and exits non-zero. In an environment without `TERM`, the real command can exit successfully but write a `_curses.error: setupterm` warning before its version line. Set `PWNLIB_NOTERM=1` locally for this version probe so the captured first line remains the version. This environment override belongs only to the probe invocation; it must not change ordinary pwntools commands or executable-availability detection.
Expected generated record:
@@ -53,9 +53,9 @@ Add a hermetic Bash test under `kali/scripts/` that:
5. Asserts `bootstrap-reverse.sh --list` advertises pwntools.
6. Parses both manifests and asserts `verifyCommand == "pwn"`.
-The `pwn` fixture accepts exactly one argument, `version`, writes the exact real CLI line `[*] Pwntools v4.15.0` to stderr, and fails every other invocation. This prevents the invalid `pwn --version` spelling from passing through a permissive stub. The test must not invoke package installation, network access, client configuration, or repository output paths.
+The `pwn` fixture accepts exactly one argument, `version`, and fails every other invocation. For a valid call it first writes the stable simulated no-terminal warning `Warning: _curses.error: setupterm: could not find terminfo database` unless `PWNLIB_NOTERM=1`, then writes the exact real CLI line `[*] Pwntools v4.15.0` to stderr. Each test unsets inherited `TERM` and `PWNLIB_NOTERM` around its refresh invocation, making the no-terminal precondition deterministic while still allowing production to set the variable on the child probe. This both prevents the invalid `pwn --version` spelling from passing through a permissive stub and proves that each production version probe sets the suppression variable locally. The generated version assertion stays exact, so an unsuppressed warning is recorded as the first line and produces a focused RED failure.
-The same executable has one version-command contract on every supported host path. Therefore the minimum change also updates `skills/scripts/refresh-tool-index.sh` from `pwn --version` to `pwn version`, ensures its version runner does not append empty placeholder arguments, and extends the existing `skills/scripts/test-client-neutral-bootstrap.sh` regression with the same strict stub and generated-record assertions.
+The same executable has one version-command contract on every supported host path. Therefore the minimum change also updates `skills/scripts/refresh-tool-index.sh` from `pwn --version` to `pwn version`, ensures its version runner does not append empty placeholder arguments, and extends the existing `skills/scripts/test-client-neutral-bootstrap.sh` regression with the same strict stub and generated-record assertions. Both production paths must run this particular probe with `PWNLIB_NOTERM=1`; the setting must not be exported globally.
### CI wiring
@@ -69,6 +69,8 @@ Run the new regression in the existing Ubuntu Bash CI job after shell syntax val
4. Re-run both focused tests until green.
5. Run Bash syntax, bootstrap-manifest, routing, repository-security, document-link, JSON, YAML, UTF-8/BOM and mojibake checks.
+For the no-terminal follow-up, first strengthen both strict stubs as described above and preserve the exact version assertions. Run the Kali regression in normal and Python-optimized modes plus the client-neutral regression and record RED failures whose actual version is the warning line. Commit only tests and documentation at this stage; production changes that add the probe-local `PWNLIB_NOTERM=1` follow in a separate GREEN commit.
+
## Integration and provenance
Create a merge commit whose second parent is the original #144 head, preserving contributor provenance. Add the completion changes as a separate maintainer commit. Push only after local verification; wait for GitHub CI before fast-forwarding `main`. No force-push is permitted.
@@ -76,5 +78,5 @@ Create a merge commit whose second parent is the original #144 head, preserving
## Failure handling
- A missing `pwn` command must produce an unavailable pwntools record without aborting refresh.
-- A failing `pwn version` command may leave the version empty or record its first stderr diagnostic line, consistent with existing non-blocking discovery behaviour, but detection remains based on executable presence.
+- A failing `pwn version` command may leave the version empty or record its first stderr diagnostic line, consistent with existing non-blocking discovery behaviour, but detection remains based on executable presence. The known successful no-terminal warning is prevented with probe-local `PWNLIB_NOTERM=1`, rather than filtered from output.
- Any CI failure blocks integration into `main`.
diff --git a/kali/scripts/test-pwntools-discovery.sh b/kali/scripts/test-pwntools-discovery.sh
index a9e522d..fe42d15 100755
--- a/kali/scripts/test-pwntools-discovery.sh
+++ b/kali/scripts/test-pwntools-discovery.sh
@@ -223,6 +223,9 @@ if [[ $# -ne 1 || "$1" != "version" ]]; then
printf '\n' >&2
exit 64
fi
+if [[ "${PWNLIB_NOTERM:-}" != "1" ]]; then
+ printf '%s\n' 'Warning: _curses.error: setupterm: could not find terminfo database' >&2
+fi
printf '%s\n' '[*] Pwntools v4.15.0' >&2
STUB
chmod +x "$BIN_DIR/pwn"
@@ -233,6 +236,7 @@ chmod +x "$BIN_DIR/pwn"
# or execute an untracked repository-root command.
(
cd "$WORK_DIR"
+ unset TERM PWNLIB_NOTERM
env PATH="$BIN_DIR" HOME="$HOME_DIR" \
"$REAL_BASH" "$REFRESH" "$OUTPUT_MD" "$OUTPUT_JSON" >/dev/null
)
diff --git a/skills/scripts/test-client-neutral-bootstrap.sh b/skills/scripts/test-client-neutral-bootstrap.sh
index a912ac8..2ce7d58 100644
--- a/skills/scripts/test-client-neutral-bootstrap.sh
+++ b/skills/scripts/test-client-neutral-bootstrap.sh
@@ -41,6 +41,9 @@ if [[ $# -ne 1 || "$1" != "version" ]]; then
printf '\n' >&2
exit 64
fi
+if [[ "${PWNLIB_NOTERM:-}" != "1" ]]; then
+ printf '%s\n' 'Warning: _curses.error: setupterm: could not find terminfo database' >&2
+fi
printf '%s\n' '[*] Pwntools v4.15.0' >&2
STUB
chmod +x "$BIN_DIR/pwn"
@@ -53,7 +56,10 @@ export CODEX_CONFIG_PATH="$CODEX_CFG"
MD="$SCRATCH/tool-index.md"
JSON="$SCRATCH/tool-index.json"
-PATH="$BIN_DIR" "$BIN_DIR/bash" "$REFRESH" "$MD" "$JSON" >/dev/null
+(
+ unset TERM PWNLIB_NOTERM
+ PATH="$BIN_DIR" "$BIN_DIR/bash" "$REFRESH" "$MD" "$JSON" >/dev/null
+)
python3 - "$JSON" "$BIN_DIR/ghidra" "$BIN_DIR/pwn" <<'PY'
import json, os, sys