test : add unit tests for KnowledgeBase.infer_cpe and _normalize_version

Đang mở
#2,247 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.

  • #2252 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
25/100
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
testing

Hướng nghiên cứu

Start with testing/backend/unit/test_knowledgebase.py and find the existing KnowledgeBase unit tests; then read the infer_cpe and _normalize_version implementations to confirm expected behavior. Add the listed cases and run the focused unit test file. Done when both helpers’ specified cases pass; the issue notes it is being handled and links a closed, unmerged pull request.

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 KnowledgeBase.infer_cpe() and KnowledgeBase._normalize_version() in testing/backend/unit/test_knowledgebase.py. These methods are not currently tested despite being public helpers in the knowledgebase module.

Changes that Need to be Made:
Add tests to testing/backend/unit/test_knowledgebase.py:

For infer_cpe():

  • exact CPE match for seeded products (nginx 1.18.0, apache 2.4.49)
  • returns None for unknown product/service
  • handles empty product/service strings
  • handles None values gracefully

For _normalize_version():

  • strips leading 'v' prefix (v1.2.3 -> 1.2.3)
  • extracts numeric prefix (1.2.3-beta -> 1.2.3)
  • handles empty string
  • handles purely alphabetic strings (returns as-is)

Impact that it would Provide:

  • Ensures knowledgebase CPE inference behaves correctly across version formats
  • Improves reliability of the vulnerability matching pipeline
  • Tests pure, isolated helpers that do not require a database or network

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.