Signature update services may not expose new signatures for workers immediately #232
Labels
accepted
This issue was accepted, we will work on this at some point
bug
Something isn't working
pending review
service-base
Describe the bug
I've observed it originally when testing my service, but I was also able to reproduce it with the YARA service. When updating signatures from a source, the updater service (base from AL library) sends new data to Elasticsearch (
do_source_update
), and then notifies another thread to get a new signature package from Elasticsearch (do_local_update
), and then finally serves it to worker services.When uploading data to Elastic, the updater through signature client makes a synchronous call, but does not request to wait for shreds to be refreshed. By default, Elastic finishes the bulk request independently of the refreshing. Effectively, if the Elastic isn't quick enough or the updater slow enough, the new signatures are not visible yet when the updater asks for a new signature package. Effectively, new updates are not downloaded back to the updater and are not exposed to the workers until another update of local files (worst case: on next scheduled update, e.g. next day).
To Reproduce
Steps to reproduce the behavior:
Imported 1/1 signatures from example into Assemblyline
), but also a logNo signature updates available.
shortly after.Expected behavior
After successful update from source, data are immediately or in a short time available to download by workers.
The bulk API from Elastic exposes a parameter
refresh
requesting Elastic to e.g. wait for the refresh. By default, it does not wait. I did tests by hardcordingwait_for
value in thebulk()
method indatastore/collection.py
fromassemblyline_base
repo, and it fixed the problem. However, I don't know if it was intentionally not set or it has any other side effects somewhere else.Screenshots
Environment (please complete the following information if pertinent):
Additional context
During the debugging, I've confirmed that the Elasticsearch is just returning old last modified timestamp, it's not the issue in the service itself. This is a race condition, and I'm aware it may be harder to spot with more sources or different Elastic configuration. I believe it should generally be consistent, and if it's not just that the Elasticsearch in my configuration is slow, the impact may sometimes be rather big (e.g. Yara rules used a day later than expected).
The text was updated successfully, but these errors were encountered: