OpenCTI-Platform / opencti

Open Cyber Threat Intelligence Platform
https://opencti.io
Other
6.2k stars 919 forks source link

When mandatory attributes are enabled in Report, importing data from CSV fails #6947

Closed yassine-ouaamou closed 2 months ago

yassine-ouaamou commented 4 months ago

Description

When mandatory attributes are enabled in Report type, importing a CSV generates the following error:

Environment

Testing

Reproducible Steps

Steps to create the smallest reproducible scenario:

  1. Setup mandatory attributes for the Report type image

  2. Create a simple CSV mapper to ingest URLs image

  3. Create a report, a CSV file containing URLs and upload the file inside the report urls.csv

  4. Import the CSV file using the previously created CSV mapper

Expected Output

Actual Output

[May 13, 2024, 8:54:46 PM] {'name': 'VALIDATION_ERROR', 'message': 'Validation error'}

Traceback (most recent call last):
  File "/opt/opencti-worker/worker.py", line 269, in data_handler
    self.api.stix2.import_bundle_from_json(
  File "/usr/local/lib/python3.12/site-packages/pycti/utils/opencti_stix2.py", line 215, in import_bundle_from_json
    return self.import_bundle(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pycti/utils/opencti_stix2.py", line 2669, in import_bundle
    self.import_object(item, update, types)
  File "/usr/local/lib/python3.12/site-packages/pycti/utils/opencti_stix2.py", line 990, in import_object
    stix_object_results = do_import(
                          ^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pycti/entities/opencti_report.py", line 881, in import_from_stix2
    return self.create(
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pycti/entities/opencti_report.py", line 724, in create
    result = self.opencti.query(
             ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pycti/api/opencti_api_client.py", line 359, in query
    raise ValueError(
ValueError: {'name': 'VALIDATION_ERROR', 'message': 'Validation error'}
richard-julien commented 4 months ago

https://github.com/OpenCTI-Platform/opencti/pull/6862 must be reviewed and merged first

frapuks commented 3 months ago

5550 will create a new capability 'Bypass mandatory fields' for connectors