test : add unit tests for _build_triage_prompt in triage_engine

Đang mở
#2,420 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

  • #2425 của @tmdeveloper007 — đã đóng, không merge

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
security, testing

Hướng nghiên cứu

Read backend/secuscan/triage_engine.py to inspect _build_triage_prompt() and the existing tests in testing/backend/unit/test_triage_engine.py. Add focused tests for the listed fields, defaults, response format, and deterministic output. Done means those cases verify the prompt without invoking an LLM; linked pull request #2425 is closed and unmerged, so check its changes before starting.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary of What Needs to be Done:
Add unit tests for the _build_triage_prompt() helper function in backend/secuscan/triage_engine.py. This private function constructs the prompt string passed to the LLM when triaging a SAST finding. It formats the finding title, category, severity, description, code context, and variables into a structured prompt.

The existing test file testing/backend/unit/test_triage_engine.py tests extract_code_context, is_eligible_for_triage, triage_finding, and triage_findings, but _build_triage_prompt is not directly imported or tested.

Changes that Need to be Made:
In testing/backend/unit/test_triage_engine.py:

  • Import _build_triage_prompt from backend.secuscan.triage_engine
  • Test that the prompt includes the finding title
  • Test that the prompt includes the finding category
  • Test that the prompt includes the severity
  • Test that the prompt includes the description
  • Test that the prompt includes the code snippet from context
  • Test that the prompt includes variable hints
  • Test that missing/None values fall back to defaults like "Untitled finding", "(no source snippet available)", "(none identified)"
  • Test that the prompt ends with the response format instructions (JSON object requirements)
  • Test that the prompt is a pure function (same inputs always produce same output)

Impact that it would Provide:

  • Directly tests the prompt construction logic without needing a mock LLM
  • Ensures the LLM receives well-formed prompts with all required fields
  • Catches regressions if the prompt template changes

Note: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.

Ngôn ngữ chính
Python
Star
36
Fork
234
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của utksh1/SecuScan

Tất cả issue của utksh1/SecuScan

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.