Sha256: 7e11da5aff49cac6d5424606ea5402e9e1624357d0f857016a2c83944c0b08e4

Contents?: true

Size: 713 Bytes

Versions: 6778

Compression:

Stored size: 713 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Security
      # This cop checks for the use of `Kernel#eval` and `Binding#eval`.
      #
      # @example
      #
      #   # bad
      #
      #   eval(something)
      #   binding.eval(something)
      class Eval < Cop
        MSG = 'The use of `eval` is a serious security risk.'.freeze

        def_node_matcher :eval?, <<-PATTERN
          (send {nil? (send nil? :binding)} :eval $!str ...)
        PATTERN

        def on_send(node)
          eval?(node) do |code|
            return if code.dstr_type? && code.recursive_literal?

            add_offense(node, location: :selector)
          end
        end
      end
    end
  end
end

Version data entries

6,778 entries across 6,772 versions & 24 rubygems

Version Path
cybrid_api_bank_ruby-0.123.111 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_organization_ruby-0.123.111 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_id_ruby-0.123.111 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_id_ruby-0.123.110 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_bank_ruby-0.123.110 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_organization_ruby-0.123.110 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_bank_ruby-0.123.109 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_organization_ruby-0.123.109 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_id_ruby-0.123.109 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_bank_ruby-0.123.107 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_organization_ruby-0.123.107 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_id_ruby-0.123.107 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_bank_ruby-0.123.106 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_organization_ruby-0.123.106 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_id_ruby-0.123.106 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_organization_ruby-0.123.105 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_bank_ruby-0.123.105 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_id_ruby-0.123.105 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_bank_ruby-0.123.104 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb
cybrid_api_id_ruby-0.123.104 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/eval.rb