Module: NewRelic::Security::Instrumentation::Dir

Included in:
Prepend
Defined in:
lib/newrelic_security/instrumentation-security/dir/chain.rb,
lib/newrelic_security/instrumentation-security/dir/prepend.rb,
lib/newrelic_security/instrumentation-security/dir/instrumentation.rb

Defined Under Namespace

Modules: Chain, Prepend

Instance Method Summary collapse

Instance Method Details

#mkdir_on_enter(*var) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/newrelic_security/instrumentation-security/dir/instrumentation.rb', line 8

def mkdir_on_enter(*var)
  event = nil
  NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}"
  fname = var[0]
  abs_path = ::File.expand_path(fname)
  if NewRelic::Security::Instrumentation::InstrumentationUtils.notify_app_integrity_open?(fname, abs_path, WRITE)
    event = NewRelic::Security::Agent::Control::Collector.collect(FILE_INTEGRITY, [fname], WRITE)
  else
    if NewRelic::Security::Instrumentation::InstrumentationUtils.read_filter?(fname, abs_path)
      NewRelic::Security::Agent.logger.debug "Filtered because File name exist in filtered list #{self.class}.#{__method__} Args:: #{fname}"
    else
      event = NewRelic::Security::Agent::Control::Collector.collect(FILE_OPERATION, [fname], WRITE)
    end 
  end
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
  return event
end

#mkdir_on_exit(event, retval) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/newrelic_security/instrumentation-security/dir/instrumentation.rb', line 29

def mkdir_on_exit(event, retval)
  NewRelic::Security::Agent.logger.debug "OnExit :  #{self.class}.#{__method__}"
  NewRelic::Security::Agent::Utils.create_exit_event(event) if retval.is_a?(Integer)
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
end

#rmdir_on_enter(name) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/newrelic_security/instrumentation-security/dir/instrumentation.rb', line 38

def rmdir_on_enter(name)
  event = nil
  NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}"
  fname = name
  abs_path = ::File.expand_path(fname)
  if NewRelic::Security::Instrumentation::InstrumentationUtils.notify_app_integrity_delete?([fname])
    event = NewRelic::Security::Agent::Control::Collector.collect(FILE_INTEGRITY, [fname], DELETE)
  else
    if NewRelic::Security::Instrumentation::InstrumentationUtils.read_filter?(fname, abs_path)
      NewRelic::Security::Agent.logger.debug "Filtered because File name exist in filtered list #{self.class}.#{__method__} Args:: #{fname}"
    else
      event = NewRelic::Security::Agent::Control::Collector.collect(FILE_OPERATION, [fname], DELETE)
    end 
  end
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
  return event
end

#rmdir_on_exit(event, retval) ⇒ Object



59
60
61
62
63
64
65
66
# File 'lib/newrelic_security/instrumentation-security/dir/instrumentation.rb', line 59

def rmdir_on_exit(event, retval)
  NewRelic::Security::Agent.logger.debug "OnExit :  #{self.class}.#{__method__}"
  NewRelic::Security::Agent::Utils.create_exit_event(event) if retval.is_a?(Integer)
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
end


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/newrelic_security/instrumentation-security/dir/instrumentation.rb', line 68

def unlink_on_enter(*var)
  event = nil
  NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}"
  fname = var[0]
  abs_path = ::File.expand_path(fname)
  if NewRelic::Security::Instrumentation::InstrumentationUtils.notify_app_integrity_delete?([fname])
    event = NewRelic::Security::Agent::Control::Collector.collect(FILE_INTEGRITY, [fname], DELETE)
  else
    if NewRelic::Security::Instrumentation::InstrumentationUtils.read_filter?(fname, abs_path)
      NewRelic::Security::Agent.logger.debug "Filtered because File name exist in filtered list #{self.class}.#{__method__} Args:: #{fname}"
    else
      event = NewRelic::Security::Agent::Control::Collector.collect(FILE_OPERATION, [fname], DELETE)
    end 
  end
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
  return event
end


89
90
91
92
93
94
95
96
# File 'lib/newrelic_security/instrumentation-security/dir/instrumentation.rb', line 89

def unlink_on_exit(event, retval)
  NewRelic::Security::Agent.logger.debug "OnExit :  #{self.class}.#{__method__}"
  NewRelic::Security::Agent::Utils.create_exit_event(event) if retval.is_a?(Integer)
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
end