Sha256: 2e56c4d2848ef7b34a5af9327dccc2552695e4f920adbc1bdb99bc70336bf07b
Contents?: true
Size: 922 Bytes
Versions: 46
Compression:
Stored size: 922 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`.' 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
46 entries across 35 versions & 5 rubygems