Skip to content

forms: harden honeypot — skip file save for spam, log triggers - #50

Merged
karloscodes merged 1 commit into
mainfrom
feature/honeypot-followups
Jun 6, 2026
Merged

forms: harden honeypot — skip file save for spam, log triggers#50
karloscodes merged 1 commit into
mainfrom
feature/honeypot-followups

Conversation

@karloscodes

Copy link
Copy Markdown
Owner

Two follow-ups from a self-review of #45 (v3.0.9):

1. Spam submissions no longer save uploaded files

The original honeypot fix gated delivery events on !isSpam but left the file-save block alone. For forms that accept uploads, a bot could still flood disk while looking like a normal trapped spam submission.

CreateSubmissionWithFiles now skips the file-save block (no SaveFiles call, no SubmissionFile rows, submission.Files stays empty) when the honeypot is triggered.

2. Honeypot triggers now log

Previously the honeypot was entirely silent — operators had no signal at all that bots were hitting them. Adds one slog.Info("honeypot triggered", ...) line on each trip with form_id + form_slug. On by default; info-level so it can be filtered at scale if it ever gets noisy.

Infra

  • Added SubmissionFile to testsupport.SetupTestDB's migrations (was missing — any test that exercised the file path would have died with "no such table").
  • New test: TestCreateSubmission/honeypot-trapped_submission_does_not_save_uploaded_files exercises files + payload + honeypot end-to-end and asserts no rows, no files attached, and no bytes in dataDir.

Related: #45.

Two follow-ups to #45 surfaced during self-review:

1. Spam submissions still wrote uploaded files to disk. For forms that
   accept uploads, a bot could fill __fl_hp and still flood storage. Gate
   the file-save block on !isSpam so spam submissions are a no-op for the
   filesystem.

2. The honeypot was entirely silent — operators had zero visibility into
   spam volume. Add a single Info log line on each trigger (form_id +
   form_slug). On by default so the signal is there, info-level so it
   can be filtered at scale.

Also includes a test-infrastructure fix: SubmissionFile was missing from
testsupport.SetupTestDB, so previous file-related tests would have failed
with 'no such table' if anyone tried.
@karloscodes
karloscodes merged commit 7a4ab3c into main Jun 6, 2026
9 checks passed
@karloscodes
karloscodes deleted the feature/honeypot-followups branch June 6, 2026 10:20
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