Skip to content

Incorporate spf-tools into postallow - #40

Merged
edmundlod merged 14 commits into
mainfrom
plans/incorporate-spf-tools
Sep 16, 2026
Merged

edmundlod merged 14 commits into
mainfrom
plans/incorporate-spf-tools

Conversation

@edmundlod

@edmundlod edmundlod commented Sep 16, 2026 •

Copy link
Copy Markdown
Owner

Ports spf-tools' SPF-parsing/DNS-querying (despf.sh/despf.inc.sh/global.inc.sh) and CIDR-normalisation (normalize.sh) directly into postallow, removing the external spf-tools runtime dependency entirely. Apache-2.0 attribution included for the ported code.

Implements docs/superpowers/specs/2026-09-15-incorporate-spf-tools.md (already on main).

Summary

  • Ported despf/normalize functions verbatim into postallow; renamed postallow's own cleanup() to cleanup_tmpfiles() to avoid colliding with the ported cleanup().
  • Rewired all 4 call sites (query_host, query_block_host, query_yahoo_host, --quick-add, and the main aggregation pipeline) to use the local functions instead of shelling out.
  • Removed spftoolspath and all its supporting plumbing (Makefile probe, installer download step, AppArmor rules, config/man docs).
  • Updated README/man1/MIGRATING.md to stop describing spf-tools as an external dependency.

Verification

  • sh -n postallow and sh -n contrib/install.sh pass
  • Worktree-based before/after regression diff against main's pre-work tip: CIDR output byte-identical (only header timestamp differs), including under invalid_cidr=remove + enable_blocklist=yes (previously untested combination)
  • --quick-add and the Yahoo DNS-override subshell scoping verified
  • Multi-domain run leaves zero leftover tempfiles
  • Final whole-branch review (3 Important findings) — all fixed and re-verified clean

Note

Found and left untouched (pre-existing, unrelated to this change, confirmed identical before/after): cleanup_tmpfiles()'s enable_blocklist=yes path checks $blktmp1..5 but the actual variables are named $blocktmp1..5 — causes the script to always exit 1 (skipping "Done!") and leak blocklist tempfiles whenever blocklisting is enabled. Worth a separate bug-fix task.

- Task 9 Step 4: replace the broken 'git stash back to pre-Task-1' regression
  check (every task ends in a commit, so there's nothing to stash by Task 9)
  with a git worktree-based before/after comparison against 568b9bf.
- Task 8 Step 3: verified README.md:188-190 is a numbered list and wrote
  the exact renumbering instead of hedging with 'if this was a numbered step'.
Frees up the name cleanup() for despf.inc.sh's loop-detection-tempfile
cleanup function, which is about to be ported in verbatim. Two
functions sharing one name would mean POSIX sh keeps only the
textually-last definition — silently breaking whichever one loses,
including a mid-run scenario where tmp1 (which accumulates SPF results
across every query_host() call) gets deleted mid-loop.
Adapted verbatim from spf-tools (Apache-2.0, see LICENSES/Apache-2.0.txt).
Adds despf_run() as new integration glue replacing despf.sh's own
loopfile-provisioning wrapper. Not yet wired to any call site — that's
the next task.
Restored three trailing-whitespace instances that were inadvertently
removed when the code block was initially inserted:
- dea() line: added trailing space after 'do'
- getamx() line: added trailing space after 'do'
- despfit() blank line: changed to single space (not completely empty)

All changes verified against brief using cat -A to ensure exact
byte-for-byte match with the spf-tools upstream source.
Adapted verbatim (Apache-2.0). Not yet wired to any call site.
query_host/query_block_host/query_yahoo_host, the --quick-add block, and
the main allowlist/blocklist aggregation pipeline now call despf_run/
normalize_cidrs directly instead of shelling out to ${spftoolspath}/despf.sh
and ${spftoolspath}/normalize.sh. No behavior change intended - same
functions, same logic, now in-process.
Task 9's straggler grep surfaced dead spftoolspath=/usr/local/bin lines
in every job's postallow.conf heredoc and stale comments describing
contrib/install.sh as installing spf-tools — both left over from before
the spf-tools incorporation (Tasks 1-8), and explicitly called out as
in-scope in the spec's Removals section but missed by those tasks. No
functional CI behavior change: the config lines were already harmless
(sourced but unused), this just removes the dead config and corrects
the comments to match what install.sh actually does now.
- Remove stale "Requires SPF-Tools" header lines from postallow now
  that spf-tools is built in rather than an external dependency.
- Grant AppArmor rules the ported despf code actually needs: the
  despf-sort- tempfile pattern, tr, and rm (pre-existing gap); update
  stale despf.sh comment references.
- Confine ~/.spf-toolsrc sourcing to despf_run()'s subshell instead of
  postallow's top-level shell, so it can no longer override postallow's
  own config variables.
- Fix a stale normalize.sh comment reference to say normalize_cidrs.
The plan (docs/superpowers/plans/2026-09-16-incorporate-spf-tools.md) was
scratch/working scaffolding for the 9-task subagent-driven implementation
of the already-merged spec (docs/superpowers/specs/2026-09-15-incorporate-spf-tools.md).
Git history is the record now; removing it per the branch-workflow
instruction to strip planning artifacts before opening the final PR.
@edmundlod edmundlod changed the title Add implementation plan for incorporating spf-tools Incorporate spf-tools into postallow Sep 16, 2026
@edmundlod
edmundlod merged commit d1ccde0 into main Sep 16, 2026
5 checks passed
edmundlod added a commit that referenced this pull request Sep 16, 2026
Brings in the just-merged spf-tools inlining (PR #40) and resolves the
resulting conflicts: dropped the now-removed spftoolspath setting
everywhere both branches touched it, removed the resulting dead
dependency-install blocks from contrib/install.sh (neither spf-tools
nor aggregateCIDR.pl needs a separate fetch anymore), and reconciled
the doc/CI/AppArmor text so both changes are described together.
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.

1 participant