File names containing spaces will not be moved out of queue
kayla-tokash opened this issue · 6 comments
Describe the bug
The "scanner.sh" script does not escape spaces in file names. As result, files with spaces in their name, e.g. "Some file name.zip", will not be moved out of the queue after being processed for malware.
To Reproduce
Steps to reproduce the behavior:
- Add a file with spaces in the name, e.g. "Some file name.zip", to the queue
- Check the "inotify" process's log "/var/log/supervisor/inotify-stderr.log" for errors like "cannot stat file 'name.zip'".
- Check the "okay" and "not okay" directories, and observe the file will not be in either directory.
- Check the "queue" directory, and observe the file will still be in the queue.
- Watch the "clamscan" and "mallet" processes using top in the container, and observer they are not still processing, i.e. neither process should still exist in the list.
Expected behavior
A file with spaces in the name, e.g. "Some file name.zip", will be scanned by clamav and maldet, and then moved from the "queue" directory to the the appropriate "okay" or "not okay" directory.
Editing for clarity.
The problem is with "scanner.sh". The two lines where '$file' is referenced need the variable in quotes.
I also noticed that launcher.sh is not actually monitoring recursively. I've fixed this myself and would go and push in a PR but I can see yours still hasn't even been reviewed by the repo owner.
As such, the fix to get true recursive monitoring in the queue folder is to edit the launcher.sh script where it says "/data/av/queue" to then say "/data/av/queue/" without that last slash, it won't be recursive. Thank you for your patch as well as I will certainly be using it myself 👍
I also noticed that launcher.sh is not actually monitoring recursively. I've fixed this myself and would go and push in a PR but I can see yours still hasn't even been reviewed by the repo owner.
As such, the fix to get true recursive monitoring in the queue folder is to edit the launcher.sh script where it says "/data/av/queue" to then say "/data/av/queue/" without that last slash, it won't be recursive. Thank you for your patch as well as I will certainly be using it myself +1
Actually, with my patch first I was able to have true recursive scanning in queue folder. After adding yours I lost that ability so I will likely need to figure out what needs to be adjusted in the scanner.sh for both fixes to work.
Alright, I believe I only encountered an illusion of fixing recursive monitoring with my initial fix. I believe the issue was not encountered on those test runs because I ran rm -rf on the nested folder inside queue and then quickly reran the copy command to bring it back. inotify must have still been running somehow when the copy was run but only because it was triggered by file removal... Nope, it does work when it's just my initial change. Something in the file variable for scanner.sh being made to function properly breaks my change again lol. Will update soon with final change info.
Building the container from git clone after changing the launcher.sh recursion as I initially stated appears to also work with spaces inside of recursed folders just fine. So, perhaps this is an alternate solution to your PR as well :)