public static RuleConfiguration FromRuleStorage(RuleStorage ruleStorage)
        {
            RuleConfiguration ruleConfiguration = new RuleConfiguration(ruleStorage.OrganizationalUnitRoot.ObjectGuid, ruleStorage.Id.ObjectGuid);

            UnifiedPolicyStorageFactory.CopyPropertiesFromStorage <RuleConfiguration>(ruleConfiguration, new TenantSettingFacade <RuleStorage>(ruleStorage));
            return(ruleConfiguration);
        }
        private IList <Guid> ValidateUpdateObjectSyncParameters()
        {
            IList <Guid> list = new List <Guid>();

            foreach (string text in this.UpdateObjectId)
            {
                switch (this.ObjectType.First <ConfigurationObjectType>())
                {
                case ConfigurationObjectType.Policy:
                {
                    PolicyStorage storageObject = (PolicyStorage)base.GetDataObject <PolicyStorage>(new PolicyIdParameter(text), base.DataSession, null, new LocalizedString?(Strings.ErrorPolicyNotFound(text)), new LocalizedString?(Strings.ErrorPolicyNotUnique(text)));
                    list.Add(Utils.GetUniversalIdentity(storageObject));
                    break;
                }

                case ConfigurationObjectType.Rule:
                {
                    RuleStorage storageObject2 = (RuleStorage)base.GetDataObject <RuleStorage>(new ComplianceRuleIdParameter(text), base.DataSession, null, new LocalizedString?(Strings.ErrorRuleNotFound(text)), new LocalizedString?(Strings.ErrorRuleNotUnique(text)));
                    list.Add(Utils.GetUniversalIdentity(storageObject2));
                    break;
                }

                default:
                    throw new NotImplementedException();
                }
            }
            return(list);
        }
Example #3
0
        protected override IConfigurable PrepareDataObject()
        {
            RuleStorage ruleStorage = (RuleStorage)base.PrepareDataObject();

            ruleStorage.Name = base.Name;
            ruleStorage.SetId(((ADObjectId)this.policyStorage.Identity).GetChildId(base.Name));
            ruleStorage.MasterIdentity = Guid.NewGuid();
            PsDlpComplianceRule psDlpComplianceRule = new PsDlpComplianceRule(ruleStorage)
            {
                Comment  = base.Comment,
                Disabled = base.Disabled,
                Mode     = Mode.Enforce,
                Policy   = Utils.GetUniversalIdentity(this.policyStorage),
                Workload = this.policyStorage.Workload,
                ContentPropertyContainsWords        = this.ContentPropertyContainsWords,
                ContentContainsSensitiveInformation = this.ContentContainsSensitiveInformation,
                AccessScopeIs = this.AccessScopeIs,
                BlockAccess   = this.BlockAccess
            };

            if (!psDlpComplianceRule.GetTaskActions().Any <PsComplianceRuleActionBase>())
            {
                throw new RuleContainsNoActionsException(psDlpComplianceRule.Name);
            }
            ADObjectId adobjectId;

            base.TryGetExecutingUserId(out adobjectId);
            psDlpComplianceRule.UpdateStorageProperties(this, base.DataSession as IConfigurationSession, true);
            return(ruleStorage);
        }
Example #4
0
        protected override IConfigurable PrepareDataObject()
        {
            RuleStorage ruleStorage = (RuleStorage)base.PrepareDataObject();

            ruleStorage.Name = base.Name;
            ruleStorage.SetId(((ADObjectId)this.policyStorage.Identity).GetChildId(base.Name));
            PsHoldRule psHoldRule = new PsHoldRule(ruleStorage)
            {
                Comment                 = base.Comment,
                Disabled                = base.Disabled,
                Mode                    = Mode.Enforce,
                Policy                  = Utils.GetUniversalIdentity(this.policyStorage),
                Workload                = this.policyStorage.Workload,
                ContentMatchQuery       = this.ContentMatchQuery,
                ContentDateFrom         = this.ContentDateFrom,
                ContentDateTo           = this.ContentDateTo,
                HoldContent             = this.HoldContent,
                HoldDurationDisplayHint = this.HoldDurationDisplayHint
            };

            if (!psHoldRule.GetTaskActions().Any <PsComplianceRuleActionBase>())
            {
                throw new RuleContainsNoActionsException(psHoldRule.Name);
            }
            ADObjectId adobjectId;

            base.TryGetExecutingUserId(out adobjectId);
            psHoldRule.UpdateStorageProperties(this, base.DataSession as IConfigurationSession, true);
            return(ruleStorage);
        }
Example #5
0
        protected override void StampChangesOn(IConfigurable dataObject)
        {
            RuleStorage ruleStorage = (RuleStorage)dataObject;

            ruleStorage.ResetChangeTracking(true);
            base.PsRulePresentationObject = new PsHoldRule(ruleStorage);
            PsHoldRule psHoldRule = (PsHoldRule)base.PsRulePresentationObject;

            base.PsRulePresentationObject.PopulateTaskProperties(this, base.DataSession as IConfigurationSession);
            if (base.PsRulePresentationObject.ReadOnly)
            {
                throw new TaskRuleIsTooAdvancedToModifyException(base.PsRulePresentationObject.Name);
            }
            if (ruleStorage.Mode == Mode.PendingDeletion)
            {
                base.WriteError(new ErrorCommonComplianceRuleIsDeletedException(ruleStorage.Name), ErrorCategory.InvalidOperation, null);
            }
            base.StampChangesOn(dataObject);
            this.CopyExplicitParameters();
            if (!Utils.ValidateContentDateParameter(psHoldRule.ContentDateFrom, psHoldRule.ContentDateTo))
            {
                throw new InvalidContentDateFromAndContentDateToPredicateException();
            }
            if (!psHoldRule.GetTaskActions().Any <PsComplianceRuleActionBase>())
            {
                base.WriteError(new RuleContainsNoActionsException(psHoldRule.Name), ErrorCategory.InvalidData, psHoldRule);
            }
            psHoldRule.UpdateStorageProperties(this, base.DataSession as IConfigurationSession, false);
        }
        internal virtual void PopulateTaskProperties(Task task, IConfigurationSession configurationSession)
        {
            RuleStorage ruleStorage = base.DataObject as RuleStorage;
            ADUser      userObjectByExternalDirectoryObjectId  = Utils.GetUserObjectByExternalDirectoryObjectId(ruleStorage.CreatedBy, configurationSession);
            ADUser      userObjectByExternalDirectoryObjectId2 = Utils.GetUserObjectByExternalDirectoryObjectId(ruleStorage.LastModifiedBy, configurationSession);

            this.CreatedBy      = ((!Utils.ExecutingUserIsForestWideAdmin(task) && userObjectByExternalDirectoryObjectId != null) ? userObjectByExternalDirectoryObjectId.DisplayName : ruleStorage.CreatedBy);
            this.LastModifiedBy = ((!Utils.ExecutingUserIsForestWideAdmin(task) && userObjectByExternalDirectoryObjectId2 != null) ? userObjectByExternalDirectoryObjectId2.DisplayName : ruleStorage.LastModifiedBy);
        }
        public static RuleStorage ToRuleStorage(RuleConfiguration rule)
        {
            RuleStorage ruleStorage = new RuleStorage();

            ruleStorage[ADObjectSchema.OrganizationalUnitRoot] = new ADObjectId(rule.TenantId);
            ruleStorage.Name = rule.Name;
            ruleStorage.SetId((ADObjectId)DalHelper.ConvertFromStoreObject(rule.ObjectId, typeof(ADObjectId)));
            UnifiedPolicyStorageFactory.CopyPropertiesToStorage <RuleConfiguration>(new TenantSettingFacade <RuleStorage>(ruleStorage), rule);
            return(ruleStorage);
        }
Example #8
0
        public void PropertySet_AliasTest()
        {
            RuleStorage rules      = RuleStorage.Instance;
            Type        type1      = typeof(TestAlias1::AliasTestPack.Class1);
            var         type1Rules = rules.GetValidationRules(type1);

            Assert.That(type1Rules.ValidationStrategyBuilders.Any(x => x.Key.Name == "TestPack1NotNull"), Is.True, "type1 rule notNull");
            Type type2      = typeof(TestAlias2::AliasTestPack.Class1);
            var  type2Rules = rules.GetValidationRules(type2);

            Assert.That(type2Rules.ValidationStrategyBuilders.Any(x => x.Key.Name == "TestPack1NotNull"), Is.False, "type1 rule notNull present");
            Assert.That(type2Rules.ValidationStrategyBuilders.Any(x => x.Key.Name == "TestPack2NotNull"), Is.True, "type1 rule notNull present");
        }
Example #9
0
        protected override IConfigurable PrepareDataObject()
        {
            RuleStorage ruleStorage = (RuleStorage)base.PrepareDataObject();

            ruleStorage.Name = this.ruleName;
            ruleStorage.SetId(((ADObjectId)this.policyStorage.Identity).GetChildId(this.ruleName));
            DeviceRuleBase deviceRuleBase = this.CreateDeviceRule(ruleStorage);

            deviceRuleBase.Policy       = Utils.GetUniversalIdentity(this.policyStorage);
            deviceRuleBase.Workload     = this.policyStorage.Workload;
            deviceRuleBase.TargetGroups = this.TargetGroups;
            this.SetPropsOnDeviceRule(deviceRuleBase);
            deviceRuleBase.UpdateStorageProperties(this, base.DataSession as IConfigurationSession, true);
            return(ruleStorage);
        }
        protected override IConfigurable PrepareDataObject()
        {
            RuleStorage ruleStorage = (RuleStorage)base.PrepareDataObject();

            ruleStorage.Name = this.Name;
            ruleStorage.SetId(((ADObjectId)this.policyStorage.Identity).GetChildId(this.Name));
            AuditConfigurationRule auditConfigurationRule = new AuditConfigurationRule(ruleStorage)
            {
                Policy         = Utils.GetUniversalIdentity(this.policyStorage),
                Workload       = this.policyStorage.Workload,
                AuditOperation = this.AuditOperation
            };

            auditConfigurationRule.UpdateStorageProperties();
            return(ruleStorage);
        }
Example #11
0
        protected override void StampChangesOn(IConfigurable dataObject)
        {
            RuleStorage ruleStorage = (RuleStorage)dataObject;

            ruleStorage.ResetChangeTracking(true);
            AuditConfigurationRule auditConfigurationRule = new AuditConfigurationRule(dataObject as RuleStorage);

            auditConfigurationRule.PopulateTaskProperties();
            if (ruleStorage.Mode == Mode.PendingDeletion)
            {
                base.WriteError(new ErrorCommonComplianceRuleIsDeletedException(ruleStorage.Name), ErrorCategory.InvalidOperation, null);
            }
            base.StampChangesOn(dataObject);
            auditConfigurationRule.CopyChangesFrom(base.DynamicParametersInstance);
            auditConfigurationRule.AuditOperation = this.AuditOperation;
            auditConfigurationRule.UpdateStorageProperties();
        }
 internal virtual void UpdateStorageProperties(Task task, IConfigurationSession configurationSession, bool isNewRule)
 {
     if (!Utils.ExecutingUserIsForestWideAdmin(task))
     {
         ADObjectId objectId;
         task.TryGetExecutingUserId(out objectId);
         ADUser userObjectByObjectId = Utils.GetUserObjectByObjectId(objectId, configurationSession);
         if (userObjectByObjectId != null)
         {
             RuleStorage ruleStorage = base.DataObject as RuleStorage;
             ruleStorage.LastModifiedBy = userObjectByObjectId.ExternalDirectoryObjectId;
             if (isNewRule)
             {
                 ruleStorage.CreatedBy = userObjectByObjectId.ExternalDirectoryObjectId;
             }
         }
     }
 }
 public void ReloadRulesForAnalyzer(string analyzerProgramName)
 {
     Task.Run(() =>
     {
         var analyzer = Analyzers.FirstOrDefault(a => a.Key == analyzerProgramName).Value;
         AddMessage($"Reloading rules for {analyzerProgramName}. Stopping Analyzer.");
         analyzer.StopAnalyzer();
         while (analyzer.State != State.Stopped)
         {
             //wait for stop
         }
         analyzer.UnloadAllRules();
         AddMessage($"{analyzerProgramName} analyzer stopped and rules unloaded.");
         var rules = RuleStorage.GetRulesForApplication(analyzerProgramName);
         AddRulesToAnalyzer(rules);
         AddMessage($"{analyzer.ProgramName} analyzer starting.");
         analyzer.StartAnalyzer();
     });
 }
Example #14
0
 protected DeviceRuleBase(RuleStorage ruleStorage) : base(ruleStorage)
 {
 }
Example #15
0
 public PsHoldRule(RuleStorage ruleStorage) : base(ruleStorage)
 {
 }
 protected abstract DeviceRuleBase CreateDeviceRule(RuleStorage dataObject);
 protected override DeviceRuleBase CreateDeviceRule(RuleStorage dataObject)
 {
     return(new DeviceConfigurationRule(dataObject));
 }
Example #18
0
 protected override DeviceRuleBase CreateDeviceRule(RuleStorage dataObject)
 {
     return(new DeviceTenantRule(dataObject));
 }
 protected override DeviceRuleBase CreateDeviceRuleObject(RuleStorage ruleStorage)
 {
     return(new DeviceTenantRule(ruleStorage));
 }
Example #20
0
 protected abstract DeviceRuleBase CreateDeviceRuleObject(RuleStorage ruleStorage);
Example #21
0
 protected override DeviceRuleBase CreateDeviceRule(RuleStorage ruleStorage)
 {
     return(new DeviceConfigurationRule(ruleStorage));
 }
 public PsComplianceRuleBase(RuleStorage ruleStorage) : base(ruleStorage)
 {
 }
Example #23
0
 protected override DeviceRuleBase CreateDeviceRule(RuleStorage ruleStorage)
 {
     return(new DeviceConditionalAccessRule(ruleStorage));
 }
 protected override DeviceRuleBase CreateDeviceRule(RuleStorage dataObject)
 {
     return(new DeviceConditionalAccessRule(dataObject));
 }
 public PsDlpComplianceRule(RuleStorage ruleStorage) : base(ruleStorage)
 {
 }
Example #26
0
 public DeviceTenantRule(RuleStorage ruleStorage) : base(ruleStorage)
 {
 }