Sha256: d956f06e6bae55aa4106ac295d304c738bd916cd8e5ab976e4c5cc1862d604c7
Contents?: true
Size: 813 Bytes
Versions: 10
Compression:
Stored size: 813 Bytes
Contents
module Security class RejectAllRequestsLocal < RuboCop::Cop::Base RAILS_ENV = ['integration', 'staging', 'production'] MSG = "RAILS CONFIG: Restrict usage of option 'consider_all_requests_local' on #{RAILS_ENV.join(', ')} envs" def_node_matcher "consider_all_requests_local", '(send (send nil :config) :consider_all_requests_local= (true))' def on_send(node) source = node.source file_name = node.loc.operator.to_s add_offense(node.loc.selector) if found_match(source) && block_listed?(file_name) end def block_listed?(string) RAILS_ENV.each_with_object([]) do |env, results| results << string.include?(env) end.any?(true) end def found_match(string) /config.consider_all_requests\S?.*=\s?.*true/.match?(string) end end end
Version data entries
10 entries across 10 versions & 1 rubygems