Пример #1
0
        public Actions GetOperation(string component, string tenant, string user, string operation, DateTime currentTime)
        {
            AuditUploaderDictionaryKey currentKey = new AuditUploaderDictionaryKey(component, tenant, user, operation);
            int num = 0;

            while ((double)num < Math.Pow((double)AuditUploaderDictionaryKey.NumberOfFields, 2.0))
            {
                AuditUploaderDictionaryKey nextKey = this.GetNextKey(currentKey, num);
                if (this.auditUploaderRules == null)
                {
                    EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_InvalidRuleCollection, "Audit Uploader rules collection has not been generated yet.", new object[0]);
                    return(Actions.Skip);
                }
                if (this.auditUploaderRules.ContainsKey(nextKey))
                {
                    TimeSpan?actionThrottlingInterval = this.auditUploaderRules[nextKey].ActionThrottlingInterval;
                    if (actionThrottlingInterval == null || currentTime.Subtract(actionThrottlingInterval.Value).CompareTo(this.auditUploaderRules[nextKey].LastTriggerDate) > 0)
                    {
                        this.auditUploaderRules[nextKey].LastTriggerDate = currentTime;
                        return(this.auditUploaderRules[nextKey].ActionToPerform);
                    }
                    return(Actions.LetThrough);
                }
                else
                {
                    num++;
                }
            }
            EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_InvalidRuleCollection, "Audit Uploader rules collection does not contain a matching rule for the given entry.", new object[0]);
            return(Actions.LetThrough);
        }
Пример #2
0
 private AuditUploaderDictionaryKey GetNextKey(AuditUploaderDictionaryKey currentKey, int index)
 {
     this.tempKey.CopyFrom(currentKey);
     for (int i = 0; i < AuditUploaderDictionaryKey.NumberOfFields; i++)
     {
         if ((index >> i & 1) == 1)
         {
             this.tempKey[i] = AuditUploaderDictionaryKey.WildCard;
         }
     }
     return(this.tempKey);
 }
Пример #3
0
 private static void GenerateDictionary()
 {
     if (AuditUploaderConfig.filteringRules == null)
     {
         AuditUploaderConfig.filteringRules = new AuditUploaderConfigRules();
     }
     foreach (FilteringRule filteringRule in AuditUploaderConfig.config.FilteringSection)
     {
         AuditUploaderDictionaryKey key = new AuditUploaderDictionaryKey((filteringRule.Predicate.Component != null) ? filteringRule.Predicate.Component : AuditUploaderDictionaryKey.WildCard, (filteringRule.Predicate.Tenant != null) ? filteringRule.Predicate.Tenant : AuditUploaderDictionaryKey.WildCard, (filteringRule.Predicate.User != null) ? filteringRule.Predicate.User : AuditUploaderDictionaryKey.WildCard, (filteringRule.Predicate.Operation != null) ? filteringRule.Predicate.Operation : AuditUploaderDictionaryKey.WildCard);
         if (!AuditUploaderConfig.filteringRules.Contains(key))
         {
             AuditUploaderConfig.filteringRules.Add(key, new AuditUploaderAction(filteringRule.ActionToPerform, (filteringRule.Throttle != null) ? filteringRule.Throttle.Interval : null));
         }
         else
         {
             EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_InvalidConfigFile, "Duplicate rule detected in the configuration", new object[0]);
         }
     }
     if (!AuditUploaderConfig.filteringRules.Contains(new AuditUploaderDictionaryKey(AuditUploaderDictionaryKey.WildCard, AuditUploaderDictionaryKey.WildCard, AuditUploaderDictionaryKey.WildCard, AuditUploaderDictionaryKey.WildCard)))
     {
         AuditUploaderConfig.filteringRules.Add(new AuditUploaderDictionaryKey(AuditUploaderDictionaryKey.WildCard, AuditUploaderDictionaryKey.WildCard, AuditUploaderDictionaryKey.WildCard, AuditUploaderDictionaryKey.WildCard), new AuditUploaderAction(Actions.LetThrough, null));
     }
 }
Пример #4
0
 public bool Contains(AuditUploaderDictionaryKey key)
 {
     return(this.auditUploaderRules.ContainsKey(key));
 }
Пример #5
0
 public void Add(AuditUploaderDictionaryKey key, AuditUploaderAction action)
 {
     this.auditUploaderRules.Add(key, action);
 }