Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.27.10
-------
- Add sub_tenant_ids filter to devices and incidents history queries

1.27.9
-------
- Add rule_id to AnalysisSkippedByRuleError with the id of the rule that skipped the analysis
Expand Down
2 changes: 1 addition & 1 deletion intezer_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.27.9'
__version__ = '1.27.10'
5 changes: 5 additions & 0 deletions intezer_sdk/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def generate_devices_history_search_filters(*,
host_types: list[str] = None,
last_login_users: list[str] = None,
site_names: list[str] = None,
sub_tenant_ids: list[str] = None,
include_raw_device: bool = None) -> dict[str, Any]:
filters = {}
time_range_start_timestamp = int(time_range_start.timestamp()) if time_range_start else None
Expand All @@ -65,6 +66,7 @@ def generate_devices_history_search_filters(*,
add_filter(filters, 'host_types', host_types)
add_filter(filters, 'last_login_users', last_login_users)
add_filter(filters, 'site_names', site_names)
add_filter(filters, 'sub_tenant_ids', sub_tenant_ids)
add_filter(filters, 'include_raw_device', include_raw_device)

return filters
Expand All @@ -91,6 +93,7 @@ def query_devices_history(*,
host_types: list[str] = None,
last_login_users: list[str] = None,
site_names: list[str] = None,
sub_tenant_ids: list[str] = None,
include_raw_device: bool = None) -> DevicesHistoryResult:
"""
Query devices history with query param.
Expand All @@ -115,6 +118,7 @@ def query_devices_history(*,
:param host_types: Query devices only with these host types (e.g. server, workstation).
:param last_login_users: Query devices only with these last login users.
:param site_names: Query devices only with these site names.
:param sub_tenant_ids: Query devices only from these sub-tenants.
:param include_raw_device: Include raw device data in the results.

:return: Device query result from server as Results iterator.
Expand All @@ -140,6 +144,7 @@ def query_devices_history(*,
host_types=host_types,
last_login_users=last_login_users,
site_names=site_names,
sub_tenant_ids=sub_tenant_ids,
include_raw_device=include_raw_device,
)

Expand Down
5 changes: 5 additions & 0 deletions intezer_sdk/incidents.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def generate_incidents_history_search_filters(*,
free_text: str = None,
sort_by: list[str] = None,
sort_order: str = None,
sub_tenant_ids: list[str] = None,
include_raw_incident: bool = None) -> dict[str, Any]:
filters = {}
start_timestamp = int(start_time.timestamp()) if start_time else None
Expand All @@ -65,6 +66,7 @@ def generate_incidents_history_search_filters(*,
add_filter(filters, 'free_text', free_text)
add_filter(filters, 'sort_by', sort_by)
add_filter(filters, 'sort_order', sort_order)
add_filter(filters, 'sub_tenant_ids', sub_tenant_ids)
add_filter(filters, 'include_raw_incident', include_raw_incident)

return filters
Expand All @@ -90,6 +92,7 @@ def query_incidents_history(*,
free_text: str = None,
sort_by: list[str] = None,
sort_order: str = None,
sub_tenant_ids: list[str] = None,
include_raw_incident: bool = None) -> IncidentsHistoryResult:
"""
Query for incidents history with query param.
Expand All @@ -113,6 +116,7 @@ def query_incidents_history(*,
:param free_text: Query incidents that contain this text in the following fields: name, severity, status, related_alert_ids.
:param sort_by: Sort incidents only with this sort_by_key value (creation_time / received_time / triage_time / triage_change_time / risk_score).
:param sort_order: The order to sort the incidents by (asc / desc).
:param sub_tenant_ids: Query incidents only from these sub-tenants.
:param include_raw_incident: Include the raw incident data in the results.

:return: Incident query result from server as Results iterator.
Expand All @@ -138,6 +142,7 @@ def query_incidents_history(*,
free_text=free_text,
sort_by=sort_by,
sort_order=sort_order,
sub_tenant_ids=sub_tenant_ids,
include_raw_incident=include_raw_incident,
)

Expand Down
15 changes: 14 additions & 1 deletion tests/unit/test_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test_generate_devices_history_search_filters_with_all_parameters(self):
host_types = ['server', 'workstation']
last_login_users = ['user1', 'user2']
site_names = ['site1', 'site2']
sub_tenant_ids = ['sub_tenant1', 'sub_tenant2']

# Act
result = generate_devices_history_search_filters(
Expand All @@ -53,7 +54,8 @@ def test_generate_devices_history_search_filters_with_all_parameters(self):
cloud_providers=cloud_providers,
host_types=host_types,
last_login_users=last_login_users,
site_names=site_names
site_names=site_names,
sub_tenant_ids=sub_tenant_ids
)

# Assert
Expand All @@ -75,6 +77,7 @@ def test_generate_devices_history_search_filters_with_all_parameters(self):
self.assertEqual(result['host_types'], host_types)
self.assertEqual(result['last_login_users'], last_login_users)
self.assertEqual(result['site_names'], site_names)
self.assertEqual(result['sub_tenant_ids'], sub_tenant_ids)

def test_generate_devices_history_search_filters_with_none_parameters(self):
# Arrange & Act
Expand Down Expand Up @@ -114,6 +117,16 @@ def test_query_devices_history_with_search_mode(self):
self.assertIsInstance(result, DevicesHistoryResult)
self.assertEqual(result._search_mode, 'or')

def test_query_devices_history_with_sub_tenant_ids(self):
# Arrange
sub_tenant_ids = ['sub_tenant1']

# Act
result = query_devices_history(sub_tenant_ids=sub_tenant_ids)

# Assert
self.assertEqual(result.filters['sub_tenant_ids'], sub_tenant_ids)

def test_device_init(self):
# Arrange
device_id = 'test_device_id'
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/test_incidents.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test_generate_incidents_history_search_filters_with_all_parameters(self):
free_text = 'test search'
sort_by = ['creation_time']
sort_order = 'desc'
sub_tenant_ids = ['sub_tenant1', 'sub_tenant2']
include_raw_incident = True

# Act
Expand All @@ -55,6 +56,7 @@ def test_generate_incidents_history_search_filters_with_all_parameters(self):
free_text=free_text,
sort_by=sort_by,
sort_order=sort_order,
sub_tenant_ids=sub_tenant_ids,
include_raw_incident=include_raw_incident
)

Expand All @@ -77,6 +79,7 @@ def test_generate_incidents_history_search_filters_with_all_parameters(self):
self.assertEqual(result['free_text'], free_text)
self.assertEqual(result['sort_by'], sort_by)
self.assertEqual(result['sort_order'], sort_order)
self.assertEqual(result['sub_tenant_ids'], sub_tenant_ids)
self.assertEqual(result['include_raw_incident'], include_raw_incident)

def test_generate_incidents_history_search_filters_with_none_parameters(self):
Expand Down Expand Up @@ -106,6 +109,16 @@ def test_query_incidents_history_returns_incidents_incidents_result(self):
# Assert
self.assertIsInstance(result, IncidentsHistoryResult)

def test_query_incidents_history_with_sub_tenant_ids(self):
# Arrange
sub_tenant_ids = ['sub_tenant1']

# Act
result = query_incidents_history(sub_tenant_ids=sub_tenant_ids)

# Assert
self.assertEqual(result.filters['sub_tenant_ids'], sub_tenant_ids)

def test_incident_init(self):
# Arrange
incident_id = 'test_incident_id'
Expand Down
Loading