test : add unit tests for _contextual_severity_score helper in risk_scoring

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

@aaniya22 đang làm issue này rồi.

Từ ngày 2/8/2026.

  • #2339 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/risk_scoring.py to inspect _contextual_severity_score and the related factor helpers, then review nearby tests under testing/backend/unit/. Add testing/backend/unit/test_risk_scoring_contextual_severity.py to cover overrides, multiplier combinations, defaults, clamping, and float results. The linked pull request #2339 is closed and unmerged; check the issue thread for current ownership 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 _contextual_severity_score function in backend/secuscan/risk_scoring.py. This function calculates a context-aware severity score by applying system exposure and business criticality multipliers to a base severity. It is a pure function with no external I/O and is directly importable without triggering heavy dependencies.

Changes that Need to be Made:

  • Add a new file testing/backend/unit/test_risk_scoring_contextual_severity.py
  • Import _contextual_severity_score from backend.secuscan.risk_scoring
  • Test that custom_override bypasses all other calculations (returns clamped value)
  • Test that base_severity * exposure_mult * criticality_mult is correctly clamped to [0, 10]
  • Test _system_exposure_factor interaction: public/internet_facing/internal/private multipliers
  • Test _business_criticality_factor interaction: critical/high/medium/low multipliers
  • Test that None for exposure_context or business_criticality falls back to default multipliers (1.0)
  • Test that extreme products (very large base_severity, extreme multipliers) are clamped
  • Test that result is always a float in [0, 10]

Impact that it would Provide:

  • Increases test coverage for the risk_scoring module's context-aware severity path
  • Ensures the exposure/criticality multipliers are correctly combined and clamped
  • Guards against regression when multipliers or clamp bounds are changed

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.