Cloud Enrichment Tasks#

Enrichment result object schemas#

You can make enrichment using object schema that defines attribute composition of the objects and data types of the attributes (see Cloud Data Model for more information).

To create enrichment tasks, you will need to specify the schema id of the objects that are the results of these tasks.

In the example bellow we get list of enrichment result object schemas.

#!/usr/bin/env python3
from cybsi.cloud import Client, Config
from cybsi.cloud.pagination import chain_pages

if __name__ == "__main__":
    config = Config(api_key="the cryptic string")

    with Client(config) as client:
        # Retrieve first page of enrichment result object schemas.
        start_page = client.insight.schemas.filter()

        for schema in chain_pages(start_page):
            # Do something with the schema as SchemaCommonView.
            print(schema)

And one more example of getting schema by ID.

#!/usr/bin/env python3
from cybsi.cloud import Client, Config

if __name__ == "__main__":
    config = Config(api_key="the cryptic string")

    with Client(config) as client:
        schema_id = "example-schema"

        # Retrieve schema. It describes all attributes of objects you can encounter
        # in the result object of the enrichment task with this schema.
        schema_view = client.insight.schemas.view(schema_id="example-schema")

        # Do something with the schema as SchemaView.
        print(schema_view)

Enrichment tasks#

Insight service enriches object data.

In the example bellow you create new enrichment task.

#!/usr/bin/env python3
from cybsi.cloud import Client, Config
from cybsi.cloud.insight import ObjectKeyForm, TaskForm
from cybsi.cloud.insight.tasks import ObjectKeyType

if __name__ == "__main__":
    config = Config(api_key="the cryptic string")

    with Client(config) as client:
        schema_id = "phishing"

        # define task params
        keys = [ObjectKeyForm(ObjectKeyType.DomainName, "example.com")]
        task_form = TaskForm(schema_id, keys)
        # create task
        task = client.insight.tasks.register(task_form)
        # store task identifier
        print(task.id)

And example of getting enrichment task result.

#!/usr/bin/env python3

import uuid

from cybsi.cloud import Client, Config
from cybsi.cloud.insight import TaskState

if __name__ == "__main__":
    config = Config(api_key="the cryptic string")

    with Client(config) as client:
        # task identifier
        task_id = uuid.UUID("d3bcba79-2a0f-41ec-a3da-52e82eea4b2b")
        # get task view
        task = client.insight.tasks.view(task_id)
        if task.state == TaskState.Completed:
            # handle result
            print(task.result)
        elif task.state == TaskState.Failed:
            # handle task error
            print(task.error)
        else:
            # retry after some time
            pass