CERT-Polska / drakvuf-sandbox

DRAKVUF Sandbox - automated hypervisor-level malware analysis system
https://drakvuf-sandbox.readthedocs.io/
Other
1.04k stars 143 forks source link

Warn when Redis is misconfigured #470

Open chivay opened 3 years ago

chivay commented 3 years ago

Failing to install / forgetting setup Redis properly will result in crashes

  1. web UI shouldn't crash with a 500 ISE

It's possible for use the UI in a read-only way when Redis is down. The only thing that won't work is new sample submission. User should be somehow notified that Redis is misconfigured and that uploading failed.

  1. draksetup should warn about missing Redis

Installation works offline and it doesn't need Redis but adding a sanity check and notification that Redis should be configured would be a nice addition.

techathena commented 3 years ago

can you tell me the port number which redis is using or point me to the implementation file? I have made a function to check redis state rn and can continue from that

chivay commented 3 years ago

In both cases we're using https://karton-core.readthedocs.io/en/latest/karton_api.html#karton.core.config.Config

for drakrun: https://github.com/CERT-Polska/drakvuf-sandbox/blob/master/drakrun/drakrun/main.py#L611-L613

for drakcore: https://github.com/CERT-Polska/drakvuf-sandbox/blob/master/drakcore/drakcore/util.py#L21-L45

icedevml commented 3 years ago

I think in terms of implementation, you should try to connect to the Redis specified in config.ini and issue some simple command (for example PING).

manorit2001 commented 3 years ago

~I was trying to work on this but it seems karton will protest if Redis isn't available. SystemService of karton is being used in a lot of places which apparantely is used to instantiate minio backend also in some places~ https://github.com/CERT-Polska/drakvuf-sandbox/blob/9d3c096aaf6d3cb84676cb3d26fd9a3fdad6e0dc/drakcore/drakcore/app.py#L25-L26 ~which is further used in many other api's. So, it seems that minio will also be rendered useless if redis fails, and if that happens the UI won't have anything to play around with in readOnly state ig.~

Also, drak-system won't be able to run at all as it depends totally on the object returned by SystemService in the end service.loop() https://github.com/CERT-Polska/drakvuf-sandbox/blob/9d3c096aaf6d3cb84676cb3d26fd9a3fdad6e0dc/drakcore/drakcore/system.py#L24-L40

EDIT: the first problem is resolved by using get_minio_helper which doesn't depend on karton