Skip to content

Integrate #1063 and #1065, and back-port the v1 fixes stranded on dev-go - #1066

Draft
six2dez wants to merge 12 commits into
devfrom
integrate/prs-1063-1065
Draft

six2dez wants to merge 12 commits into
devfrom
integrate/prs-1063-1065

Conversation

@six2dez

@six2dez six2dez commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Integrates the two open contributor PRs and back-ports the v1 bash fixes that were sitting on dev-go, where v1 users never get them.

dev was 2 commits behind main with an identical tree, so this branch is based on main and merges cleanly into dev.

The reason this is more than two PRs

reconftw.sh ran a bare set +e, and ~20 bats suites source it from their own setup(). Errexit was therefore off inside every test body, so only a test's last command decided the verdict — every earlier assertion was inert. Both PRs arrived with green suites that were not actually asserting.

Restoring errexit (back-ported from dev-go) turned up one real defect in each area, and a second root cause behind both.

Contributor PRs

#1063 — Slack files.upload sunset (@torrresagus)

Verified the three-step flow against docs.slack.dev: getUploadURLExternal takes filename + length and returns upload_url + file_id; completeUploadExternal accepts files, channels (comma-separated, alongside the singular channel_id) and initial_comment. The PR matches the documented contract.

Two gaps closed:

  • Only the first step's result was checked. A file that uploaded but was never shared to the channel looked exactly like a success — the one failure an operator relying on these notifications would miss. Its ok is now checked and Slack's error reported.
  • The PR carried no test because no Slack mock existed. tests/unit/test_slack_upload.bats adds nine cases, all mutation-checked: pointing step one back at files.upload, dropping the ok-check, renaming channels=, sending a wrong byte length, swapping the raw POST for -F, or ignoring the returned file_id each turn the suite red.

#1065 — DarkEye domain exposure (@juanmill4)

Opt-in, metadata-only, off by default, with good docs and an honest "not run against the live APIs". Three fixes:

  • The target guard was bypassable. It enumerated bad characters as [/?*@:], which omits ;. example.com;echo passed it, sanitize_domain quietly rewrote it to example.comecho, validate_domain accepted that, and the lookup queried DarkEye for a domain the operator never named. The guard now requires sanitization to be a no-op against the lower-cased input, which covers ;, &, |, $, backticks and spaces without enumerating any of them, and still accepts EXAMPLE.COM. This is what the "wildcards, URLs and IPs are rejected" case asserts now — it was red before the fix.
  • The API keys were not redacted. darkeye_exposure's body is a subshell (it needs its own umask and EXIT trap), so its register_secret() call never reached REGISTERED_SECRETS in the parent. Both names are now in REDACT_VARS, which resolves by name and so works regardless.
  • curl's stderr went to /dev/null instead of $LOGFILE, unlike every other tool call in the tree.

Also: comments translated to English, and the README section moved out from under "Star History" into its own section with a ToC entry.

#1048 — already merged, should be closed

Both of its commits (cece45fd, 6cbabe06) are ancestors of main via merge 6324bddb, and the PROXYCHAINS_EXCLUDE follow-up ca86b6a7 is in too. Its base branch fix/main-open-issues went in as #1047. Nothing left to merge.

Back-ported from dev-go

  • 7be831c9 — the errexit restore plus the five production bash bugs it exposed (msftrecon rc always 0, warn-once compared under the global IFS, run_command stored axiom commands one argument per line, grep -P on BSD, bash -lc rebuilding PATH with BSD tools first), the cached_download_typed dry-run cp that broke jsonl-strict, and the test_resolvers_hardening case that was overwriting the operator's real ~/Tools/resolvers.txt with a one-line mock.
  • fbdd5620 — GOTATOR_FLAGS, NUCLEI_EXTRA_ARGS, NUCLEI_DAST_EXTRA_ARGS and AXIOM_EXTRA_ARGS as arrays. Under the global IFS=$'\n\t' the old strings reached the tools as one argument, so those flags silently did nothing; _as_array keeps existing string configs working. Also interlace input sanitisation, the ffuf header via the environment, install.sh exiting non-zero when a tool failed to install, and the CI shellcheck gate at -S warning.

New in this branch

  • macos: put the GNU userland on PATH for --source-only too — the root cause behind two of the failures above. The Homebrew gnubin setup sat after the --source-only early return, so the suites loaded the modules and then ran them against the BSD userland, while CI's macos-smoke job puts gnubin on PATH itself. A GNU-only assumption could fail on a maintainer's Mac and pass in CI, or the reverse. Sourcing callers now get a warning instead of exit 1.
    • Exposed and fixed: incremental_diff built its INFO line from wc -l <file, which BSD wc pads, so macOS reported test: 1 new (previous: 1, total: 2).
  • scope: anchor deleteOutScoped to the whole host — an out-of-scope dev.example.com was deleted with an unanchored sed, so it also removed xdev.example.com, api.dev.example.com, dev.example.com.cdn.net and any URL with it in the path. In-scope assets vanished from subdomains.txt and webs.txt with nothing in the log. (fbdd5620 carries the same fix; this commit has the detailed rationale and landed first, so that hunk was already applied.)
  • tests: make the checkpoint guard actually hide nuclei, testssl and exiftool — its setup claimed an empty PATH dir made the real binaries unreachable. It does not: ~/go/bin/nuclei stayed on PATH, the "binary not found" branch never ran, and the file only passed on CI's toolless runner. Setup now drops every PATH entry that provides one and fails loudly if one survives.

Verification

Run on macOS (Darwin 27.2) against the final tree:

gate result
make lint (shellcheck -S error) rc=0
shellcheck -S warning (the gate fbdd5620 raises CI to) rc=0
unit suite (--unit, which now includes tests/security) 414 ok / 0 fail
executed vs declared @test 414 == 376 unit + 38 security
integration smoke 22 ok / 0 fail
unit suite with ~/go/bin, .pdtm, .cargo, osmedeus stripped (toolless-runner emulation) 414 ok / 0 fail
~/Tools/resolvers.txt / resolvers_trusted.txt unchanged (169315 / 328 bytes)
stray files in the repo root none

The nine Slack cases and the DarkEye target guard are mutation-checked, not just green.

six2dez and others added 12 commits September 22, 2026 08:09
Integrate #1047 + #1048, unblock their CI, and close #1049(part)/#1050
Merge dev into main: bump subfinder pin to v2.16.0 (#1062)
reconftw.sh runs `set +e`, so the ~20 suites that source it from their own
setup() lost errexit and only a test's LAST command decided the verdict (an
explicit `return 1` mid-test still reported ok). With --source-only the
script now restores the caller's errexit. 33 tests went red. Five were real
bugs in production bash:

- osint: `if ! msftrecon; then rc=$?` always recorded 0.
- core: the missing-tool warn-once check compared " ${missing[*]} " under
  the global IFS, so it never matched and warned every time.
- utils: run_command stored the axiom-disabled command with one argument
  per line ("${cmd[*]}" under IFS=$'\n\t').
- web/vulns: grep -P is not available in BSD grep (macOS).
- common: run_with_heartbeat_shell used `bash -lc`; the login shell rebuilt
  PATH with BSD tools ahead of GNU ones.

The rest were hidden test defects (stale interlace mocks, real tools
reached through ~/go/bin, arrays declared local from setup(), negated
commands that errexit ignores, after_each instead of teardown) and the
sanitize_domain injection tests, which asserted on stderr; they now assert
stdout is exactly the neutralised host with no metacharacter.

Also:
- cached_download_typed no longer copies a file that dry-run never
  downloaded; the cp error broke --log-format jsonl-strict (the weekly
  integration-full job has failed on this since March).
- test_resolvers_hardening re-pins CACHE_DIR, tools and resolver paths
  after sourcing reconftw.cfg; it was overwriting the operator's real
  ~/Tools/resolvers.txt with a one-line mock.
- Tests no longer leave files in the repository root.
The modules assume GNU behaviour (`wc -l` without padding, `stat -c`, GNU
`sed -i`, `grep -P`), but the Homebrew gnubin PATH setup sat *after* the
--source-only early return, so the bats suites loaded the modules and then
ran them against the BSD userland. CI's macos-smoke job puts gnubin on PATH
itself, so this diverged in both directions: a GNU-only assumption could
fail on the maintainer's Mac and pass in CI, or pass locally and fail there.

The block is now a function called from both paths. Sourcing callers get a
warning instead of `exit 1`, because killing the caller's shell is worse
than running with whatever is on PATH.

Exposed by this, and fixed: incremental_diff built its INFO line from
`wc -l <file`, which BSD wc pads, so macOS reported "test:        1 new
(previous:        1, total:        2)". It now uses count_lines(), which
already strips the padding.
An out-of-scope entry was deleted with an unanchored `sed "/${escaped}/d"`,
so "dev.example.com" in the out-of-scope list also removed every line that
merely CONTAINED it: xdev.example.com, api.dev.example.com,
dev.example.com.cdn.net, and any URL with it in the path. In-scope assets
disappeared from subdomains.txt and webs.txt with nothing in the log to say
why, and wildcard entries had the same problem with a `$` anchor on the tail
only.

Entries are now anchored to the whole hostname with an ERE that tolerates
the optional scheme, port and path the callers pass (subdomains.txt is a
host list, webs.txt and arjun are URL lists). "*.example.com" keeps its
suffix semantics. Matching is case-insensitive, and a file emptied of every
line is a valid outcome rather than a grep failure.

The three anchoring cases in tests/security/test_injection.bats cover it;
they came in with the assertion restore and were red until now.
Slack retired `files.upload` on November 12, 2025, so `sendToNotify()` now uploads files to Slack in three steps. It calls `files.getUploadURLExternal` with the filename and byte length, POSTs the raw bytes to the returned `upload_url`, and finishes with `files.completeUploadExternal` (sending `files`, `channels` and `initial_comment`). If no upload URL comes back it prints a warning, and it skips that warning in dry-run mode. I also added a CHANGELOG entry. Nothing was run: no `make lint`, `shellcheck` or bats tests, and no live Slack upload.

Notice slack-files-upload-sunset about slack.com's API describes the change. It was read from a file and is not signed by the provider.
…e keys

Adapting #1065 (thanks @juanmill4). Three things the PR's own 15 tests could
not see, because reconftw.sh's `set +e` had made every bats assertion but a
test's last command inert:

- The target guard enumerated bad characters as [/?*@:], which omits ';'.
  "example.com;echo" therefore passed it, sanitize_domain quietly rewrote it
  to "example.comecho", validate_domain accepted that, and the lookup queried
  DarkEye for a domain the operator never named. The guard now requires
  sanitization to be a no-op against the lower-cased input, which covers ';',
  '&', '|', '$', backticks and spaces without enumerating any of them, while
  still accepting "EXAMPLE.COM". This is what the "wildcards, URLs and IPs are
  rejected" case actually asserts now; it was red before this change.

- darkeye_exposure's body is a subshell, so its register_secret() call never
  reached REGISTERED_SECRETS in the parent and the API keys were not redacted
  from logs or dry-run previews. Both names are now in REDACT_VARS, which
  resolves by name and so works regardless of the subshell.

- curl's stderr went to /dev/null instead of $LOGFILE, unlike every other
  tool call in the tree.

Also: comments translated to English to match the rest of the codebase, and
the README section moved out from under "Star History" into its own section
before the license, with a table-of-contents entry.

Note for later: because the body is a subshell, end_func's record_func_timing
write is lost, so darkeye_exposure will not appear in the verbose timing
summary. The checkpoint itself is a file, so resume is unaffected.
Adapting #1063 (thanks @torrresagus). The three-step replacement for the
sunset files.upload matches Slack's documented contract -- verified against
docs.slack.dev: getUploadURLExternal takes filename and length and returns
upload_url and file_id, and completeUploadExternal accepts files, channels
(comma-separated, alongside the singular channel_id) and initial_comment.

Two gaps closed:

- Only the first step's result was checked. If completeUploadExternal failed,
  the file had uploaded but was never shared to the channel, and the run said
  nothing -- the exact failure an operator relying on these notifications
  would not notice. Its `ok` is now checked and the API's error reported.
  The upload-URL warning also names the error Slack returned.

- The PR carried no test, because there was no Slack mock to extend. There is
  one now: tests/unit/test_slack_upload.bats pins which endpoints are called
  and in what order, that the sunset endpoint is not among them, the real byte
  length and basename, the raw-octet-stream body rather than a multipart form,
  the returned file_id/channel/comment on the final step, both failure paths,
  that a dry run issues no request, and that the bot token is redacted.

All nine cases are mutation-checked: pointing step one back at files.upload,
dropping the ok-check, renaming channels=, sending a wrong length, swapping
the raw POST for -F, or ignoring the returned file_id each turn the suite red.
…on errors

- GOTATOR_FLAGS, NUCLEI_EXTRA_ARGS, NUCLEI_DAST_EXTRA_ARGS and
  AXIOM_EXTRA_ARGS are arrays. Under the global IFS=$'\n\t' the old strings
  reached the tools as ONE argument. _as_array keeps old string configs
  working.
- deleteOutScoped matches whole hostnames, so dev.example.com no longer
  removes xdev.example.com.
- interlace inputs are sanitised and the ffuf header is passed through the
  environment instead of the -c string.
- install.sh exits non-zero when any tool failed to install.
- tests/security runs with --unit and in CI; shellcheck runs at -S warning.
- Dead helpers and unused cfg variables removed.
…iftool

The setup comment claimed "empty PATH dir first so no real nuclei/testssl/
exifray is reachable", but prepending an empty directory hides nothing:
~/go/bin/nuclei stayed on PATH, so the "binary not found" branch never ran
and "nuclei_check runs again when DIFF=true" only passed on CI's toolless
runner. It was red on a provisioned box.

Every PATH entry that actually provides one of the three tools is now
dropped, and setup fails loudly if one is still reachable afterwards rather
than letting the file go quietly green against the real binaries.
…g` array

shellcheck tracks a name across the whole file, so a local string called
`missing` inside _init_gnu_path collided with the `missing` array used by the
dependency check and produced six SC2178/SC2128 warnings. Harmless at runtime,
but the CI gate is now -S warning, so it would have been red. Renaming is the
fix; a disable comment would only have hidden a genuinely confusing name reuse.

shellcheck -S warning is clean on reconftw.sh, modules/, lib/ and install.sh.

This branch has not been deployed

No deployments
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.

3 participants