[Python] "unsupported type for timedelta hours component: str" [closed]

Discussão em 'Python' iniciado por Stack, Fevereiro 13, 2025.

  1. Stack

    Stack Membro Participativo

    I am getting the following error when running a TAXII connector in OpenCTI. This used to work without any problems with an older version.

    {"timestamp": "2025-02-13T11:01:50.017793Z", "level": "ERROR", "name": "TAXII2", "message": "unsupported type for timedelta hours component: str", "exc_info": "Traceback (most recent call last):\n File "/opt/opencti-taxii2/connector/connector.py", line 113, in process_message\n added_after = datetime.now() - timedelta(\n ^^^^^^^^^^\nTypeError: unsupported type for timedelta hours component: str", "taskName": null}

    The code at line 113 as follows.

    # Performing the collection of intelligence
    # Convert last_run to RFC-3339
    dt_format = ""
    if current_state is not None and "last_run" in current_state:
    dt = datetime.fromtimestamp(last_run, tz=timezone.utc)
    dt_format = dt.strftime("%Y-%m-%dT%H:%M:%S.%fZ")

    if self.config.enable_url_query_limit and self.config.taxii2v21:
    self.taxii2.filters["limit"] = self.config.url_query_limit
    # Set added_after to either last run or initial history
    if current_state is not None and "last_run" in current_state:
    self.taxii2.filters["added_after"] = dt_format
    else:
    added_after = datetime.now() - timedelta(
    hours=self.config.initial_history
    )
    self.taxii2.filters["added_after"] = added_after

    stix_objects = self._collect_intelligence()


    I am not a coder so not sure how to fix it. Any help appreciated. Thanks

    Continue reading...

Compartilhe esta Página