CERT-Polska / karton

Distributed malware processing framework based on Python, Redis and S3.
https://karton-core.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
381 stars 45 forks source link

Fix issues with `register_tasks` and empty tasks list #237

Closed nazywam closed 8 months ago

nazywam commented 8 months ago

Closes #236

When backend.register_tasks - https://github.com/CERT-Polska/karton/blob/2d10bd432928354a2030a0ee8aa976b64f4acb63/karton/core/backend.py#L542 is called with an empty list of tasks to create it results in a crash when calling mset:

redis.exceptions.ResponseError: wrong number of arguments for 'mset' command

Reproduction: Downgrade to <4.4.0, create a new task and create a new "NOP" operational task by setting the task status to its current value:

producer = Producer(identity="test-producer")
headers = {
    "kind": "raw",
    "type": "sample"
}
t = Task(headers=headers, payload={
    "sample": "sample",
})
producer.send_task(t)
producer.backend.set_task_status(t, TaskState.DECLARED)