lib/conjur/command/audit.rb in conjur-cli-4.7.1 vs lib/conjur/command/audit.rb in conjur-cli-4.7.2

- old
+ new

@@ -8,32 +8,28 @@ class << self private SHORT_FORMATS = { 'resource:check' => lambda{|e| "checked that they can #{e[:privilege]} #{e[:resource]} (#{e[:allowed]})" }, - 'resource:create' => lambda{|e| "created resource #{e[:resource_id]} owned by #{e[:owner]}" }, + 'resource:create' => lambda{|e| "created resource #{e[:resource]} owned by #{e[:owner]}" }, 'resource:update' => lambda{|e| "gave #{e[:resource]} to #{e[:owner]}" }, 'resource:destroy' => lambda{|e| "destroyed resource #{e[:resource]}" }, 'resource:permit' => lambda{|e| "permitted #{e[:grantee]} to #{e[:privilege]} #{e[:resource]} (grant option: #{!!e[:grant_option]})" }, 'resource:deny' => lambda{|e| "denied #{e[:privilege]} from #{e[:grantee]} on #{e[:resource]}" }, 'resource:permitted_roles' => lambda{|e| "listed roles permitted to #{e[:permission]} on #{e[:resource]}" }, 'role:check' => lambda{|e| "checked that #{e[:role] == e[:conjur_user] ? 'they' : e[:role]} can #{e[:privilege]} #{e[:resource]} (#{e[:allowed]})" }, 'role:grant' => lambda{|e| "granted role #{e[:role]} to #{e[:member]} #{e[:admin_option] ? ' with ' : ' without '}admin" }, 'role:revoke' => lambda{|e| "revoked role #{e[:role]} from #{e[:member]}" }, - 'role:create' => lambda{|e| "created role #{e[:role_id]}" } + 'role:create' => lambda{|e| "created role #{e[:role]}" } } def short_event_format e e.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 = "[#{Time.parse(e[:timestamp])}] " - s << " #{e[:conjur_user]}" - s << " (as #{e[:conjur_role]})" if e[:conjur_role] != e[:conjur_user] + s = "[#{Time.parse(e[:timestamp])}]" + s << " #{e[:user]}" + s << " (as #{e[:acting_as]})" if e[:acting_as] != e[:user] formatter = SHORT_FORMATS["#{e[:kind]}:#{e[:action]}"] if formatter s << " " << formatter.call(e) else s << " unknown event: #{e[:asset]}:#{e[:action]}!" @@ -62,12 +58,12 @@ end def show_audit_events events, options events = [events] unless events.kind_of?(Array) if options[:short] - events.map(&:to_h).each{|e| puts short_event_format(e)} + events.each{|e| puts short_event_format(e)} else - events.map(&:to_h).each{|e| puts JSON.pretty_generate(e) } + events.each{|e| puts JSON.pretty_generate(e) } end end def audit_feed_command kind, &block command kind do |c| \ No newline at end of file