intuitem / ciso-assistant-community

CISO Assistant is a one-stop-shop for GRC, covering Risk, AppSec and Audit Management and supporting +70 frameworks worldwide with auto-mapping: NIST CSF, ISO 27001, SOC2, CIS, PCI DSS, NIS2, CMMC, PSPF, GDPR, HIPAA, Essential Eight, NYDFS-500, DORA, NIST AI RMF, 800-53, 800-171, CyFun, CJIS, AirCyber, NCSC, ECC, SCF and so much more
https://intuitem.com
Other
1.17k stars 165 forks source link

Failed to import ISO 27001-2022 library #14

Closed stalpers closed 1 year ago

stalpers commented 1 year ago

I tried to import the ISO 27k library multiple times, but it always fails no matter if the DB if SQLite or Postgres. Also tried Docker and local installs, without success...

To get some more context, I enabled DJANGO_DEBUG and imported https://github.com/Qix-/better-exceptions

Version is 0.9.1 (cloned Oct 18 2023) $ cat ciso_assistant/VERSION 0.9.1

Stacktrace:

`Importing framework: ISO/IEC 27001:2022 Traceback (most recent call last): File "/home/stefan/tools/ciso-assistant-community/venv/lib/python3.11/site-packages/django/db/models/query.py", line 916, in get_or_create return self.get(**kwargs), False │ └ {'urn': 'urn:intuitem:risk:req_groups:iso27001-2022:core:10:10.2:annex-a:5'} └ <QuerySet [, <RequirementGroup: 4>, <RequirementGroup: 4.1>, <RequirementGroup: 4.2>, <RequirementGroup:... File "/home/stefan/tools/ciso-assistant-community/venv/lib/python3.11/site-packages/django/db/models/query.py", line 637, in get raise self.model.DoesNotExist( core.models.RequirementGroup.DoesNotExist: RequirementGroup matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/stefan/tools/ciso-assistant-community/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, callback_kwargs) │ │ │ │ └ {'library_urn': 'urn:intuitem:risk:library:iso27001-2022'} │ │ │ └ () │ │ └ <WSGIRequest: POST '/libraries/import_default_library/urn:intuitem:risk:library:iso27001-2022'> │ └ <function import_default_library at 0x7fb492ec6ac0> └ None File "/home/stefan/tools/ciso-assistant-community/venv/lib/python3.11/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapper_view return view_func(request, *args, *kwargs) │ │ │ └ {'library_urn': 'urn:intuitem:risk:library:iso27001-2022'} │ │ └ () │ └ <WSGIRequest: POST '/libraries/import_default_library/urn:intuitem:risk:library:iso27001-2022'> └ <function import_default_library at 0x7fb49304cfe0> File "/home/stefan/tools/ciso-assistant-community/library/views.py", line 82, in import_default_library raise e File "/home/stefan/tools/ciso-assistant-community/library/views.py", line 80, in import_default_library import_library_view(request, library) │ │ └ {'urn': 'urn:intuitem:risk:library:iso27001-2022', 'locale': 'en', 'name': 'ISO/IEC 27001:2022', 'description': 'Information sec... │ └ <WSGIRequest: POST '/libraries/import_default_library/urn:intuitem:risk:library:iso27001-2022'> └ <function import_library_view at 0x7fb492ec6340> File "/home/stefan/tools/ciso-assistant-community/library/utils.py", line 355, in import_library_view import_objects(objects_imported) │ └ {'threats': [{'urn': 'urn:intuitem:risk:threat:T1047', 'name': 'T1047 - Windows Management Instrumentation', 'provider': 'MITRE ... └ <function import_objects at 0x7fb492ec6200> File "/home/stefan/tools/ciso-assistant-community/library/utils.py", line 311, in import_objects import_requirement_group(framework_urn=framework['urn'], fields=requirement_group) │ │ └ {'urn': 'urn:intuitem:risk:req_groups:iso27001-2022:core:10:10.2:annex-a:5', 'name': '5', 'description': 'Organisational control... │ └ {'urn': 'urn:intuitem:risk:framework:iso27001-2022', 'provider': 'ISO/IEC', 'name': 'ISO/IEC 27001:2022', 'description': 'Inform... └ <function import_requirement_group at 0x7fb492ec5e40> File "/home/stefan/tools/ciso-assistant-community/library/utils.py", line 111, in import_requirement_group requirement_group = RequirementGroup.objects.update_or_create( File "/home/stefan/tools/ciso-assistant-community/venv/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method return getattr(self.get_queryset(), name)(args, kwargs) │ │ │ └ {'defaults': {'framework': <Framework: ISO/IEC 27001:2022>, 'urn': 'urn:intuitem:risk:req_groups:iso27001-2022:core:10:10.2:anne... │ │ └ () │ └ 'update_or_create' └ <django.db.models.manager.Manager object at 0x7fb492f7acd0> File "/home/stefan/tools/ciso-assistant-community/venv/lib/python3.11/site-packages/django/db/models/query.py", line 949, in update_or_create obj, created = self.select_for_update().get_or_create(defaults, kwargs) │ │ └ {'urn': 'urn:intuitem:risk:req_groups:iso27001-2022:core:10:10.2:annex-a:5'} │ └ {'framework': <Framework: ISO/IEC 27001:2022>, 'urn': 'urn:intuitem:risk:req_groups:iso27001-2022:core:10:10.2:annex-a:5', 'pare... └ <QuerySet [, <RequirementGroup: 4>, <RequirementGroup: 4.1>, <RequirementGroup: 4.2>, <RequirementGroup:... File "/home/stefan/tools/ciso-assistant-community/venv/lib/python3.11/site-packages/django/db/models/query.py", line 923, in get_or_create return self.create(params), True │ └ {'urn': 'urn:intuitem:risk:req_groups:iso27001-2022:core:10:10.2:annex-a:5', 'framework': <Framework: ISO/IEC 27001:2022>, 'pare... └ <QuerySet [, <RequirementGroup: 4>, <RequirementGroup: 4.1>, <RequirementGroup: 4.2>, <RequirementGroup:... File "/home/stefan/tools/ciso-assistant-community/venv/lib/python3.11/site-packages/django/db/models/query.py", line 658, in create obj.save(force_insert=True, using=self.db) │ └ <QuerySet [, <RequirementGroup: 4>, <RequirementGroup: 4.1>, <RequirementGroup: 4.2>, <RequirementGroup:... └ <RequirementGroup: 5> File "/home/stefan/tools/ciso-assistant-community/core/base_models.py", line 107, in save self.clean() └ <RequirementGroup: 5> File "/home/stefan/tools/ciso-assistant-community/core/base_models.py", line 102, in clean super().clean() File "/home/stefan/tools/ciso-assistant-community/core/base_models.py", line 29, in clean raise ValidationError(field_errors) │ └ {'name': 'This name is already in use.'} └ <class 'django.core.exceptions.ValidationError'> django.core.exceptions.ValidationError: {'name': ['This name is already in use.']} "POST /libraries/import_default_library/urn:intuitem:risk:library:iso27001-2022 HTTP/1.1" 500 215317`

ab-smith commented 1 year ago

Thank you @stalpers can you confirm the hash of your repo, please?

stalpers commented 1 year ago

sure - I hope that's the correct command ;-)

$ git rev-parse --branches 6f45f5a99deb3bd87b3fc2c71705fa232982863c

$ git rev-parse --remotes 6f45f5a99deb3bd87b3fc2c71705fa232982863c fe3b2f51cf35ae7031350f7e311b73bb34e609c7 f2befde894a0919be621f6be939ccea67eb981a0 48ea5cef4d042256418cd5d2fa450bb6a8233063 4365252d34b41a880b3be7690416f8978e633e85 7b7df239caff2d8eba782aff4f01e51b5e6956f5 6f45f5a99deb3bd87b3fc2c71705fa232982863c 9e03b31640f297cdda9f6b174bb29cbfad52d468 ae70a725633f0569c8f11a37a53fbe23453ebf40

eric-intuitem commented 1 year ago

Thanks for your answer. Please checkout the last version, this issue has been fixed.

stalpers commented 1 year ago

Thank you it works!