Skip to content

dtaniwaki/rack-secure-upload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rack-secure-upload

Gem Version Dependency Status Build Status Coverage Status Code Climate

Upload files securely

Installation

Add the rack-secure-upload gem to your Gemfile.

gem "rack-secure-upload"

And run bundle install.

Rack App

require 'rack-secure-upload'
use Rack::SecureUpload::Middleware, :fsecure
run MyApp

Rails App

In config/application.rb

module MyApp
  class Application < Rails::Application
    config.middleware.insert_before ActionDispatch::ParamsParser, Rack::SecureUpload::Middleware, :avast
  end 
end

Options

You can add some options like below.

use Rack::SecureUpload::Middleware, :fsecure, {foo: :bar}

fallback

  • proc { |env, params, path| }
    • use return value of proc
  • :raise
    • raise Rack::SecureUpload::InsecureFileError |
  • else
    • return 406

AntiVirus Softwares

Avast

  1. Get license
  2. Install the package
wget -c http://files.avast.com/files/linux/avast4workstation-1.3.0-1.i586.rpm
sudo yum localinstall avast4workstation-1.3.0-1.i586.rpm
avast -V # Input your license
avast-update

F-Secure

  1. Get license (Optional)
  2. Install the package
wget http://download.f-secure.com/webclub/f-secure-linux-security-10.00.60.tar.gz
tar xvzf f-secure-linux-security-10.00.60.tar.gz
sudo ./f-secure-linux-security-10.00.60/f-secure-linux-security-10.00.60

Test this middleware

  1. Download eicar test file
  2. Upload it

You can try this with sample app

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Copyright

Copyright (c) 2014 Daisuke Taniwaki. See LICENSE for details.