コード例 #1
0
        public void Should_be_possible_to_apply_regex_on_unix_filepath_strings()
        {
            var valuesToMatch = new string[] { "/temp/hub1/", "/temp/hub2/", "/temp/hub3/" };
            var multiLevelPatterOperator = new MultiLevelPatternMatchOperation(FamilyEnumeration.unix);

            var result = multiLevelPatterOperator.applyPatternMatch(@"/temp/.*/usb/", valuesToMatch);

            Assert.AreEqual(3, result.Count());
            Assert.AreEqual("temp/hub1/usb", result.ElementAt(0), UNEXPECTED_MATCH_VALUE_WAS_FOUND);
            Assert.AreEqual("temp/hub2/usb", result.ElementAt(1), UNEXPECTED_MATCH_VALUE_WAS_FOUND);
            Assert.AreEqual("temp/hub3/usb", result.ElementAt(2), UNEXPECTED_MATCH_VALUE_WAS_FOUND);
        }
コード例 #2
0
        public void Should_be_possible_to_apply_regex_on_windows_filepath_strings()
        {
            var valuesToMatch = new string[] { "c:\\temp\\hub1\\", "c:\\temp\\hub2\\", "c:\\temp\\hub3\\" };
            var multiLevelPatterOperator = new MultiLevelPatternMatchOperation(FamilyEnumeration.windows);

            var result = multiLevelPatterOperator.applyPatternMatch(@"c:\temp\.*\usb\", valuesToMatch);

            Assert.AreEqual(3, result.Count());
            Assert.AreEqual("c:\\temp\\hub1\\usb", result.ElementAt(0), UNEXPECTED_MATCH_VALUE_WAS_FOUND);
            Assert.AreEqual("c:\\temp\\hub2\\usb", result.ElementAt(1), UNEXPECTED_MATCH_VALUE_WAS_FOUND);
            Assert.AreEqual("c:\\temp\\hub3\\usb", result.ElementAt(2), UNEXPECTED_MATCH_VALUE_WAS_FOUND);
        }
コード例 #3
0
        private IEnumerable<string> processOperation(OVAL.Definitions.ObjectType objectType, IEnumerable<String> evalutedVariables)
        {
            var trusteeEntity = ((sid_object)objectType).TrusteeName;
            var entityOperation = trusteeEntity.operation;
            string[] trusteeNames = string.IsNullOrEmpty(trusteeEntity.var_ref) ? new string[] { trusteeEntity.Value } : evalutedVariables.ToArray();

            var operationResult = new List<String>();
            foreach (var trusteeName in trusteeNames)
            {
                var valuesToApply = (this.getValuesToApplyOperation(entityOperation, trusteeName)).ToArray();
                if (entityOperation == OperationEnumeration.patternmatch)
                {
                    var multiLevelOperation = new MultiLevelPatternMatchOperation(FamilyEnumeration.windows);
                    operationResult.AddRange(multiLevelOperation.applyPatternMatch(trusteeName, valuesToApply));
                }
                else
                    operationResult.AddRange(this.EvaluateOperationsDifferentsOfPatternMatch(entityOperation, trusteeName, valuesToApply));
            }

            return operationResult;
        }
コード例 #4
0
ファイル: PathOperatorEvaluator.cs プロジェクト: ywcsz/modSIC
        private List<string> EvaluateOperationPatternMatchOfPath(IEnumerable<string> paths)
        {
            var values = new List<string>();
            foreach (string path in paths)
            {
                var regexInformation = new FilePathRegexInformation(path);
                var basePath = regexInformation.GetPathWithFirstRegex();
                if (basePath != null)
                {
                    var result = this.searchFileChildren(path, true);
                    if (regexInformation.IsWindowsFilepath())
                        result = this.removeFilesFromList(result);

                    var multiLevelPatternMatchOperator = new MultiLevelPatternMatchOperation(this.Platform);
                    var valuesWithMatch = multiLevelPatternMatchOperator.applyPatternMatch(path, result).ToList();
                    //var newPaths = this.SubstitutionValueInPattern(valuesWithMatch, basePath, regexInformation);
                    //if (newPaths.Count() > 0)
                    //    values.AddRange(this.EvaluateOperationPatternMatchOfPath(newPaths));
                    //else
                        values.AddRange(valuesWithMatch);
                }
            }
            return values;
        }
コード例 #5
0
 private IEnumerable<string> EvaluateOperations(OperationEnumeration operation, string entityValue, IEnumerable<string> valuesToMatch)
 {
     if (operatorHelper.IsRegularExpression(operation))
     {
         var multiLevelPatternMatchOperator = new MultiLevelPatternMatchOperation(GetPlatform());
         return multiLevelPatternMatchOperator.applyPatternMatch(entityValue, valuesToMatch);
     }
     else
     {
         return this.EvaluateOperationsDifferentsOfPatternMatch(operation, entityValue, valuesToMatch);
     }
 }
コード例 #6
0
        private IEnumerable<String> ProcessOperationsTrusteeSID(fileeffectiverights53_object objectToCollect)
        {
            var trusteeSIDEntityName = fileeffectiverights53_object_ItemsChoices.trustee_sid.ToString();
            var trusteeSIDEntity = objectToCollect.GetAllObjectEntities()[trusteeSIDEntityName];
            var derivedTrusteeSIDs = new List<String>();

            if (trusteeSIDEntity.operation == OperationEnumeration.equals)
                derivedTrusteeSIDs.Add(trusteeSIDEntity.Value);
            else
            {
                this.searchAllUsersOnTarget();
                derivedTrusteeSIDs = 
                    new MultiLevelPatternMatchOperation(FamilyEnumeration.windows)
                        .applyPatternMatch(trusteeSIDEntity.Value, allUsersSID).ToList();
            }

            return derivedTrusteeSIDs;
        }
コード例 #7
0
 private IEnumerable<string> processOperationPatternMatchForTrustName(EntityObjectStringType trustName)
 {
     var operationResult = new List<string>();
     string[] valuesToApply = this.searchUsers();
     var multiLevelOperation = new MultiLevelPatternMatchOperation(FamilyEnumeration.windows);
     operationResult.AddRange(multiLevelOperation.applyPatternMatch(trustName.Value, valuesToApply));
     return operationResult;
 }