Module: Immunio::IOHooks

Defined in:
lib/immunio/plugins/io.rb

Class Method Summary collapse

Class Method Details

.inject(mod, name, methods) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/immunio/plugins/io.rb', line 6

def self.inject(mod, name, methods)
  mod.class_eval "    def self.extended(base)                                        # def self.extended(base)\n      \#{methods.inspect}.each do |method|                          #   [\"read\", \"binread\"].each do |method|\n        base.singleton_class.alias_method_chain method, :immunio   #     base.singleton_class.alias_method_chain method, :immunio\n      end                                                          #   end\n    end                                                            # end\n\n    def self.included(base)                                        # def self.included(base)\n      \#{methods.inspect}.each do |method|                          #   [\"read\", \"binread\"].each do |method|\n        base.alias_method_chain method, :immunio                   #     base.alias_method_chain method, :immunio\n      end                                                          #   end\n    end                                                            # end\n  EOF\n  Immunio.logger.debug \"IO: successfully chained \#{name} \#{methods}\"\n  methods.each do |method|\n    mod.class_eval <<-EOF\n      def \#{method}_with_immunio(*args, &block)                    # def read_with_immunio(*args, &block)\n        Request.time \"plugin\", \"IO::\#{method}\" do                  #\n          strict_context, loose_context, stack, loose_stack = Immunio::Context.context()\n          Immunio.run_hook! \"io\", \"file_io\",                       #   Immunio.run_hook! \"io\", \"open\",\n                          method: \"\#{name}\#{method}\",              #      open_method: \"IO.read\",\n                          parameters: args,                        #      parameters: args\n                          stack: loose_stack,                      #\n                          context_key: loose_context,              #\n                          cwd: Dir.pwd\n          Request.pause \"plugin\", \"IO::\#{method}\" do               #\n            \#{method}_without_immunio(*args, &block)               #   read_without_immunio(*args, &block)\n          end\n        end\n      end                                                          # end\n    EOF\n    Immunio.logger.debug \"IO: successfully created hook for \#{name} \#{method}\"\n  end\nend\n"