test : add unit tests for KnowledgeBase.infer_cpe and _normalize_version

Abierto
#2,247 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

  • #2252 de @tmdeveloper007 — cerrado sin fusionar

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
25/100
Tipo de issue
Documentación
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python
Área
testing

Línea de trabajo

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.

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 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.

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.