Rails / Heroku - How to anti-virus scan uploaded file?

隐身守侯 提交于 2019-12-07 02:16:57

问题


How is it possible to scan a uploaded file for viruses, trojans etc.?

Just thinking about preventing some users to upload some nasty stuff.

I am using Heroku and Amazon S3.


回答1:


check out This

it's support a REST/JSON antivirus web service

Here is the post - https://stackoverflow.com/questions/4104985/antivirus-scanning-service




回答2:


For the passers-by asking the same question:

Metascan. It's free and has a simple API!




回答3:


For anyone approaching this in future we recently created CarrierWave::AttachmentScanner to easily integrate virus and malware scanning into Rails and CarrierWave.

The plugin basically hooks into file uploads using carrierwave and sends the request to a JSON/REST web service to check the files.

If the file matches a known signature then it will raise a CarrierWave:: IntegrityError.




回答4:


Open Source: ClamAV and Clamby

  1. Install ClamAV:

    macOS

    brew install clamav
    

    Ubuntu

    sudo apt-get install clamav clamav-daemon -y
    
  2. Setup after_create callback in your Rails app to scan new Files:

    after_create :scan_for_viruses
    
    def scan_for_viruses
      raise "Virus discovered!" if Clamby.virus?( self.path )
    end
    



回答5:


You could refer to my blog post about running a ClamAV (using Clamby gem) antivirus as a service on Kubernetes and a DRY implementation to use it inside your RoR app:

https://www.shebanglabs.io/rails-antivirus-clamby-clamav/

Also, you can just pick the part that you like and combine it with your stack of choice.



来源:https://stackoverflow.com/questions/9640516/rails-heroku-how-to-anti-virus-scan-uploaded-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!