Sha256: 93d129e7478c851f7a55c51af8d57d1250ae90ca2344f52540b65b3d28704658
Contents?: true
Size: 919 Bytes
Versions: 4
Compression:
Stored size: 919 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 < Base extend AutoCorrector 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.loc.selector) do |corrector| corrector.replace(node.loc.selector, 'safe_load') end end end end end end end
Version data entries
4 entries across 4 versions & 2 rubygems