Module: Conjur::Audit::Humanizer
- Included in:
- WebServer::AuditStream
- Defined in:
- lib/conjur/audit/humanizer.rb
Class Method Summary collapse
- .append_features(base) ⇒ Object
-
.humanize(event) ⇒ Object
Add a “human” field to the event, describing what happened.
Class Method Details
.append_features(base) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# 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) ⇒ Object
Add a “human” field to the event, describing what happened.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# 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 |