Skip to content

Methods' arguments are not consistent (**kwargs) #316

Open
@axelfahy

Description

@axelfahy

Description

Lots of methods in the pycti library uses a variable number of keyword arguments (**kwargs). However, some of those arguments are in snake_case and others in camelCase, making it really error-prone.
Let's take, for example, the create method of the Identity class (opencti_identity.py file):

    def create(self, **kwargs):
        type = kwargs.get("type", None)
        stix_id = kwargs.get("stix_id", None)
        created_by = kwargs.get("createdBy", None)
        object_marking = kwargs.get("objectMarking", None)
        object_label = kwargs.get("objectLabel", None)
        external_references = kwargs.get("externalReferences", None)
        revoked = kwargs.get("revoked", None)
        confidence = kwargs.get("confidence", None)
        lang = kwargs.get("lang", None)
        created = kwargs.get("created", None)
        modified = kwargs.get("modified", None)
        name = kwargs.get("name", None)
        description = kwargs.get("description", "")
        contact_information = kwargs.get("contact_information", None)
        roles = kwargs.get("roles", None)
        x_opencti_aliases = kwargs.get("x_opencti_aliases", None)
        x_opencti_organization_type = kwargs.get("x_opencti_organization_type", None)
        x_opencti_reliability = kwargs.get("x_opencti_reliability", None)
        x_opencti_firstname = kwargs.get("x_opencti_firstname", None)
        x_opencti_lastname = kwargs.get("x_opencti_lastname", None)
        x_opencti_stix_ids = kwargs.get("x_opencti_stix_ids", None)
        update = kwargs.get("update", False)

For example, stix_id is snake_case, but createdBy is camelCase. Is there a specific reason for having some of the arguements in camelCase (Python naming style from pep8 does not use camelCase for variable names)?

It is interesting to note that even if an argument is camelCase, it is assigned to a variable being snake_case when retrieving the keyword argument.

This inconsistency is visible in most of the files of the pycti library.

Environment

  1. OS (where OpenCTI server runs): not relevant
  2. OpenCTI version: pycti 5.5.2
  3. Other environment details:

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionuse for asking information about a functionality or behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions