Exemplo n.º 1
0
        public void Should_be_possible_to_collect_file_effective_rights()
        {
            #region File Effective Rights Object
            //<fileeffectiverights_object id="oval:modulo:obj:7" version="1" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#windows">
            //    <path>c:\temp</path>
            //    <filename>file1.txt</filename>
            //    <trustee_name>mss\lfernandes</trustee_name>
            //</fileeffectiverights_object>
            #endregion

            oval_definitions            definitions               = ProbeHelper.GetFakeOvalDefinitions("definitionsSimple.xml");
            CollectInfo                 fakeCollectInfo           = ProbeHelper.CreateFakeCollectInfo(definitions.objects, null, null);
            Definitions::ObjectType     fileEffectiveRightsObject = ProbeHelper.GetOvalComponentByOvalID(definitions, "oval:modulo:obj:7");
            IEnumerable <CollectedItem> fakeCollectedItems        = new CollectedItem[] { this.createFakeCollectedItem(fileEffectiveRightsObject) };

            FileEffectiveRightsProber prober = this.createMockedFileEffectiveRightsProber(fakeCollectedItems);
            ProbeResult result = prober.Execute(ProbeHelper.CreateFakeContext(), ProbeHelper.CreateFakeTarget(), fakeCollectInfo);

            Assert.IsNotNull(result, "The result of FileEffectiveRightsProber execution cannot be null.");
            Assert.IsNotNull(result.ExecutionLog, "The ExecutionLog of FileEffectiveRightsProber was not created.");
            Assert.IsNotNull(result.CollectedObjects, "There are no collected objects.");
            Assert.AreEqual(1, result.CollectedObjects.Count(), "Unexpected collected objects count found.");

            this.AssertCollectedFileItems(fileEffectiveRightsObject, result.CollectedObjects.ElementAt(0), fakeCollectedItems);
        }
Exemplo n.º 2
0
        private IEnumerable <string> processOperation(Definitions::ObjectType objectType, IEnumerable <string> fullFilePaths)
        {
            OperationEnumeration entityOperation = OvalHelper.GetFileEntityOperation(this.VariableEvaluator.AllObjectEntities);

            IEnumerable <string> allDerivedFilePaths = new List <String>();

            foreach (var fullFilePath in fullFilePaths)
            {
                bool     isPatternMatchOperation = entityOperation == OperationEnumeration.patternmatch;
                string[] valuesToApply           = isPatternMatchOperation ? this.searchFileChildren(fullFilePath) : new string[] { fullFilePath };
                ((List <String>)allDerivedFilePaths).AddRange(this.EvaluateOperations(entityOperation, fullFilePath, valuesToApply));
            }

            return(allDerivedFilePaths);
        }
Exemplo n.º 3
0
        private IEnumerable <string> processVariables(Definitions::ObjectType objectType, VariablesEvaluated variables)
        {
            if (this.VariableEvaluator == null)
            {
                throw new Exception("[AbstractFileItemTypeGenerator] - The Variable Evaluator must be set.");
            }


            if ((variables == null) || (variables.VariableValues.Count() == 0))
            {
                return(new List <String>(new string[] { OvalHelper.GetFullFilePathFromObjectType(objectType) }));
            }

            return(this.VariableEvaluator.ProcessVariableForAllObjectEntities());
        }
Exemplo n.º 4
0
        private void AssertCollectedFileItems(Definitions::ObjectType sourceObject, CollectedObject collectedObject, IEnumerable <CollectedItem> expectedItems)
        {
            SystemCharacteristics.ReferenceType[] objectReferences = collectedObject.ObjectType.reference.ToArray();
            IList <ItemType> collectedItems = (IList <ItemType>)collectedObject.SystemData;

            this.assertCollectedItemsReferences(collectedObject, collectedItems);

            for (int i = 0; i < expectedItems.Count(); i++)
            {
                CollectedItem expectedFileItem = expectedItems.ElementAt(i);
                ItemType      collectedItem    = collectedItems[i];

                this.assertCollectedItemStatus(objectReferences[i], collectedItem);
                this.assertFileEffectiveRightsInitialEntities(sourceObject, collectedItem);
                this.assertFileEffectiveRightsCollectedItems(expectedFileItem, collectedItem);
            }
        }
Exemplo n.º 5
0
        private CollectedItem createFakeCollectedItem(Definitions::ObjectType fileEffectiveRightsObject)
        {
            var allEntities = OvalHelper.GetFileEffectiveRightsFromObjectType((fileeffectiverights_object)fileEffectiveRightsObject);

            fileeffectiverights_item newItem = new fileeffectiverights_item()
            {
                id              = fileEffectiveRightsObject.id,
                path            = this.createInitialItemEntity(allEntities, fileeffectiverights_object_ItemsChoices.path.ToString()),
                filename        = this.createInitialItemEntity(allEntities, fileeffectiverights_object_ItemsChoices.filename.ToString()),
                trustee_name    = this.createInitialItemEntity(allEntities, fileeffectiverights_object_ItemsChoices.trustee_name.ToString()),
                trustee_sid     = this.createItemEntityWithStringValue("12345"),
                standard_delete = this.createItemEntityWithBooleanValue("1"),
                generic_read    = this.createItemEntityWithBooleanValue("0")
            };

            return(ProbeHelper.CreateFakeCollectedItem(newItem));
        }
Exemplo n.º 6
0
 protected override set GetSetElement(Definitions::ObjectType objectType)
 {
     return ((sid_sid_object)objectType).GetSetEntity();
 }