Skip to content

Commit

Permalink
Update api
Browse files Browse the repository at this point in the history
  • Loading branch information
slowaner committed Jul 31, 2024
1 parent 76250db commit eee8224
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 18 deletions.
10 changes: 8 additions & 2 deletions cybsi/api/data_source/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,14 @@ def filter(
Added new parameters: `query`, `type_uuids`, `order_by`.
Added semantic error `DataSourceNotFound`
.. versionchanged:: 2.13
Increased maxumum length of `query` parameter.
Note:
Calls `GET /data-sources`.
Args:
query: Filter of data sources by specified substring (case-insensitive).
Substring length must be in range [1, 50].
Substring length must be in range [1, 250].
Filtering is performed by specified substring in data source names or
its type names.
type_uuids: List of data source type UUIDs.
Expand Down Expand Up @@ -308,11 +311,14 @@ async def filter(
) -> AsyncPage["DataSourceCommonView"]:
"""Get a filtered list of data sources.
.. versionchanged:: 2.13
Increased maxumum length of `query` parameter.
Note:
Calls `GET /data-sources`.
Args:
query: Filter of data sources by specified substring (case-insensitive).
Substring length must be in range [1, 50].
Substring length must be in range [1, 250].
Filtering is performed by specified substring in data source names or
its type names.
type_uuids: List of data source type UUIDs.
Expand Down
9 changes: 4 additions & 5 deletions cybsi/api/enrichment/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,21 +205,17 @@ class ArtifactAnalysisParamsForm(JsonObjectForm):
Args:
artifact_uuid: Artifact identifier.
image_id: Analyzer-specific sandbox identifier (not all data sources).
passwords: Password list for unpacking artifact and/or
its attachments (not all data sources).
"""

def __init__(
self,
artifact_uuid: uuid.UUID,
image_id: Optional[str] = None,
passwords: Optional[Iterable[str]] = None,
):
super().__init__()
self._data["artifact"] = {"uuid": str(artifact_uuid)}
if image_id is not None:
self._data["imageID"] = image_id
if passwords is not None:
self._data["passwords"] = list(passwords)

Expand Down Expand Up @@ -341,7 +337,10 @@ def artifact(self) -> RefView:

@property
def image_id(self) -> Optional[str]:
"""Analyzer-specific image id."""
"""Analyzer-specific image id.
.. deprecated:: 2.13 Always empty. Will be removed in future releases.
"""
return self._get_optional("imageID")

@property
Expand Down
44 changes: 34 additions & 10 deletions cybsi/api/observable/entities_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def aggregate(
entity_type: Optional[EntityTypes] = None,
key_type: Optional[EntityKeyTypes] = None,
key: Optional[str] = None,
suggest: Optional[str] = None,
sections: Optional[Iterable[EntityAggregateSections]] = None,
forecast_at: Optional[datetime] = None,
cursor: Optional[Cursor] = None,
Expand All @@ -188,27 +189,36 @@ def aggregate(
.. versionchanged:: 2.11
Added new parameter `dict_item_uuid`.
.. versionchanged:: 2.13
Added new parameter `suggest`.
Note:
Calls `GET /observable/entities`.
To get entity aggregate, only one of [key, entity_uuids] parameters
should be specified else Cybsi API will return error.
Args:
entity_uuids: Entity uuids.
Excludes parameters: `dict_item_uuid`, `entity_type`, `key_type`, `key`.
Excludes parameters: `dict_item_uuid`, `entity_type`, `key_type`, `key`,
`suggest`.
dict_item_uuid: Dictionary item which is attributed to the entity.
Excludes parameters: `entity_uuids`, `entity_type`, `key_type`, `key`.
Excludes parameters: `entity_uuids`, `entity_type`, `key_type`, `key`,
`suggest`.
entity_type: Entity type.
Excludes parameter `entity_uuids`, `dict_item_uuid` and
requires parameter `key`. The parameter is not required if
the `entity_type` can be uniquely determined by `key_type`.
key_type: Entity natural key type.
Excludes parameter `entity_uuids`, `dict_item_uuid` and
Excludes parameter `entity_uuids`, `dict_item_uuid`, `suggest` and
requires parameter `key`. The parameter is not required if
only one `key_type` is used for the specified `entity_type`.
key: Entity natural key value. Required if `entity_type` or `key_type`
parameter is specified.
key: Entity natural key value. Excludes parameter `suggest` and required
if `entity_type` or `key_type` parameter is specified.
It is possible to pass a key value in a non-canonical representation.
suggest: Case-insensitive prefix of natural key or value of
`identity.Names` attribute. Excludes parameter `key` and can be used
with `entity_type` parameter.
`suggest` length must greater than or equals to 2.
sections: Sections to be aggregated.
forecast_at: Point of time to aggregate sections at.
cursor: Page cursor.
Expand Down Expand Up @@ -268,6 +278,8 @@ def aggregate(
params["keyType"] = key_type.value
if key is not None:
params["key"] = key
if suggest is not None:
params["suggest"] = suggest
if sections is not None:
params["section"] = [section.value for section in sections]
if forecast_at is not None:
Expand Down Expand Up @@ -648,6 +660,7 @@ async def aggregate(
entity_type: Optional[EntityTypes] = None,
key_type: Optional[EntityKeyTypes] = None,
key: Optional[str] = None,
suggest: Optional[str] = None,
sections: Optional[Iterable[EntityAggregateSections]] = None,
forecast_at: Optional[datetime] = None,
cursor: Optional[Cursor] = None,
Expand All @@ -658,27 +671,36 @@ async def aggregate(
.. versionchanged:: 2.11
Added new parameter `dict_item_uuid`.
.. versionchanged:: 2.13
Added new parameter `suggest`.
Note:
Calls `GET /observable/entities`.
To get entity aggregate, only one of [key, entity_uuids] parameters
should be specified else Cybsi API will return error.
Args:
entity_uuids: Entity uuids.
Excludes parameters: `dict_item_uuid`, `entity_type`, `key_type`, `key`.
Excludes parameters: `dict_item_uuid`, `entity_type`, `key_type`, `key`,
`suggest`.
dict_item_uuid: Dictionary item which is attributed to the entity.
Excludes parameters: `entity_uuids`, `entity_type`, `key_type`, `key`.
Excludes parameters: `entity_uuids`, `entity_type`, `key_type`, `key`,
`suggest`.
entity_type: Entity type.
Excludes parameter `entity_uuids`, `dict_item_uuid` and
requires parameter `key`. The parameter is not required if
the `entity_type` can be uniquely determined by `key_type`.
key_type: Entity natural key type.
Excludes parameter `entity_uuids`, `dict_item_uuid` and
Excludes parameter `entity_uuids`, `dict_item_uuid`, `suggest` and
requires parameter `key`. The parameter is not required if
only one `key_type` is used for the specified `entity_type`.
key: Entity natural key value. Required if `entity_type` or `key_type`
parameter is specified.
key: Entity natural key value. Excludes parameter `suggest` and required
if `entity_type` or `key_type` parameter is specified.
It is possible to pass a key value in a non-canonical representation.
suggest: Case-insensitive prefix of natural key or value of
`identity.Names` attribute. Excludes parameter `key` and can be used
with `entity_type` parameter.
`suggest` length must greater than or equals to 2.
sections: Sections to be aggregated.
forecast_at: Point of time to aggregate sections at.
cursor: Page cursor.
Expand All @@ -702,6 +724,8 @@ async def aggregate(
params["keyType"] = key_type.value
if key is not None:
params["key"] = key
if suggest is not None:
params["suggest"] = suggest
if sections is not None:
params["section"] = [section.value for section in sections]
if forecast_at is not None:
Expand Down
5 changes: 4 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,10 @@ Entity views
API Changes
-----------

Breaking API changes are documented here. There's no such changes yet.
Breaking API changes are documented here.

Version 2.13
- Removed `image_id` from :class:`cybsi.api.enrichment.tasks.ArtifactAnalysisParamsForm`

Licensing
---------
Expand Down

0 comments on commit eee8224

Please sign in to comment.