Skip to content

Commit

Permalink
Hotfix for normalizer API bug (#3475)
Browse files Browse the repository at this point in the history
Signed-off-by: Donny Peeters <[email protected]>
  • Loading branch information
Donnype authored Sep 5, 2024
1 parent 1e27332 commit 9804153
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
17 changes: 11 additions & 6 deletions mula/scheduler/server/handlers/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,16 @@ def list(
]
}
elif task_type == "normalizer":
f_plugin = storage.filters.Filter(
column="data",
field="normalizer__id",
operator="eq",
value=plugin_id,
)
f_plugin = {
"and": [
storage.filters.Filter(
column="data",
field="normalizer__id",
operator="eq",
value=plugin_id,
)
]
}
else:
f_plugin = {
"or": [
Expand Down Expand Up @@ -182,6 +186,7 @@ def list(
detail=f"invalid filter(s) [exception: {exc}]",
) from exc
except storage.errors.StorageError as exc:
self.logger.exception(exc)
raise fastapi.HTTPException(
status_code=fastapi.status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=f"error occurred while accessing the database [exception: {exc}]",
Expand Down
7 changes: 7 additions & 0 deletions mula/tests/integration/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,13 @@ def test_get_tasks_min_created_at_future(self):
self.assertEqual(200, response.status_code)
self.assertEqual(0, len(response.json()["results"]))

def test_get_normalizer_filtered(self):
# This used to be a bug where the normalizer filter was missing a nesting on the operator
params = {"task_type": "normalizer", "plugin_id": "kat_nmap_normalize"}
response = self.client.get("/tasks", params=params)
self.assertEqual(200, response.status_code)
self.assertEqual(0, len(response.json()["results"]))

def test_get_tasks_filtered(self):
response = self.client.post(
"/tasks",
Expand Down

0 comments on commit 9804153

Please sign in to comment.