Skip to content

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

Draft
sonnymay wants to merge 2 commits into
mainfrom
claude/sleepy-lamport-7z5sf8
Draft

sonnymay wants to merge 2 commits into
mainfrom
claude/sleepy-lamport-7z5sf8

Conversation

@sonnymay

Copy link
Copy Markdown
Owner

Summary

Test plan

  • Added backend/test_ai.py with regression tests asserting _fetch_ticket and _fetch_notes escape a crafted ticket_id containing &status=eq.Closed, plus a not-found case.
  • python -m pytest -q — 45 passed, 3 new tests pass; 1 pre-existing unrelated failure (test_get_headers_uses_supabase_key) confirmed present on the base branch before this change, unaffected by this diff.

🤖 Generated with Claude Code

https://claude.ai/code/session_016pnWcimqFhFgSa4vb1LRet


Generated by Claude Code

…ai.py

_fetch_ticket and _fetch_notes built PostgREST filter strings from the
request-supplied ticket_id (POST /ai/suggest) without escaping it, the
same filter-injection class fixed for main.py's routes in #18/#19. A
crafted ticket_id could append extra filter conditions or query
parameters to the Supabase request. Reuse escape_filter_value from
database.py, matching the pattern already used elsewhere, and add
regression tests.

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

vercel Bot commented Sep 11, 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 11, 2026 2:08pm UTC

CI lint check flagged an un-sorted/un-formatted import block; ruff --fix
resolves it (removes an extra blank line ruff's isort integration doesn't
expect between the import block and the following comment).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016pnWcimqFhFgSa4vb1LRet
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