Sha256: 401be31fd36e52d357929fe09fc25e7fb779ab2e4bcdf7bcbb18af9b9b6c7a48
Contents?: true
Size: 751 Bytes
Versions: 23
Compression:
Stored size: 751 Bytes
Contents
module RuboCop module Cop module Paraxial class System < Base MSG = '`system` causes remote code execution if called on user input.' # Restrict the cop to only the `puts` method RESTRICT_ON_SEND = %i[system].freeze # @!method puts_call?(node) def_node_matcher :system_call?, <<~PATTERN (send nil? :system ...) PATTERN def on_send(node) return unless in_app_directory?(node) system_call?(node) do add_offense(node.loc.selector, message: MSG) end end private def in_app_directory?(node) processed_source.file_path.start_with?(File.join(Dir.pwd, 'app')) end end end end end
Version data entries
23 entries across 23 versions & 1 rubygems