Skip to content

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

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

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

Conversation

@sonnymay

Copy link
Copy Markdown
Owner

Summary

Test plan

  • Added backend/test_ai.py with regression tests confirming an injected ticket_id no longer produces extra query parameters for both _fetch_ticket and _fetch_notes.
  • python -m pytest — 44 passed, 1 pre-existing failure unrelated to this change (test_get_headers_uses_supabase_key fails in this sandbox due to a missing SUPABASE_URL env var; reproduces identically on main before this change).
  • ruff check / ruff format --check pass on changed files.

🤖 Generated with Claude Code

https://claude.ai/code/session_01F7DCf2tVL9vazNThJWioGA


Generated by Claude Code

…ai.py

POST /ai/suggest passes the caller-supplied ticket_id straight into
_fetch_ticket and _fetch_notes, which built PostgREST filter strings
by raw string interpolation (f"id=eq.{ticket_id}"). This is the same
filter-injection class fixed for main.py's routes in #18/#19 (a
crafted id could append extra query parameters, e.g.
"t1&status=eq.Closed"), but ai.py's helpers were missed.

Route both filters through the existing escape_filter_value helper
and add regression tests confirming injected id values no longer
produce extra query parameters.

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

vercel Bot commented Sep 15, 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 15, 2026 2:07pm 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