Class: RuboCop::Cop::Paraxial::SQL
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Paraxial::SQL
- Includes:
- ConfigurableEnforcedStyle
- Defined in:
- lib/rubocop/cop/paraxial/sql.rb
Overview
This cop checks that Active Record queries use literal keys in all of their conditions. Using dynamic keys in queries can make code susceptible to SQL injection attacks.
Constant Summary collapse
- MSG =
'SQL injection via dynamic query key.'
- RESTRICT_ON_SEND =
%i[ all average calculate count count_by_sql create_with delete_all delete_by destroy_all destroy_by exists? find_by find_by! find_by_sql find_or_create_by find_or_create_by! find_or_initialize_by find_or_initialize_by! first from group having joins last lock maximum minimum named_scope not order pluck reorder reselect rewhere scope select sql sum update_all where ].freeze
Instance Method Summary collapse
Instance Method Details
#matching_send?(node) ⇒ Boolean
102 103 104 |
# File 'lib/rubocop/cop/paraxial/sql.rb', line 102 def matching_send?(node) style == :all ? true : params?(node) end |
#on_send(node) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/rubocop/cop/paraxial/sql.rb', line 106 def on_send(node) return if object_manipulation?(node) return unless non_literal_condition?(node) add_offense(node) end |