Method: NewRelic::Security::Instrumentation::Dir#rmdir_on_enter

Defined in:
lib/newrelic_security/instrumentation-security/dir/instrumentation.rb

#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