OpenCTI-Platform / connectors

OpenCTI Connectors
https://www.opencti.io
Apache License 2.0
356 stars 389 forks source link

Error while trying to execute connectors #355

Closed ghost closed 3 years ago

ghost commented 3 years ago

Description

I'm running a manual installation of OpenCTI. When I try to execute a connector I get some errors

Environment

  1. OS: Ubuntu 20.04
  2. OpenCTI version: 4.4.1
  3. OpenCTI client: python
  4. Other environment details:

Reproducible Steps

Steps to create the smallest reproducible scenario:

  1. clone connectors repository
  2. cd misp/src
  3. cp config.yml.sample config.yml
  4. edit config.yml
  5. pip3 install -r requirements.txt
  6. python3 misp.py

Expected Output

Connector running and working

Actual Output

root@ubuntu-server:/opt/connectors/misp/src# python3 misp.py
INFO:root:Listing Threat-Actors with filters null.
ERROR:root:No reason specify
Traceback (most recent call last):
  File "misp.py", line 1299, in <module>
    mispConnector = Misp()
  File "misp.py", line 84, in __init__
    self.helper = OpenCTIConnectorHelper(config)
  File "/usr/local/lib/python3.8/dist-packages/pycti/connector/opencti_connector_helper.py", line 372, in __init__
    connector_configuration = self.api.connector.register(self.connector)
  File "/usr/local/lib/python3.8/dist-packages/pycti/api/opencti_api_connector.py", line 101, in register
    result = self.api.query(query, connector.to_input())
  File "/usr/local/lib/python3.8/dist-packages/pycti/api/opencti_api_client.py", line 273, in query
    raise ValueError(
ValueError: {'name': 'UnknownError', 'message': 'No reason specify'}

Additional information

config.yml file

opencti:
  url: 'http://<My IP OpenCTI Server>:4000'
  token: 'Mytokenvalue'

connector:
  id: '0ce52c6a-6374-449d-a93c-be1a8d9092b2'
  type: 'EXTERNAL_IMPORT'
  name: 'MISP' # Required
  scope: 'misp'
  confidence_level: 15 # 0 (Unknown) or from 1 to 100
  update_existing_data: False
  log_level: 'info'

misp:
  url: 'https://misp.lab' # Required
  reference_url: '' # Optional, will be used to create external reference to MISP event
  key: 'MyMISP API' # Required
  ssl_verify: False # Required
  datetime_attribute: 'timestamp' # Required, filter to be used in query for new MISP events
  create_reports: True # Required, create report for MISP event
  create_indicators: True # Required, create indicators for attributes
  create_observables: True # Required, create observables for attributes
  report_class: 'misp-event' # Optional, report_class if creating report for event
  import_from_date: '2010-01-01' # Optional, import all event from this date
  import_tags: 'opencti:import,type:osint' # Optional, list of tags used for import events
  import_tags_not: '' # Optional, list of tags to not include
  import_creator_orgs: 'CIRCL,Luatix' # Optional, only import events created by this ORG (put the identifier here)
  import_owner_orgs: 'CIRCL' # Optional, only import events owned by this ORG (put the identifier here)
  import_distribution_levels: '0,1,2,3' # Optional, only import events with the given distribution levels
  import_threat_levels: '1,2,3,4' # Optional only import events with the given threat levels
  import_only_published: False # Optional only import events published
  interval: 1 # Required, in minutes

Logs from application

{
    "user": {
        "ip": "::ffff:172.22.250.36",
        "user_id": "88ec0c6a-13ce-5e39-b486-354fe4a7084f"
    },
    "type": "WRITE_ERROR",
    "operation_query": "mutation RegisterConnector($input:RegisterConnectorInput){registerConnector(input:$input){id connector_state config{connection{host use_ssl port user pass}listen listen_exchange push push_exchange}connector_user{id}}}",
    "inner_relation_creation": 0,
    "operation": "RegisterConnector",
    "time": 1,
    "variables": {
        "input": {
            "id": "0ce52c6a-6374-449d-a93c-be1a8d9092b2",
            "name": "MISP",
            "type": "EXTERNAL_IMPORT",
            "scope": [
                "misp"
            ],
            "auto": false,
            "only_contextual": false
        }
    },
    "size": 148,
    "error": {
        "stacktrace": [
            "GraphQLError: Variable \"$input\" got invalid value { id: \"0ce52c6a-6374-449d-a93c-be1a8d9092b2\", name: \"MISP\", type: \"EXTERNAL_IMPORT\", scope: [\"misp\"], auto: false, only_contextual: false }; Field \"only_contextual\" is not defined by type \"RegisterConnectorInput\".",
            "at /opt/opencti/node_modules/graphql/execution/values.js:116:15",
            "at coerceInputValueImpl (/opt/opencti/node_modules/graphql/utilities/coerceInputValue.js:114:9)",
            "at coerceInputValue (/opt/opencti/node_modules/graphql/utilities/coerceInputValue.js:37:10)",
            "at _loop (/opt/opencti/node_modules/graphql/execution/values.js:109:69)",
            "at coerceVariableValues (/opt/opencti/node_modules/graphql/execution/values.js:121:16)",
            "at getVariableValues (/opt/opencti/node_modules/graphql/execution/values.js:50:19)",
            "at buildExecutionContext (/opt/opencti/node_modules/graphql/execution/execute.js:203:61)",
            "at executeImpl (/opt/opencti/node_modules/graphql/execution/execute.js:101:20)",
            "at Object.execute (/opt/opencti/node_modules/graphql/execution/execute.js:60:35)",
            "at /opt/opencti/node_modules/apollo-server-core/dist/requestPipeline.js:249:48",
            "at Generator.next (<anonymous>)",
            "at /opt/opencti/node_modules/apollo-server-core/dist/requestPipeline.js:8:71",
            "at new Promise (<anonymous>)",
            "at __awaiter (/opt/opencti/node_modules/apollo-server-core/dist/requestPipeline.js:4:12)",
            "at execute (/opt/opencti/node_modules/apollo-server-core/dist/requestPipeline.js:228:20)",
            "at Object.<anonymous> (/opt/opencti/node_modules/apollo-server-core/dist/requestPipeline.js:176:42)"
        ]
    },
    "category": "APP",
    "version": "4.4.1",
    "level": "error",
    "message": "API Call",
    "timestamp": "2021-04-29T21:02:43.176Z"
}
ghost commented 3 years ago

highlight to this output on application logs:

Field \"only_contextual\" is not defined by type \"RegisterConnectorInput\
SamuelHassine commented 3 years ago

Hello @huntingneo,

You're using the master branch of the connector, which is the current (4.5.0) version. Please use the proper tag (4.4.1) and pip3 install the requirements. Your Python library is too recent. Or.... upgrade your platform to the latest version ;)

Kind regards, Samuel

SamuelHassine commented 3 years ago

By the way, thanks for this very good issue (and very complete). Rare enough to be noted!

ghost commented 3 years ago

It's working! I didn't notice wasn't using the last version available. =/

Thank you for the compliment about the issue. Hope I can get collaborate closely with you in the future!