Skip to content

fix: escape ticket_id before interpolating into PostgREST filters in ai.py - #22

Draft
sonnymay wants to merge 1 commit into
mainfrom
claude/sleepy-lamport-po960v
Draft

sonnymay wants to merge 1 commit into
mainfrom
claude/sleepy-lamport-po960v

Conversation

@sonnymay

Copy link
Copy Markdown
Owner

Summary

Test plan

  • python3 -m pytest -q in backend/ — all tests pass except one pre-existing, environment-dependent failure (test_database.py::test_get_headers_uses_supabase_key, unrelated to this change — reproduced on main before this fix too, since the sandbox has no SUPABASE_URL set).
  • Added backend/test_ai.py with regression tests asserting a malicious ticket_id (t1&status=eq.Closed) can no longer inject extra query params into the tickets / ticket_notes filters built by ai._fetch_ticket / ai._fetch_notes.
  • ruff check . — clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XyiFjiKo98KHBde3mumZpQ


Generated by Claude Code

…ai.py

ai._fetch_ticket and ai._fetch_notes (used by POST /ai/suggest) still
built PostgREST filter strings by interpolating the request body's
ticket_id directly, the same injection class already fixed for
main.py's id-based routes in #18/#19. A crafted ticket_id could append
extra query params or filter conditions. Both helpers now go through
escape_filter_value like the rest of the API, with regression tests
covering the injection case.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XyiFjiKo98KHBde3mumZpQ
@vercel

vercel Bot commented Sep 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
supportops Ready Ready Preview Sep 12, 2026 2:06pm UTC

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