Sha256: 9d1badccd39f94fa71da16c1e26cd9a7b4bf259074f80fb75063a5ba4afe6c35

Contents?: true

Size: 929 Bytes

Versions: 6792

Compression:

Stored size: 929 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Security
      # This cop checks for the use of YAML class methods which have
      # potential security issues leading to remote code execution when
      # loading from an untrusted source.
      #
      # @example
      #   # bad
      #   YAML.load("--- foo")
      #
      #   # good
      #   YAML.safe_load("--- foo")
      #   YAML.dump("foo")
      #
      class YAMLLoad < Cop
        MSG = 'Prefer using `YAML.safe_load` over `YAML.load`.'.freeze

        def_node_matcher :yaml_load, <<-PATTERN
          (send (const {nil? cbase} :YAML) :load ...)
        PATTERN

        def on_send(node)
          yaml_load(node) do
            add_offense(node, location: :selector)
          end
        end

        def autocorrect(node)
          ->(corrector) { corrector.replace(node.loc.selector, 'safe_load') }
        end
      end
    end
  end
end

Version data entries

6,792 entries across 6,786 versions & 25 rubygems

Version Path
ory-client-0.0.1.alpha74 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-client-0.0.1.alpha73 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-client-0.0.1.alpha72 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-client-0.0.1.alpha71 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-client-0.0.1.alpha70 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-client-0.0.1.alpha69 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-client-0.0.1.alpha68 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-client-0.0.1.alpha67 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-client-0.0.1.alpha66 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-oathkeeper-client-0.38.19.beta1 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-oathkeeper-client-0.38.18.beta1 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-oathkeeper-client-0.38.17.beta1 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
avalara_sdk-2.4.7 vendor/bundle/ruby/2.6.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-client-0.0.1.alpha58 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-client-0.0.1.alpha57 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-client-0.0.1.alpha56 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-client-0.0.1.alpha55 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-client-0.0.1.alpha54 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-client-0.0.1.alpha53 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb
ory-client-0.0.1.alpha52 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/security/yaml_load.rb