Swordfish-Security / hub-tool-converters

Набор конвертеров/парсеров отчетов о сканировании из формата сканера в формат AppSec.HUB
https://appsec-hub.ru/
Apache License 2.0
6 stars 3 forks source link

[Semgrep][sarif]: Ошибки конвертации - лишний текст в блоке кода (sample) #19

Open nluzgin opened 2 weeks ago

nluzgin commented 2 weeks ago

Краткое описание: В снипет кода включается лишний текст из описания уязвимсоти.

if (level === cadesplugin.LOG_LEVEL_DEBUG) **Rule name:** semgrep_public_rules.0xdea.generic.raptor-bad-words **Rule short description:** Semgrep Finding: semgrep_public_rules.0xdea.generic.raptor-bad-words

В самом файле строчка с "уязвимостью" не содержит подстроку "Rule name: sem .... "

Как воспроизводится:

  1. Просканировать файл (sample_code.txt) с помощью Semgrep Команда на скан примерно такая: semgrep scan --metrics=off --dataflow-traces --disable-version-check --no-error --config '/semgrep_public_rules' --sarif --output='sample_code_results.sarif' --exclude='*_test.go' --exclude='*/src/test/java/*' sample_code.txt
  2. Сариф файл (sample_code_results.sarif) отправить в конрвертор python.exe .\main.py -t CODEBASE -s semgrep --format sarif -f C:\...\sample_code_results.sarif -o sample_code_results_hub.json -n semgrep-sarif-3000-pro -u https://gitlab.xxx.ru/example-repo -b master -bt NPM
  3. загрузить результат (sample_code_results_hub.json) в Hub python3 -m src.import_report --url https://hub-test.ru --token <токенхаба> --appcode test_conv --report-file sample_code_results_hub.json --insecure

Что именно не так: В файле sample_code.txt "уязвима" - строка 7. В sarif файле сниппет корректный - строка 208 Конвертированный результат содержит "мусор" - строка 53

WDN2010 commented 2 weeks ago

sample_code.txt sample_code_results.sarif.txt sample_code_results_hub.json.txt