From 92bc2978b0dcb7db3a510f68ef1692fda0583031 Mon Sep 17 00:00:00 2001 From: Steve Garon Date: Fri, 23 Apr 2021 13:36:59 +0000 Subject: [PATCH 1/4] Fix delete favorites to use json encoded data --- assemblyline_client/v4_client/module/user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assemblyline_client/v4_client/module/user.py b/assemblyline_client/v4_client/module/user.py index f5f392b..8c8e502 100644 --- a/assemblyline_client/v4_client/module/user.py +++ b/assemblyline_client/v4_client/module/user.py @@ -68,7 +68,7 @@ def delete(self, username, fav_type, name): Throws a Client exception if the user does not exist. """ - return self._connection.delete(api_path('user', 'favorites', username, fav_type), data=name) + return self._connection.delete(api_path('user', 'favorites', username, fav_type), json=name) def update(self, username, favorites): """\ From fd902168b47ef3dcab7fdcf4ee48c29f249eb5f5 Mon Sep 17 00:00:00 2001 From: Steve Garon Date: Fri, 23 Apr 2021 13:37:24 +0000 Subject: [PATCH 2/4] Fix test_help to work if tos is there or not --- test/test_help.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_help.py b/test/test_help.py index 1a7c324..268fd45 100644 --- a/test/test_help.py +++ b/test/test_help.py @@ -21,4 +21,4 @@ def test_constants(client): def test_tos(client): res = client.help.tos() - assert res is None + assert res is None or isinstance(res, str) From ea1ca9fa003111bb5b7a6f35b2d4056a1071d714 Mon Sep 17 00:00:00 2001 From: Steve Garon Date: Fri, 23 Apr 2021 13:38:00 +0000 Subject: [PATCH 3/4] Switch searches to use POST instead of GET --- .../v4_client/module/search/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/assemblyline_client/v4_client/module/search/__init__.py b/assemblyline_client/v4_client/module/search/__init__.py index 5bf3972..91f24fb 100644 --- a/assemblyline_client/v4_client/module/search/__init__.py +++ b/assemblyline_client/v4_client/module/search/__init__.py @@ -1,3 +1,5 @@ +import json + from assemblyline_client.v4_client.common.utils import SEARCHABLE, ClientError, api_path from assemblyline_client.v4_client.module.search.facet import Facet from assemblyline_client.v4_client.module.search.fields import Fields @@ -26,14 +28,12 @@ def _do_search(self, bucket, query, **kwargs): if isinstance(filters, str): filters = [filters] - filters = [('filters', fq) for fq in filters] + kwargs['filters'] = filters - kwargs = {k: v for k, v in kwargs.items() if v is not None and k != 'filters'} + kwargs = {k: v for k, v in kwargs.items() if v is not None} kwargs['query'] = query - if filters is not None: - kwargs['params_tuples'] = filters - path = api_path('search', bucket, **kwargs) - return self._connection.get(path) + path = api_path('search', bucket) + return self._connection.post(path, data=json.dumps(kwargs)) def alert(self, query, filters=None, fl=None, offset=0, rows=25, sort=None, timeout=None): """\ From fb22c2d871bc2c61d69af2dcdac737283d89a3bf Mon Sep 17 00:00:00 2001 From: Steve Garon Date: Fri, 23 Apr 2021 13:43:11 +0000 Subject: [PATCH 4/4] delete_matching was renamed delete_by_query --- test/test_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_service.py b/test/test_service.py index ceacb1e..065a998 100644 --- a/test/test_service.py +++ b/test/test_service.py @@ -29,7 +29,7 @@ def test_add_service(datastore, client): # Cleanup so the new service does not interfere with other tests datastore.service_delta.delete('ResultSample') - datastore.service.delete_matching('name:ResultSample') + datastore.service.delete_by_query('name:ResultSample') datastore.service.commit() datastore.service_delta.commit()