Skip to content

add honeypot to snap reports#5589

Merged
M7mdisk merged 6 commits intomainfrom
honey-pot
Feb 17, 2026
Merged

add honeypot to snap reports#5589
M7mdisk merged 6 commits intomainfrom
honey-pot

Conversation

@M7mdisk
Copy link
Copy Markdown
Contributor

@M7mdisk M7mdisk commented Feb 13, 2026

Done

  • add honeypot

How to QA

  • go to demo, submit form, see message on snap reports channel
  • inspect html, check the "confirm" checkbox, see message get ignored.

Testing

  • This PR has tests
  • No testing required (explain why):

Security

  • Security considerations for review (list them):
    • Examples:
    • Access control: users can only access their own data
    • Input: user input is validated and sanitised
    • Sensitive data: secret or private data is not exposed in any way
    • ...
  • This PR has no security considerations (explain why):

Issue / Card

Fixes #

Screenshots

UX Approval

  • This PR does not require UX approval
  • This PR does require UX approval (add context):

Copilot AI review requested due to automatic review settings February 13, 2026 10:54
@webteam-app
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds spam protection to the snap report form by implementing a honeypot field and URL detection in comments. The honeypot is a hidden checkbox that legitimate users won't see or interact with, while bots are likely to fill it out. The backend silently rejects submissions that trigger either the honeypot or contain "http" in the comment field.

Changes:

  • Added honeypot checkbox field (hidden via inline CSS) to the report snap modal form
  • Implemented backend validation to silently reject spam submissions based on honeypot activation or URL presence in comments

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
webapp/store/snap_details_views.py Added spam detection logic to check for honeypot field and URLs in comments before processing report submissions
templates/store/snap-details/_report_snap_modal.html Added hidden honeypot checkbox field with label positioned off-screen using inline styles

Comment thread webapp/store/snap_details_views.py Outdated

fields = flask.request.form

# If the honeypot is activated or a URL is included in the comment,
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description is incomplete and does not meet the repository's required standards. According to the custom coding guidelines, every PR must include:

  1. Clear "How to QA" instructions with specific, actionable steps
  2. Link to the issue or card being addressed (currently shows "Fixes #" with no issue number)
  3. Completion of security considerations checklist (currently all unchecked)
  4. Brief explanation of what changed and why

These sections are currently empty or incomplete, making it difficult for reviewers to understand the context and properly test the changes.

Copilot generated this review using guidance from repository custom instructions.
Comment on lines +53 to +54
<label for="report-snap-confirm" style="position: absolute; top: -9999999px;">I agree</label>
<input id="report-snap-confirm" type="checkbox" name="confirm" style="position: absolute; top: -9999999px;" />
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The honeypot field lacks accessibility attributes that are important for screen reader users. While the field is intentionally hidden from visual users, it should include an aria-hidden="true" attribute to explicitly signal to assistive technologies that this field should be ignored. This ensures that screen reader users don't encounter confusion from a hidden "I agree" checkbox that appears unrelated to the form's stated purpose.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Comment thread templates/store/snap-details/_report_snap_modal.html Outdated
Comment thread webapp/store/snap_details_views.py Outdated
Comment on lines +545 to +550
# If the honeypot is activated or a URL is included in the comment,
# silently reject to avoid spam
if (
"confirm" in fields and fields["confirm"] == "on"
) or "http" in fields.get("comment", ""):
return flask.jsonify({"ok": True}), 200
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spam detection implementation lacks test coverage. The repository has comprehensive Python test coverage for store endpoints (see tests/store/tests_details.py with 675 lines of tests), but this new security-critical functionality has no tests. Tests should verify:

  1. Legitimate reports without URLs are accepted
  2. Reports with the honeypot field checked are silently rejected
  3. Reports containing "http" in comments are rejected (though this behavior should be reconsidered as noted in another comment)
  4. The endpoint returns the correct response codes and JSON payloads in each scenario

Testing is particularly important for spam prevention logic to ensure it works as intended and doesn't create false positives.

Copilot uses AI. Check for mistakes.
Comment thread webapp/store/snap_details_views.py Outdated
Comment thread webapp/store/snap_details_views.py Outdated
Comment on lines +545 to +550
# If the honeypot is activated or a URL is included in the comment,
# silently reject to avoid spam
if (
"confirm" in fields and fields["confirm"] == "on"
) or "http" in fields.get("comment", ""):
return flask.jsonify({"ok": True}), 200
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The URL detection pattern is overly restrictive and will block legitimate reports. The check for "http" in the comment field will reject valid reports that include legitimate URLs (e.g., "This snap violates copyright of https://example.com"). Consider:

  1. Only blocking if the comment contains multiple URLs (spam pattern)
  2. Using a more sophisticated pattern to detect spam URLs vs. legitimate references
  3. Checking for "http://" or "https://" at word boundaries rather than just "http" as a substring

Additionally, "https" URLs will also be blocked since they contain "http" as a substring, making this check even more restrictive than likely intended.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 13, 2026

@M7mdisk I've opened a new pull request, #5590, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 4 commits February 13, 2026 14:26
…bility (#5590)

* Initial plan

* Add aria-hidden attribute to honeypot field for accessibility

Co-authored-by: M7mdisk <43501040+M7mdisk@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: M7mdisk <43501040+M7mdisk@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

<label for="report-snap-email">Your email (optional)</label>
<input id="report-snap-email" type="email" name="email" placeholder="email@example.com" />
<label for="report-snap-confirm" style="position: absolute; top: -9999999px;" aria-hidden="true">I agree</label>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps wrap these two fields in a div with the u-off-screen class, rather than using inline styles?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't know that was a thing! thanks

<label for="report-snap-email">Your email (optional)</label>
<input id="report-snap-email" type="email" name="email" placeholder="email@example.com" />
<label for="report-snap-confirm" style="position: absolute; top: -9999999px;" aria-hidden="true">I agree</label>
<input id="report-snap-confirm" type="checkbox" name="confirm" style="position: absolute; top: -9999999px;" aria-hidden="true" />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we added a tabindex="-1" to the input, would it prevent bots from triggering the honey pot? currently tab navigation in the form is in part broken because it shifts focus to the hidden checkbox

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, good point, I'll test it as is for now (mainly because thats how it was originally), I can then add this later down the line and see if we get more spam (I just need a point of reference for the time being)

@M7mdisk M7mdisk merged commit 13f4f6c into main Feb 17, 2026
23 of 24 checks passed
@M7mdisk M7mdisk deleted the honey-pot branch February 17, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants