public AuditEventPolicySubcategoriesProberTest()
        {
            var fakeItem = new auditeventpolicysubcategories_item();

            FakeCollectInfo = GetFakeCollectInfo("oval:modulo:obj:2000");
            FakeCollectedItems = new CollectedItem[] { ProbeHelper.CreateFakeCollectedItem(fakeItem) };
            FakeItemsToCollect = new ItemType[] { fakeItem };
        }
 public FileEffectiveRightsProberTests()
 {
     var fakeItemType = new fileeffectiverights_item();
     this.FakeItemsToBeGenerateByItemTypeGenerator = new ItemType[] { fakeItemType };
     this.FakeCollectedItemsToBeReturnedByObjectCollector = new CollectedItem[] { ProbeHelper.CreateFakeCollectedItem(fakeItemType) };
     this.OvalDefinitionsSample = ProbeHelper.GetFakeOvalDefinitions("definitionsSimple");
     var objectSample = OvalDefinitionsSample.objects.OfType<fileeffectiverights53_object>().Where(obj => obj.Items.Count() > 1).First();
     this.FakeCollectInfo = ProbeHelper.CreateFakeCollectInfo(new OVAL.Definitions.ObjectType[] { objectSample }, null, null);
 }
示例#3
0
        public static CollectInfo CreateFakeCollectInfo(
            IEnumerable<Definitions.ObjectType> objects, 
            VariablesEvaluated variables = null, 
            oval_system_characteristics systemCharacteristics = null)
        {
            CollectInfo collectInfo = new CollectInfo();
            collectInfo.Variables = (variables == null) ? new VariablesEvaluated(new List<VariableValue>()) : variables;
            collectInfo.ObjectTypes = objects;
            collectInfo.SystemCharacteristics = systemCharacteristics;

            return collectInfo;
        }
示例#4
0
        public void Should_be_possible_to_obtain_a_variable_by_ovalComponentId()
        {
            List<string> variableValues = new List<string>() { "Multiprocessor Free" };            
            VariableValue variable = new VariableValue("oval:org.mitre.oval:obj:6000", "oval:com.hp:var:1", variableValues);
            IEnumerable<VariableValue> variables = new List<VariableValue>() { variable };
            VariablesEvaluated variablesEvaluated = new VariablesEvaluated(variables);

            CollectInfo collectInfo = new CollectInfo() { Variables = variablesEvaluated};
            IEnumerable<VariableValue> variablesExpected = collectInfo.GetVariableValueForOvalComponent("oval:org.mitre.oval:obj:6000");
            Assert.IsNotNull(variablesExpected, "the variable was not found");            
            variablesExpected = collectInfo.GetVariableValueForOvalComponent("oval:org.mitre.oval:obj:6005");
            Assert.IsTrue(variablesExpected.Count() == 0, "the variable is not expected");
        }
        public AuditEventPolicyProberTest()
        {
            this.FakeContext = ProbeHelper.CreateFakeContext();
            this.FakeTargetInfo = ProbeHelper.CreateFakeTarget();
            this.FakeItemsToCollect = new ItemType[] { new auditeventpolicy_item() };

            var fakeAuditEventPolicyItem = new auditeventpolicy_item();
            fakeAuditEventPolicyItem.CreateAllEntityItemsWithAuditNoneEventStatus();
            fakeAuditEventPolicyItem.detailed_tracking.Value = AuditEventStatus.AUDIT_SUCCESS_FAILURE.ToString();
            this.FakeCollectedItems = new CollectedItem[] { ProbeHelper.CreateFakeCollectedItem(fakeAuditEventPolicyItem) };

            var objects = new Definitions.ObjectType[] { ProbeHelper.GetDefinitionObjectTypeByID("definitionsSimple", "2100") };
            this.FakeCollectInfo = ProbeHelper.CreateFakeCollectInfo(objects, null, null);
        }
示例#6
0
        public ProbeResult Execute(IList<IConnectionProvider> connectionContext, 
                                   TargetInfo target, VariablesEvaluated variables,  
                                   SC::oval_system_characteristics  systemCharacteristics,
                                   IEnumerable<StateType> states)
        {
            CollectInfo collectInfo = new CollectInfo() 
            { 
                ObjectTypes = this.ObjectTypes, 
                Variables = variables, 
                SystemCharacteristics =  systemCharacteristics,
                States = states
            };

            return probe.Execute(connectionContext, target, collectInfo);
        }
示例#7
0
        public void Should_Be_Possible_To_Execute_A_Family_Probe()
        {
            var fakeDefinitions = ProbeHelper.GetFakeOvalDefinitions("fdcc_xpfirewall_oval_regex_on_value.xml");
            var fakeCollectInfo = new CollectInfo() { ObjectTypes = fakeDefinitions.objects.OfType<family_object>() };
            
            ProbeResult result = 
                GetFamilyProber()
                    .Execute(null, ProbeHelper.CreateFakeTarget(), fakeCollectInfo);            

            var collectedFamily = result.CollectedObjects.ElementAt(0);
            Assert.IsNotNull(result.CollectedObjects);
            Assert.AreEqual(1, result.CollectedObjects.Count());
            Assert.AreEqual(1, collectedFamily.ObjectType.reference.Count());
            Assert.AreEqual(collectedFamily.ObjectType.reference.Count(), collectedFamily.SystemData.Count);
            Assert.AreEqual("oval:modulo:obj:99", collectedFamily.ObjectType.id);
            Assert.AreEqual(collectedFamily.ObjectType.reference[0].item_ref, collectedFamily.SystemData[0].id);
            
            var familyItem = (family_item)collectedFamily.SystemData[0];
            Assert.AreEqual(StatusEnumeration.exists, familyItem.status);
            Assert.AreEqual("Windows", familyItem.family.Value);
        }
 public TextFileContentProberUnixTests()
 {
     FakeItemsToCollect = new ItemType[] { new textfilecontent_item() };
     FakeCollectedItems = new CollectedItem[] { ProbeHelper.CreateFakeCollectedItem(new textfilecontent_item()) };
     FakeCollectInfo = GetFakeCollectInfo("oval:modulo:obj:900");
 }
示例#9
0
 public FileContentProbeTest()
 {
     FakeItemsToReturn = new ItemType[] { CreateFakeTextFileContent() };
     FakeCollectedItem = new CollectedItem[] { ProbeHelper.CreateFakeCollectedItem(CreateFakeTextFileContent()) };
     FakeCollectInfo = GetFakeCollectInfo("oval:modulo:obj:9");
 }
 public EnvironmentVariableProberTest()
 {
     FakeItemsToCollect = new ItemType[] { GetFakeEnvironmentVariableItem() };
     FakeCollectedItems =  new CollectedItem[] { GetFakeCollectedItem() };
     FakeCollectInfo = GetFakeCollectInfo("oval:modulo:obj:2360");
 }
示例#11
0
 public UserProberTests()
 {
     var fakeObjects = new Definitions.ObjectType[] { new UserObjectFactory().NewObject("guest") };
     this.FakeCollectInfo = ProbeHelper.CreateFakeCollectInfo(fakeObjects, null, null);
 }
 public RegKeyEffectiveRightsProberTest()
 {
     FakeCollectInfo = GetFakeCollectInfo("oval:modulo:obj:750");
     FakeItemsToReturnByItemTypeGenerator = new ItemType[] { new regkeyeffectiverights_item() };
     FakeCollectedItems = new CollectedItem[] { ProbeHelper.CreateFakeCollectedItem(new regkeyeffectiverights_item()) };
 }
示例#13
0
文件: ProbeBase.cs 项目: ywcsz/modSIC
        /// <summary>
        /// This method executes the process of  a setElement in the ObjectType.
        /// For the objectType that has a setElement the process is a some different. 
        /// Actually, the setElement uses the objectType already was  collected. 
        /// In this process the setElement process uses a systemCharacteristics for the get a reference for the objectType 
        /// collected and makes the references are used in the new CollectedObject of the process.
        /// </summary>
        /// <param name="ovalObject">The Oval Object.</param>
        /// <param name="collectInfo">The collect info.</param>
        /// <returns></returns>
        private CollectedObject ProcessSet(Definitions.ObjectType ovalObject, CollectInfo collectInfo)
        {
            CollectedObject collectedObject = null;
            try
            {
                var setElement = this.GetSetElement(ovalObject);
                var setEvaluator = new SetEvaluator(collectInfo.SystemCharacteristics, collectInfo.States, collectInfo.Variables);
                var resultOfSet = setEvaluator.Evaluate(setElement);
                var objectReferences = resultOfSet.Result;

                if (objectReferences.Count() > 0)
                {
                    collectedObject = new CollectedObject(ovalObject.id);
                    foreach (string reference in objectReferences)
                    {
                        var itemType = collectInfo.SystemCharacteristics.GetSystemDataByReferenceId(reference);
                        collectedObject.AddItemToSystemData(itemType);
                    }

                    collectedObject.SetEspecificObjectStatus(resultOfSet.ObjectFlag);
                }

                return collectedObject;
            }
            catch (Exception ex)
            {
                collectedObject = new CollectedObject(ovalObject.id);
                collectedObject.SetEspecificObjectStatus(FlagEnumeration.error);
                collectedObject.ObjectType.message = MessageType.FromErrorString(String.Format("An error occurred while set processing: '{0}'", ex.Message));
                return collectedObject;
            }
        }
示例#14
0
文件: ProbeBase.cs 项目: ywcsz/modSIC
        /// <summary>
        /// Executes a normal collect, using the system datasource for data collecting.
        /// </summary>
        /// <param name="ovalComponent">The oval component.</param>
        /// <param name="collectInfo">The collect info.</param>
        /// <param name="id">The id parameter is 'a sequencial number controlled by external scope.</param>
        /// <returns></returns>
        private CollectedObject ProcessCollect(Definitions.ObjectType ovalComponent, CollectInfo collectInfo, ProbeResultBuilder probeResultBuilder, ref int id)
        {
            CollectedObject collectedObject = null;
            var allItemsToCollect = this.TryToGetItemsToCollect(ovalComponent, collectInfo.Variables);

            if (allItemsToCollect.Count() > 0)
            {
                collectedObject = new CollectedObject(ovalComponent.id);
                foreach (var itemToCollect in allItemsToCollect)
                {
                    var collectedItems = ObjectCollector.CollectDataForSystemItem(itemToCollect);
                    foreach (var collectedItem in collectedItems)
                    {
                        var itemType = probeResultBuilder.GetItemType(collectedItem.ItemType);
                        if (itemType == null)
                        {
                            collectedItem.ItemType.id = id.ToString();
                            id++;
                        }
                        else
                        {
                            collectedItem.ItemType = itemType;
                        }

                        collectedObject.AddItemToSystemData(collectedItem.ItemType);
                        var variables = collectInfo.GetVariableValueForOvalComponent(collectedObject.ObjectType.id);
                        collectedObject.AddVariableReference(variables);
                        ExecutionLogBuilder.AddDetailInformation(collectedItem.ExecutionLog);
                    }
                }

                collectedObject.UpdateCollectedObjectStatus();
            }

            return collectedObject;
        }
示例#15
0
文件: ProbeBase.cs 项目: ywcsz/modSIC
        protected virtual ProbeResultBuilder CollectInformation(CollectInfo collectInfo)
        {
            CollectedObject collectedObject = null;
            var probeResultBuilder = new ProbeResultBuilder();

            int idOfItems = 1;
              //  var objectsOfAnEspecificType = this.GetObjectsOfType(collectInfo.ObjectTypes);

            ObjectCollector.PrepareCollectionOfObjects(collectInfo.ObjectTypes, collectInfo.Variables);
            foreach (var ovalObject in collectInfo.ObjectTypes)
            {
                ExecutionLogBuilder.CollectingInformationFrom(ovalObject.id);

                if (this.ObjectTypeHasSet(ovalObject))
                    collectedObject = this.ProcessSet(ovalObject, collectInfo);
                else
                    collectedObject = this.ProcessCollect(ovalObject, collectInfo, probeResultBuilder, ref idOfItems);

                probeResultBuilder.AddCollectedObject(collectedObject);
            }

            return probeResultBuilder;
        }
示例#16
0
 /// <summary>
 /// Collects the information for variableProbes. The variable prober not needs a real systemDataSource.
 /// The SystemDataSource implementation for this prober, is only for compatibility with the architecture.
 /// Because this, is necessary configure a systemDataSource with the set of variables for the creation of 
 /// Items.
 /// </summary>
 /// <param name="collectInfo">The collect info.</param>
 /// <returns></returns>
 protected override ProbeResultBuilder CollectInformation(CollectInfo collectInfo)
 {
     ((VariableObjectCollector)this.ObjectCollector).VariableEvaluated = collectInfo.Variables;
     return base.CollectInformation(collectInfo);
 }
示例#17
0
 public SIDProberTest() 
 {
     FakeCollectInfo = GetFakeCollectInfo("oval:modulo:obj:8");
     FakeItemsToBeReturnedByItemTypeGenerator = new ItemType[] { CreateFakeSidItem() };
     FakeCollectedItems = new CollectedItem[] { ProbeHelper.CreateFakeCollectedItem(CreateFakeSidItem()) };
 }
示例#18
0
 public UserSID55ProberTest()
 {
     FakeCollectInfo = this.GetFakeCollectInfo("oval:modulo:obj:1080");
     FakeItemsToBeReturnedByItemTypeGenerator = new ItemType[] { CreateFakeUserSIDItem() };
     FakeCollectedItems = CreateFakeCollectedItems();
 }
示例#19
0
 public GroupSIDProberTest()
 {
     FakeCollectInfo = GetFakeCollectInfo("oval:modulo:obj:1110");
     FakeItemsToReturnByItemTypeGenerator = new ItemType[] { new group_sid_item() };
     FakeCollectedItems = new CollectedItem[] { ProbeHelper.CreateFakeCollectedItem(this.CreateFakeGroupSIDItemType()) };
 }
示例#20
0
 public AccessTokenProberTest()
 {
     FakeCollectInfo = GetFakeCollectInfo("oval:modulo:obj:840");
     FakeItemsToCollect = new ItemType[] { new accesstoken_item() };
     FakeCollectedItems = new CollectedItem[] { ProbeHelper.CreateFakeCollectedItem(new accesstoken_item()) };
 }
 public FileAuditedPermissionsProberTests()
 {
     FakeItemsToCollect = new ItemType[] { new fileauditedpermissions_item() };
     FakeCollectedItems = new CollectedItem[] { ProbeHelper.CreateFakeCollectedItem(FakeItemsToCollect.First()) };
     FakeCollectInfo = GetFakeCollectInfo("2400");
 }
示例#22
0
文件: ProbeBase.cs 项目: ywcsz/modSIC
        public ProbeResult Execute(
            IList<IConnectionProvider> connectionContext, 
            TargetInfo target, 
            CollectInfo collectInfo)
        {
            this.ExecutionLogBuilder = new ExecutionLogBuilder();
            this.ExecutionLogBuilder.TryConnectToHost(target.GetAddress());
            this.OpenConnectionProvider(connectionContext, target);

            ExecuteAfterOpenConnectionProvider();

            this.ExecutionLogBuilder.ConnectedToHostWithUserName(target.credentials.GetFullyQualifiedUsername());
            this.ConfigureObjectCollector();

            ProbeResultBuilder probeResultBuilder = this.CollectInformation(collectInfo);
            probeResultBuilder.AddExecutionLogs(this.ExecutionLogBuilder.BuildExecutionLogs());
            return probeResultBuilder.ProbeResult;
        }