
Detecting Malicious Threats Using Ruby on Rails
Ever wonder how to scan any file for a virus on file upload in a Rails application?
We have been using a ruby wrapper to an open source antivirus engine ClamAV®, for detecting trojans, viruses, malware & other malicious threats.
Dependencies
First, you need to install ClamAV’s clamscan binary and/or have clamdscan daemon running on your server. Run following commands to install required binaries:sudo apt-get install clamav
sudo apt-get install clamav-daemon
sudo service clamav-daemon restart
Optional
If you face any errors related to “clamav-daemon”, run following commands.sudo freshclam
sudo service clamav-daemon restart
Now we need to install a ruby wrapper clam_scan written for ClamAV® library.
Gem Installation
gem 'clam_scan' #in Gemfile
bundle
How To Scan a file?
It is quite easy to scan any file/input stream using the wrapper.
How to Delete Infected File?
Here is a simple configuration to remove infected files:
Have A Safe Application! 🙂
Thank you for reading!
At BoTree Technologies, we build enterprise applications with our RoR team of 25+ engineers.
We also specialize in Python, RPA, AI, Django, JavaScript and ReactJS.
Consulting is free – let us help you grow!
