Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: setup rack-protection #674

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ AllCops:
Metrics/BlockLength:
Exclude:
- Rakefile
ExcludedMethods:
- route

Naming/RescuedExceptionsVariableName:
PreferredName: error
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gem 'html2rss-configs', github: 'html2rss/html2rss-configs'
gem 'erubi'
gem 'parallel'
gem 'rack-cache'
gem 'rack-protection'
gem 'rack-timeout'
gem 'rack-unreloader'
gem 'roda'
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ GEM
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
base64 (0.2.0)
byebug (11.1.3)
concurrent-ruby (1.3.4)
crass (1.0.6)
Expand Down Expand Up @@ -73,6 +74,9 @@ GEM
rack (3.1.7)
rack-cache (1.17.0)
rack (>= 0.4)
rack-protection (4.0.0)
base64 (>= 0.1.0)
rack (>= 3.0.0, < 4)
rack-timeout (0.7.0)
rack-unreloader (2.1.0)
rainbow (3.1.1)
Expand Down Expand Up @@ -158,6 +162,7 @@ DEPENDENCIES
parallel
puma
rack-cache
rack-protection
rack-timeout
rack-unreloader
rake
Expand Down
13 changes: 8 additions & 5 deletions config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@
require 'rubygems'
require 'bundler/setup'
require 'rack-timeout'
require 'rack/protection'
require 'rack/protection/path_traversal'

use Rack::Timeout

dev = ENV.fetch('RACK_ENV', nil) == 'development'
use Rack::Protection
use Rack::Protection::PathTraversal

requires = Dir['app/**/*.rb']

if dev
if ENV.fetch('RACK_ENV', nil) == 'development'
require 'logger'
require 'rack/unreloader'

logger = Logger.new($stdout)

require 'rack/unreloader'
Unreloader = Rack::Unreloader.new(subclasses: %w[Roda Html2rss],
logger:,
reload: dev) do
reload: true) do
Html2rss::Web::App
end
Unreloader.require('app.rb') { 'Html2rss::Web::App' }
Expand Down