Sha256: 6e9429618740b89b2945408bccfbff49c54a185d6e44041b559f131c40117492
Contents?: true
Size: 988 Bytes
Versions: 4
Compression:
Stored size: 988 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop module Security # This cop checks for the use of Marshal class methods which have # potential security issues leading to remote code execution when # loading from an untrusted source. # # @example # # bad # Marshal.load("{}") # Marshal.restore("{}") # # # good # Marshal.dump("{}") # # # okish - deep copy hack # Marshal.load(Marshal.dump({})) # class MarshalLoad < Base MSG = 'Avoid using `Marshal.%<method>s`.' def_node_matcher :marshal_load, <<~PATTERN (send (const {nil? cbase} :Marshal) ${:load :restore} !(send (const {nil? cbase} :Marshal) :dump ...)) PATTERN def on_send(node) marshal_load(node) do |method| add_offense(node.loc.selector, message: format(MSG, method: method)) end end end end end end
Version data entries
4 entries across 4 versions & 2 rubygems