Closed drJabber closed 10 months ago
We're seeing the same when importing SARIF results (since it flows down into the same culprit code) on DefectDojo v2.25.2:
[01/Sep/2023 05:00:08] INFO [django.request:241] OK: /api/v2/import-scan/
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 56, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/utils/deprecation.py", line 138, in __call__
response = self.process_response(request, response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/watson/middleware.py", line 37, in process_response
self._close_search_context(request)
File "/usr/local/lib/python3.11/site-packages/watson/middleware.py", line 33, in _close_search_context
search_context_manager.end()
File "/usr/local/lib/python3.11/site-packages/watson/search.py", line 261, in end
list(chain.from_iterable(engine._update_obj_index_iter(obj)
File "/usr/local/lib/python3.11/site-packages/watson/search.py", line 505, in _update_obj_index_iter
"content": adapter.get_content(obj),
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/watson/search.py", line 147, in get_content
return self.prepare_content(" ".join(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/watson/search.py", line 101, in prepare_content
content = strip_tags(content)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/utils/functional.py", line 246, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/utils/html.py", line 175, in strip_tags
new_value = _strip_once(value)
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/utils/html.py", line 163, in _strip_once
s.feed(value)
File "/usr/local/lib/python3.11/html/parser.py", line 110, in feed
self.goahead(0)
File "/usr/local/lib/python3.11/html/parser.py", line 178, in goahead
k = self.parse_html_declaration(i)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/html/parser.py", line 263, in parse_html_declaration
return self.parse_marked_section(i)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/_markupbase.py", line 154, in parse_marked_section
raise AssertionError(
AssertionError: unknown status keyword 'A-Z' in marked section
In our case, the offending SARIF file had content similar to the following:
"contextRegion": {
"startLine": 1,
"endLine": 1,
"snippet": {
"text": "<![>"
If the <![>
value was removed from results.locations[].contextRegion.text
, the SARIF file was processed correctly.
This issue is still present in v. 2.31.0-dev
This issue can be closed @mtesauro
Bug description There is an error while import semgrep result using API or UI import function Stripped semgrep output attached semgrep2.json.txt
Steps to reproduce Steps to reproduce the behavior:
Expected behavior Semgrep output should be uploaded correctly
Deployment method (select with an
X
)Environment information
Logs
Sample scan files attached
Screenshots nope
Additional context (optional) I think this error is from bad html-tag-like content in field "lines" of json file This content comes from code snippet, which semgrep extracted from defective code