Class: RuboCop::Cop::SidekiqEnt::EncryptionWithManyArguments
- Includes:
- Sidekiq::Language
- Defined in:
- lib/rubocop/cop/sidekiq_ent/encryption_with_many_arguments.rb
Overview
Checks that encrypted jobs use proper argument structure.
Sidekiq Enterprise encryption only encrypts the last argument. If sensitive data is passed in non-last arguments, it won't be encrypted.
Constant Summary collapse
- MSG =
'Encrypted jobs should use a secret bag pattern. ' \ 'Only the last argument is encrypted; consider consolidating sensitive data.'
- MAX_RECOMMENDED_ARGS =
2
Instance Method Summary collapse
- #encryption_enabled?(node) ⇒ Object
- #on_send(node) ⇒ Object (also: #on_csend)
Methods included from Sidekiq::Language
#active_job_class?, #perform_call?, #sidekiq_include?, #sidekiq_options_call?
Methods inherited from Base
#limiter_creation?, #unique_for_option?, #unique_until_option?
Instance Method Details
#encryption_enabled?(node) ⇒ Object
39 40 41 |
# File 'lib/rubocop/cop/sidekiq_ent/encryption_with_many_arguments.rb', line 39 def_node_matcher :encryption_enabled?, "(send nil? :sidekiq_options (hash <(pair (sym :encrypt) {(true) (sym :true)}) ...>))\n" |
#on_send(node) ⇒ Object Also known as: on_csend
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rubocop/cop/sidekiq_ent/encryption_with_many_arguments.rb', line 43 def on_send(node) return unless encryption_enabled?(node) class_node = node.each_ancestor(:class).first return unless class_node perform_method = find_perform_method(class_node) return unless perform_method arg_count = perform_method.arguments.size add_offense(perform_method.loc.name) if arg_count > max_args end |