module Conjur::Audit::Humanizer
Constants
- SHORT_FORMATS
Public Class Methods
append_features(base)
click to toggle source
# File lib/conjur/audit/humanizer.rb, line 24 def append_features base base.class_eval do def humanize e Conjur::Audit::Humanizer.humanize e end def self.humanize e Conjur::Audit::Humanizer.humanize e end end end
humanize(event)
click to toggle source
Add a “human” field to the event, describing what happened.
# File lib/conjur/audit/humanizer.rb, line 6 def humanize event e = event.symbolize_keys # hack: sometimes resource is a hash. We don't want that! if e[:resource] && e[:resource].kind_of?(Hash) e[:resource] = e[:resource]['id'] end s = " #{e[:conjur_user]}" s << " (as #{e[:conjur_role]})" if e[:conjur_role] != e[:conjur_user] formatter = SHORT_FORMATS["#{e[:asset]}:#{e[:action]}"] if formatter s << " " << formatter.call(e) else s << " unknown event: #{e[:asset]}:#{e[:action]}!" end s << " (failed with #{e[:error]})" if e[:error] event['human'] = s end