django-DefectDojo icon indicating copy to clipboard operation
django-DefectDojo copied to clipboard

Generic Findings Importer Error

Open enidevops opened this issue 3 years ago • 1 comments

Bug description The Generic Findings Importer seems to be broken in the current release. When I try to import a json file in the generic findings format I get the following error (see logs). I have attached the file where this is happening.

Deployment method

  • [ ] Docker Compose
  • [X ] Kubernetes
  • [ ] GoDojo

Environment information

  • DefectDojo: 2.22.1

Logs

[pid: 1|app: -|req: -/-] 172.30.25.32 (-) {34 vars in 397 bytes} [Mon May 15 11:00:56 2023] GET / => generated 0 bytes in 43 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 1)
[15/May/2023 11:00:57] ERROR [dojo.api_v2.exception_handler:32] relation "dojo_rule" does not exist
LINE 1: ...applied_field", "dojo_rule"."parent_rule_id" FROM "dojo_rule...
                                                             ^
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.UndefinedTable: relation "dojo_rule" does not exist
LINE 1: ...applied_field", "dojo_rule"."parent_rule_id" FROM "dojo_rule...
                                                             ^


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/rest_framework/mixins.py", line 19, in create
    self.perform_create(serializer)
  File "/app/dojo/api_v2/views.py", line 2304, in perform_create
    serializer.save(push_to_jira=push_to_jira)
  File "/app/dojo/api_v2/serializers.py", line 1673, in save
    test, finding_count, closed_finding_count, test_import = importer.import_scan(scan, scan_type, engagement, lead, environment,
                                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/dojo/importers/importer/importer.py", line 330, in import_scan
    new_findings = self.process_parsed_findings(test, parsed_findings, scan_type, user, active=active,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/dojo/decorators.py", line 47, in __wrapper__
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/celery/local.py", line 188, in __call__
    return self._get_current_object()(*a, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/celery/app/task.py", line 392, in __call__
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/dojo/importers/importer/importer.py", line 105, in process_parsed_findings
    item.save(dedupe_option=False)
  File "/app/dojo/models.py", line 2750, in save
    do_apply_rules(self, *args, **kwargs)
  File "/app/dojo/utils.py", line 436, in do_apply_rules
    for rule in rules:
  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 394, in __iter__
    self._fetch_all()
  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 1867, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 87, in __iter__
    results = compiler.execute_sql(
              ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 1398, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/usr/local/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.ProgrammingError: relation "dojo_rule" does not exist
LINE 1: ...applied_field", "dojo_rule"."parent_rule_id" FROM "dojo_rule...

test.txt

enidevops avatar May 15 '23 11:05 enidevops

sorry, I accidentally switched to an older version. issue closed

enidevops avatar May 15 '23 11:05 enidevops