Module: Kernel
- Defined in:
- lib/tcell_agent/instrumentation/monkey_patches/kernel.rb,
lib/tcell_agent/instrumentation/monkey_patches/kernel.rb
Class Method Summary collapse
- .exec(*args) ⇒ Object
- .gets(*args, &block) ⇒ Object
- .open(*args, &block) ⇒ Object
- .readline(*args, &block) ⇒ Object
- .spawn(*args) ⇒ Object
- .system(*args) ⇒ Object
- .tcell_original_1_gets ⇒ Object
- .tcell_original_1_open ⇒ Object
- .tcell_original_1_spawn ⇒ Object
- .tcell_original_1_system ⇒ Object
- .tcell_original_exec ⇒ Object
- .tcell_original_readline ⇒ Object
Instance Method Summary collapse
- #`(cmd) ⇒ Object
- #gets(*args, &block) ⇒ Object
- #open(*args, &block) ⇒ Object
- #readline(*args, &block) ⇒ Object
- #spawn(*args) ⇒ Object
- #system(*args) ⇒ Object
- #tcell_original_2_gets ⇒ Object
- #tcell_original_2_open ⇒ Object
- #tcell_original_2_spawn ⇒ Object
- #tcell_original_2_system ⇒ Object
- #tcell_original_exec ⇒ Object
- #tcell_original_readline ⇒ Object
Class Method Details
.exec(*args) ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 138 def exec(*args) cmd = TCellAgent::Cmdi.parse_command(*args) if TCellAgent::Cmdi.block_command?(cmd) raise "tCell.io Agent: Command not allowed by policy: #{cmd}" end tcell_original_exec(*args) end |
.gets(*args, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 22 def gets(*args, &block) path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode_argf if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode) raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied" end tcell_original_1_gets(*args, &block) end |
.open(*args, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 4 def open(*args, &block) path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args) if !path.strip.empty? && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode) raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied" end if path.empty? cmd = TCellAgent::Cmdi.parse_command_from_open(*args) if cmd && TCellAgent::Cmdi.block_command?(cmd) raise "tCell.io Agent: Command not allowed by policy: #{cmd}" end end tcell_original_1_open(*args, &block) end |
.readline(*args, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 33 def readline(*args, &block) path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode_argf if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode) raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied" end tcell_original_readline(*args, &block) end |
.spawn(*args) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 44 def spawn(*args) cmd = TCellAgent::Cmdi.parse_command(*args) if TCellAgent::Cmdi.block_command?(cmd) raise "tCell.io Agent: Command not allowed by policy: #{cmd}" end tcell_original_1_spawn(*args) end |
.system(*args) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 54 def system(*args) cmd = TCellAgent::Cmdi.parse_command(*args) if TCellAgent::Cmdi.block_command?(cmd) raise "tCell.io Agent: Command not allowed by policy: #{cmd}" end tcell_original_1_system(*args) end |
.tcell_original_1_gets ⇒ Object
21 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 21 alias_method :tcell_original_1_gets, :gets |
.tcell_original_1_open ⇒ Object
3 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 3 alias_method :tcell_original_1_open, :open |
.tcell_original_1_spawn ⇒ Object
43 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 43 alias_method :tcell_original_1_spawn, :spawn |
.tcell_original_1_system ⇒ Object
53 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 53 alias_method :tcell_original_1_system, :system |
.tcell_original_exec ⇒ Object
137 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 137 alias_method :tcell_original_exec, :exec |
.tcell_original_readline ⇒ Object
32 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 32 alias_method :tcell_original_readline, :readline |
Instance Method Details
#`(cmd) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 65 def `(cmd) if TCellAgent::Cmdi.block_command?(cmd) raise "tCell.io Agent: Command not allowed by policy: #{cmd}" end tcell_original_backtick(cmd) end |
#gets(*args, &block) ⇒ Object
92 93 94 95 96 97 98 99 100 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 92 def gets(*args, &block) path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode_argf if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode) raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied" end tcell_original_2_gets(*args, &block) end |
#open(*args, &block) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 74 def open(*args, &block) path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args) if !path.strip.empty? && TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode) raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied" end if path.empty? cmd = TCellAgent::Cmdi.parse_command_from_open(*args) if cmd && TCellAgent::Cmdi.block_command?(cmd) raise "tCell.io Agent: Command not allowed by policy: #{cmd}" end end tcell_original_2_open(*args, &block) end |
#readline(*args, &block) ⇒ Object
103 104 105 106 107 108 109 110 111 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 103 def readline(*args, &block) path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode_argf if TCellAgent::Instrumentation::Lfi.block_file_access?(path, mode) raise IOError, "tCell.io Agent: Attempted access to file #{path} with mode #{mode} denied" end tcell_original_readline(*args, &block) end |
#spawn(*args) ⇒ Object
114 115 116 117 118 119 120 121 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 114 def spawn(*args) cmd = TCellAgent::Cmdi.parse_command(*args) if TCellAgent::Cmdi.block_command?(cmd) raise "tCell.io Agent: Command not allowed by policy: #{cmd}" end tcell_original_2_spawn(*args) end |
#system(*args) ⇒ Object
124 125 126 127 128 129 130 131 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 124 def system(*args) cmd = TCellAgent::Cmdi.parse_command(*args) if TCellAgent::Cmdi.block_command?(cmd) raise "tCell.io Agent: Command not allowed by policy: #{cmd}" end tcell_original_2_system(*args) end |
#tcell_original_2_gets ⇒ Object
91 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 91 alias_method :tcell_original_2_gets, :gets |
#tcell_original_2_open ⇒ Object
73 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 73 alias_method :tcell_original_2_open, :open |
#tcell_original_2_spawn ⇒ Object
113 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 113 alias_method :tcell_original_2_spawn, :spawn |
#tcell_original_2_system ⇒ Object
123 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 123 alias_method :tcell_original_2_system, :system |
#tcell_original_exec ⇒ Object
148 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 148 alias_method :tcell_original_exec, :exec |
#tcell_original_readline ⇒ Object
102 |
# File 'lib/tcell_agent/instrumentation/monkey_patches/kernel.rb', line 102 alias_method :tcell_original_readline, :readline |