test : add unit tests for KnowledgeBase.infer_cpe and _normalize_version helpers
@aaniya22 ya está trabajando en esto.
Desde el 2/8/2026.
- #2340 de @tmdeveloper007 — cerrado sin fusionar
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 25/100
Línea de trabajo
Read backend/secuscan/knowledgebase.py and existing tests under testing/backend/unit/ to see how KnowledgeBase is initialized and tested. Add the requested cases in testing/backend/unit/test_knowledgebase_infer_cpe.py, then run that test file. Done means the normalization cases and exact, family, missing-entry, and no-match CPE cases pass; a linked pull request already exists, and the issue says the work is being handled by tmdeveloper007.
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 infer_cpe method and _normalize_version helper in backend/secuscan/knowledgebase.py. infer_cpe returns the best CPE match for a given service/product/version tuple. _normalize_version extracts a normalized version string using a regex. Both are directly importable from the module.
Changes that Need to be Made:
- Add a new file
testing/backend/unit/test_knowledgebase_infer_cpe.py - Import
KnowledgeBaseand_normalize_versionfrombackend.secuscan.knowledgebase - For
_normalize_version:- Test empty string returns ""
- Test version with patch level: "1.2.3" extracts "1.2.3"
- Test version with extra text: "nginx-1.18.0" extracts "1.18.0"
- Test version with only major.minor: "apache2.4" extracts "2.4"
- Test version with no digits returns lowercased stripped input
- Test version with leading zeros handling
- For
infer_cpe:- Test returns None when no entries loaded
- Test returns None when no match found
- Test returns CPE string when exact match found
- Test falls back to family match when exact version not found
Impact that it would Provide:
- Improves test coverage for the knowledgebase CPE inference pipeline
- Validates version normalization edge cases that are easy to get wrong
- Ensures graceful handling of unknown products/versions
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
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de utksh1/SecuScan
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
area:frontend good first issue level:intermediate priority:low type:testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
-
area:frontend good first issue level:intermediate priority:low type:testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
area:frontend good first issue level:beginner priority:low type:testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
area:frontend good first issue level:intermediate priority:low type:testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Todos los issues de utksh1/SecuScan
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
comp/desktop P3 type/feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NousResearch/hermes-agent#154285 ·
Los mantenedores suelen responder en 1 día
-
docs: qualify copied and custom kubectl debug policy notesPosiblemente ocupada @nym01 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
kubescape/cel-admission-library#166 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
SACGF/variantgrid#2804 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[BUG] HTTP lifecycle dispatch treats a NO_PROXY-only environment as corporate egress and skips the resolve-and-pinned sessionPosiblemente ocupada @bodapatisaikrishna la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día