test : add unit tests for _contextual_severity_score helper in risk_scoring

Abierto
#2,334 3 comentarios 0 reacciones 0 asignados Ver en GitHub

@aaniya22 ya está trabajando en esto.

Desde el 2/8/2026.

  • #2339 de @tmdeveloper007 — cerrado sin fusionar

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python
Área
security, testing

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
36
Forks
234
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de utksh1/SecuScan

Todos los issues de utksh1/SecuScan

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.