Class: File

Inherits:
Object
  • Object
show all
Defined in:
lib/tcell_agent/instrumentation/monkey_patches/file.rb

Class Method Summary collapse

Class Method Details

.new(*args, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/tcell_agent/instrumentation/monkey_patches/file.rb', line 4

def new(*args, &block)
  path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)

  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_new(*args, &block)
end

.open(*args, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/tcell_agent/instrumentation/monkey_patches/file.rb', line 15

def open(*args, &block)
  path, mode = TCellAgent::Instrumentation::Lfi.extract_path_mode(*args)

  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_open(*args, &block)
end

.tcell_original_newObject



3
# File 'lib/tcell_agent/instrumentation/monkey_patches/file.rb', line 3

alias_method :tcell_original_new, :new

.tcell_original_openObject



14
# File 'lib/tcell_agent/instrumentation/monkey_patches/file.rb', line 14

alias_method :tcell_original_open, :open