<commit_before>require 'conjur/command'
require 'active_support/ordered_hash'

class Conjur::Command
  class Audit < self
    self.prefix = 'audit'
    
    class << self
      private
      SHORT_FORMATS = {
        'resource:check' => ->(e){ "checked that they can #{e[:privilege]} #{e[:resource]}" },
        'resource:create' => ->(e){ "created resource #{e[:resource_id]} owned by #{e[:owner]}" },
        'resource:update' => ->(e){ "gave #{e[:resource]} to #{e[:owner]}"},
        'resource:destroy' => ->(e){ "destroyed resource #{e[:resource]}"},
        'resource:permit' => ->(e){ "permitted #{e[:grantee]} to #{e[:privilege]} #{e[:resource]} (grant option: #{!!e[:grant_option]})" },
        'resource:deny' => ->(e){ "denied #{e[:privilege]} from #{e[:grantee]} on #{e[:resource]}" },
        'resource:permitted_roles' => ->(e){ "listed roles permitted to #{e[:permission]} on #{e[:resource]}" },
        'role:check' => -> (e){ "checked that #{e[:role]} can #{e[:privilege]} #{e[:resource]}" },
        'role:grant' => -> (e){ "granted role #{e[:role]} to #{e[:member]} #{e[:admin_option] ? ' with ' : ' without '}admin"},
        'role:revoke' => -> (e){ "revoked role #{e[:role]} from #{e[:member]}" },
        'role:create' => -> (e){ "created role #{e[:role_id]}"}
      }
      
      
      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.at(e[:timestamp])}] "
        s << " #{e[:conjur_user]}"<commit_msg>don't repeat same role id for role:check<commit_after>require 'conjur/command'
require 'active_support/ordered_hash'

class Conjur::Command
  class Audit < self
    self.prefix = 'audit'
    
    class << self
      private
      SHORT_FORMATS = {
        'resource:check' => ->(e){ "checked that they can #{e[:privilege]} #{e[:resource]}" },
        'resource:create' => ->(e){ "created resource #{e[:resource_id]} owned by #{e[:owner]}" },
        'resource:update' => ->(e){ "gave #{e[:resource]} to #{e[:owner]}"},
        'resource:destroy' => ->(e){ "destroyed resource #{e[:resource]}"},
        'resource:permit' => ->(e){ "permitted #{e[:grantee]} to #{e[:privilege]} #{e[:resource]} (grant option: #{!!e[:grant_option]})" },
        'resource:deny' => ->(e){ "denied #{e[:privilege]} from #{e[:grantee]} on #{e[:resource]}" },
        'resource:permitted_roles' => ->(e){ "listed roles permitted to #{e[:permission]} on #{e[:resource]}" },
        'role:check' => -> (e){ 
          "checked that #{e[:role] == e[:conjur_user] ? 'they' : e[:role]} can #{e[:privilege]} #{e[:resource]}" 
        },
        'role:grant' => -> (e){ "granted role #{e[:role]} to #{e[:member]} #{e[:admin_option] ? ' with ' : ' without '}admin"},
        'role:revoke' => -> (e){ "revoked role #{e[:role]} from #{e[:member]}" },
        'role:create' => -> (e){ "created role #{e[:role_id]}"}
      }
      
      
      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.at(e[:timestamp])}] "
        s << " #{e[:conjur_user]}"
{'fraction_non_alphanumeric': 0.2367005379557681, 'fraction_numerical': 0.0, 'mean_word_length': 3.1994981179422837, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1654291', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1118, 'n_words': 256}