示例#1
0
        // Token: 0x0600009D RID: 157 RVA: 0x00004740 File Offset: 0x00002940
        private bool CanAccessDataLossPreventionProperties(IRecord record)
        {
            if (record == null)
            {
                throw new ArgumentNullException("record");
            }
            IUpdateableBucketField updateableBucketField = record[this.propertyBagPosition] as IUpdateableBucketField;

            if (updateableBucketField == null)
            {
                ULS.SendTraceTag(5256291U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 100, "DLPQuerySecurityProducer.CanAccessDataLossPreventionProperties :: tenantId={0}; The record did not have a 'PropertyBag' entry.   We cannot determine if the user has permission, so we assume not.", new object[]
                {
                    this.tenantId
                });
                return(false);
            }
            IStringField stringField = updateableBucketField["RootWebTemplate"] as IStringField;

            if (stringField == null)
            {
                ULS.SendTraceTag(5256320U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 100, "DLPQuerySecurityProducer.CanAccessDataLossPreventionProperties :: tenantId={0}; The record did not have a 'RootWebTemplate' entry in its 'PropertyBag' or the value was not of type IStringField.   We cannot determine if the user has permission, so we assume not.", new object[]
                {
                    this.tenantId
                });
                return(false);
            }
            if (DLPQuerySecurityProducer.AuthorizedWebTemplateIdentifiers.Contains(stringField.StringValue, StringComparer.Ordinal))
            {
                ULS.SendTraceTag(5256321U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 100, "DLPQuerySecurityProducer.CanAccessDataLossPreventionProperties :: tenantId={0}; RootWebTemplate={1}; The query comes from an authorized template.  The user, by virtue of having access to an authorized template, has permission to query for data-loss-prevention properties.", new object[]
                {
                    this.tenantId,
                    stringField.StringValue
                });
                return(true);
            }
            ULS.SendTraceTag(5256322U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 100, "DLPQuerySecurityProducer.CanAccessDataLossPreventionProperties :: tenantId={0}; RootWebTemplate={1}; The query does not come from an authorized template.  If the query contains data-loss-prevention properties, it will be rejected.  Identifier for the web template where the query originated: ", new object[]
            {
                this.tenantId,
                stringField.StringValue
            });
            return(false);
        }
        // Token: 0x060000AE RID: 174 RVA: 0x00004A9C File Offset: 0x00002C9C
        public override void ProcessRecordCore(IRecord record)
        {
            Guid tenantId = this.GetTenantId(record);

            if (!this.isIPClassificationQueryEnabled)
            {
                base.SetNextRecord();
                return;
            }
            IUpdateableBucketField updateableBucketField = record[this.otherPosition] as IUpdateableBucketField;

            if (updateableBucketField != null)
            {
                for (int i = 0; i < updateableBucketField.FieldCount; i++)
                {
                    string text = updateableBucketField.Name(i);
                    if (string.Equals(text, "SensitiveType", StringComparison.OrdinalIgnoreCase))
                    {
                        IUpdateableListField <string> updateableListField = updateableBucketField[text] as IUpdateableListField <string>;
                        if (updateableListField == null)
                        {
                            ULS.SendTraceTag(5833439U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 20, "DLPQuerySensitiveResultTranslationProducer.ProcessRecordCore :: tenantId={0}, fieldName={1}; Found a result entry for the field name (expected to represent the sensitive type list), but its type was not IUpdateableListField<string> or its value was null.  Cannot do any data-loss-prevention result-set translation.", new object[]
                            {
                                tenantId,
                                text
                            });
                        }
                        else
                        {
                            for (int j = 0; j < updateableListField.Count; j++)
                            {
                                string text2 = DLPQuerySensitiveResultTranslationOperator.Store.RuleIdToRuleName(updateableListField[j]);
                                if (text2 == null)
                                {
                                    ULS.SendTraceTag(5833440U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 20, "DLPQuerySensitiveResultTranslationProducer.ProcessRecordCore :: tenantId={0}, fieldIndex={1}, fieldValue={2}; Found a result entry for the field name (expected to represent the sensitive type list), but the value at this index was either null or an invalid rule ID.  Cannot translate this value.", new object[]
                                    {
                                        tenantId,
                                        j,
                                        updateableListField[j]
                                    });
                                }
                                else
                                {
                                    updateableListField[j] = text2;
                                }
                            }
                        }
                    }
                    else if (string.Equals(text, "SensitiveMatchCount", StringComparison.OrdinalIgnoreCase) || string.Equals(text, "SensitiveMatchConfidence", StringComparison.OrdinalIgnoreCase))
                    {
                        IUpdateableListField <long?> updateableListField2 = updateableBucketField[text] as IUpdateableListField <long?>;
                        long?[] array = updateableBucketField[text].Value as long?[];
                        if (array == null || updateableListField2 == null)
                        {
                            ULS.SendTraceTag(5833441U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 20, "DLPQuerySensitiveResultTranslationProducer.ProcessRecordCore :: tenantId={0}, fieldName={1}; Found a result entry for the field name, but its value was null or not of type long?[] or the field was not of type IUpdateableListField<long?>.  Cannot do any data-loss-prevention result-set translation.", new object[]
                            {
                                tenantId,
                                text
                            });
                        }
                        else
                        {
                            for (int k = 0; k < array.Length; k++)
                            {
                                array[k] &= (long)((ulong)-1);
                            }
                            updateableListField2.Value = array;
                        }
                    }
                }
            }
            else
            {
                ULS.SendTraceTag(5833442U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 20, "DLPQuerySensitiveResultTranslationProducer.ProcessRecordCore :: tenantId={0}; The 'Other' field in the record was null, so we cannot do any data-loss-prevention result-set translation.", new object[]
                {
                    tenantId
                });
            }
            base.SetNextRecord();
        }
        // Token: 0x06000017 RID: 23 RVA: 0x000027A4 File Offset: 0x000009A4
        public void SetClassificationResults(ICAClassificationResultCollection results)
        {
            if (ULS.ShouldTrace(ULSCat.msoulscat_SEARCH_DataLossPrevention, 100))
            {
                ULS.SendTraceTag(4850008U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 100, "FASTClassificationItem.SetClassificationResults :: saving results for [{0}]", new object[]
                {
                    this.ItemId
                });
            }
            IUpdateableBucketField updateableBucketField = this.record[this.managedPropertiesPosition] as IUpdateableBucketField;

            if (updateableBucketField != null)
            {
                if (this.persistClassificationData)
                {
                    updateableBucketField.AddField(this.lastScanPropertyName, StandardFields.GetStandardDateTimeField(new DateTime?(DateTime.UtcNow)), BuiltInTypes.DateTimeType);
                }
                ICollection <long?>  collection  = new List <long?>();
                ICollection <long?>  collection2 = new List <long?>();
                ICollection <string> collection3 = new List <string>();
                HashSet <long>       hashSet     = new HashSet <long>();
                if (results != null && results.Count > 0)
                {
                    this.resultCount = results.Count;
                    for (int i = 0; i < this.resultCount; i++)
                    {
                        ICAClassificationResult icaclassificationResult = results[i + 1];
                        if (ULS.ShouldTrace(ULSCat.msoulscat_SEARCH_DataLossPrevention, 100))
                        {
                            ULS.SendTraceTag(4850009U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 100, "FASTClassificationItem.SetClassificationResults :: Results Found :: package={0} ruleId={1}", new object[]
                            {
                                icaclassificationResult.RulePackageID,
                                icaclassificationResult.ID
                            });
                        }
                        long?resultBase = this.ruleStore.GetResultBase(icaclassificationResult.RulePackageID, icaclassificationResult.ID);
                        if (resultBase == null)
                        {
                            ULS.SendTraceTag(6038295U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 50, "FASTClassificationItem.SetClassificationResults :: Unkwown rule ID in result (should not happen). :: package={0} ruleId={1}", new object[]
                            {
                                icaclassificationResult.RulePackageID,
                                icaclassificationResult.ID
                            });
                        }
                        else
                        {
                            long value = resultBase.Value;
                            if (!hashSet.Add(value))
                            {
                                ULS.SendTraceTag(5833436U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 50, "FASTClassificationItem.SetClassificationResults :: Duplicate rule entry is being ignored.  Duplicate rule entries should not happen. :: package={0} ruleId={1}", new object[]
                                {
                                    icaclassificationResult.RulePackageID,
                                    icaclassificationResult.ID
                                });
                            }
                            else
                            {
                                long value2 = value + (long)((int)icaclassificationResult.GetAttributeValue("BD770258-EA9C-4162-B79C-7AD408EC7CD5"));
                                long value3 = value + (long)((int)icaclassificationResult.GetAttributeValue("AFF85B32-1BA9-4EDE-9286-F08A7EE5A421"));
                                collection.Add(new long?(value2));
                                collection2.Add(new long?(value3));
                                collection3.Add(icaclassificationResult.ID);
                            }
                        }
                    }
                    if (this.persistClassificationData && this.resultCount > 0)
                    {
                        if (ULS.ShouldTrace(ULSCat.msoulscat_SEARCH_DataLossPrevention, 100))
                        {
                            ULS.SendTraceTag(4850010U, ULSCat.msoulscat_SEARCH_DataLossPrevention, 100, "FASTClassificationItem.SetClassificationResults :: Updating managed properties");
                        }
                        IUpdateableListField <long?> updateableListField = (IUpdateableListField <long?>)StandardFields.ListDescriptor <long?>(BuiltInTypes.Int64Type).CreateField();
                        updateableListField.Value = collection;
                        updateableBucketField.AddField(this.countPropertyName, updateableListField, BuiltInTypes.ListType(BuiltInTypes.Int64Type));
                        updateableListField       = (IUpdateableListField <long?>)StandardFields.ListDescriptor <long?>(BuiltInTypes.Int64Type).CreateField();
                        updateableListField.Value = collection2;
                        updateableBucketField.AddField(this.confidencePropertyName, updateableListField, BuiltInTypes.ListType(BuiltInTypes.Int64Type));
                        IUpdateableListField <string> updateableListField2 = (IUpdateableListField <string>)StandardFields.ListDescriptor <string>(BuiltInTypes.StringType).CreateField();
                        updateableListField2.Value = collection3;
                        updateableBucketField.AddField(this.typePropertyName, updateableListField2, BuiltInTypes.ListType(BuiltInTypes.StringType));
                    }
                }
            }
        }