Пример #1
0
 private ProbeExecution GetProbeExecutionWithSuccess(IDocumentSession session)
 {
     ProbeResult probeResult = new ProbeResultFactory().CreateProbeResultForRegistryCollect();
     ProbeExecution probeExecution = new CollectFactory().CreateAProbeExecution(probeResult, "registry");
     CollectResult collectResult = new CollectResultFactory().CreateCollectResultForTheProbeExecution(probeResult);
     probeExecution.SystemCharacteristics = collectResult.SystemCharacteristics;
     //probeExecution.Results.Add(collectResult);
     return probeExecution;
 }
Пример #2
0
        private ProbeExecution GetProbeExecutionWithSuccess(IDocumentSession session)
        {
            ProbeResult    probeResult    = new ProbeResultFactory().CreateProbeResultForRegistryCollect();
            ProbeExecution probeExecution = new CollectFactory().CreateAProbeExecution(probeResult, "registry");
            CollectResult  collectResult  = new CollectResultFactory().CreateCollectResultForTheProbeExecution(probeResult);

            probeExecution.SystemCharacteristics = collectResult.SystemCharacteristics;
            //probeExecution.Results.Add(collectResult);
            return(probeExecution);
        }
Пример #3
0
         public void MyTestInitialize() 
         {
             probeResultFactory = new ProbeResultFactory();
             dataprovider = new LocalDataProvider();
             MockRepository mocks = new MockRepository();

             provider = mocks.StrictMock<IDataProvider>();
             Expect.Call(provider.GetSession()).Repeat.Any().Return(dataprovider.GetSession());                                       
             mocks.ReplayAll();

         }
Пример #4
0
        public void Should_be_possible_to_create_a_collectResult_with_the_error_status_for_the_probeExecution()
        {
            CollectResultFactory factory = new CollectResultFactory();

            ProbeResult probeResult = new ProbeResultFactory().CreateProbeResultForRegostryCollectWithError();

            CollectResult collectResult = factory.CreateCollectResultForTheProbeExecution(probeResult);

            Assert.IsNotNull(collectResult);
            Assert.IsNotNull(collectResult.Date, "the date is null");
            Assert.IsTrue(collectResult.HasErrors(), "the collect result is not complete");
        }
Пример #5
0
        public void Should_be_possible_to_get_systemCharacteristics_from_a_collectResult()
        {
            ProbeResult probeResult = new ProbeResultFactory().CreateProbeResultForRegistryCollect();
            CollectResult collectResult = new CollectResultFactory().CreateCollectResultForTheProbeExecution(probeResult);

            oval_system_characteristics systemCharacteristics = collectResult.GetSystemCharacteristic();

            Assert.IsNotNull(systemCharacteristics, "the systemCharacteristics is null");
            Assert.IsTrue(systemCharacteristics.collected_objects.Count() > 0, "the quantity of collected object is 0");
            Assert.IsTrue(systemCharacteristics.system_data.Count() > 0, "the quantity of system data is 0");
        }
        public void Should_be_possible_to_get_a_system_characteristics_in_xml_format_given_a_probeResult_with_variables_defined()
        {
            SystemCharacteristicsFactory factory = new SystemCharacteristicsFactory();

            ProbeResult probe = new ProbeResultFactory().CreateProbeResultForRegistryCollectWithVariables();

            string systemCharacteristicsXML = factory.CreateSystemCharacteristicsInXMLFormat(probe);
            Assert.IsNotNull(systemCharacteristicsXML);

            //creates a stream for the xml generated
            MemoryStream m = new MemoryStream(Encoding.UTF8.GetBytes(systemCharacteristicsXML));
            IEnumerable<string> loadErrors;
            oval_system_characteristics systemCharacteristicsFromXmlGenerated = oval_system_characteristics.GetOvalSystemCharacteristicsFromStream(m, out loadErrors);

            Assert.IsNotNull(systemCharacteristicsFromXmlGenerated, "Not was possible to get a SystemCharacteristis given the xml generated");
            Assert.IsTrue(loadErrors.Count() == 0, "there are errors in the xml");
            Assert.AreEqual(systemCharacteristicsFromXmlGenerated.collected_objects[0].variable_value[0].variable_id, "oval:com.hp:var:4", "the variable Id is not expected");
            Assert.AreEqual(systemCharacteristicsFromXmlGenerated.collected_objects[0].variable_value[0].Value, "Microsoft\\WindowsNT\\", "the variable value is not expected");
        }
        public void Should_be_possible_to_get_a_system_characteristics_in_xml_format_given_a_probeResult()
        {
            SystemCharacteristicsFactory factory = new SystemCharacteristicsFactory();

            ProbeResult probe = new ProbeResultFactory().CreateProbeResultForRegistryCollect();

            string systemCharacteristicsXML = factory.CreateSystemCharacteristicsInXMLFormat(probe);
            Assert.IsNotNull(systemCharacteristicsXML);

            //creates a stream for the xml generated
            MemoryStream m = new MemoryStream(Encoding.UTF8.GetBytes(systemCharacteristicsXML));
            IEnumerable<string> loadErrors;
            oval_system_characteristics systemCharacteristicsFromXmlGenerated = oval_system_characteristics.GetOvalSystemCharacteristicsFromStream(m, out loadErrors);

            Assert.IsNotNull(systemCharacteristicsFromXmlGenerated, "Not was possible to get a SystemCharacteristis given the xml generated");
            Assert.IsTrue(loadErrors.Count() == 0, "there are errors in the xml");
        }
        public void Should_be_possible_to_create_system_characteristics_given_a_probeResult_with_variables()
        {
            SystemCharacteristicsFactory factory = new SystemCharacteristicsFactory();
            ProbeResult probe = new ProbeResultFactory().CreateProbeResultForRegistryCollectWithVariables();

            oval_system_characteristics systemCharacteristics = factory.CreateSystemCharacteristics(probe);

            Assert.IsNotNull(systemCharacteristics);
            Assert.IsNotNull(systemCharacteristics.collected_objects, "the collected object is null");
            Assert.IsTrue(systemCharacteristics.collected_objects[0].id == ProbeResultFactory.ID_REGISTRY_OBJECT, "the oval id is not expected");
            Assert.AreEqual(systemCharacteristics.collected_objects[0].variable_value[0].variable_id,"oval:com.hp:var:4", "the variable Id is not expected");
            Assert.AreEqual(systemCharacteristics.collected_objects[0].variable_value[0].Value, "Microsoft\\WindowsNT\\", "the variable value is not expected");

            Assert.IsTrue(systemCharacteristics.collected_objects.Count() == 1);
            Assert.IsNotNull(systemCharacteristics.system_data, "the system data is null");
            Assert.IsTrue(systemCharacteristics.system_data.Count() > 0, "the system data is empty.");
            Assert.IsNotNull(systemCharacteristics.generator, "the generator is null");
            Assert.IsNotNull(systemCharacteristics.system_info, "the system info is not null.");
            Assert.IsTrue(systemCharacteristics.system_info.interfaces.Count() == 1, "the interfaces is not expected");
        }
        public void Should_be_possible_to_create_system_characteristics_given_a_probeResult()
        {
            SystemCharacteristicsFactory factory = new SystemCharacteristicsFactory();

            ProbeResult probe = new ProbeResultFactory().CreateProbeResultForRegistryCollect();

            oval_system_characteristics systemCharacteristics = factory.CreateSystemCharacteristics(probe);

            Assert.IsNotNull(systemCharacteristics);
            Assert.IsNotNull(systemCharacteristics.collected_objects, "the collected object is null");
            Assert.IsTrue(systemCharacteristics.collected_objects[0].id == ProbeResultFactory.ID_REGISTRY_OBJECT, "the oval id is not expected");
            Assert.IsTrue(systemCharacteristics.collected_objects.Count() == 1);
            Assert.IsNotNull(systemCharacteristics.system_data, "the system data is null");
            Assert.IsTrue(systemCharacteristics.system_data.Count() > 0, "the system data is empty.");
            Assert.IsNotNull(systemCharacteristics.generator, "the generator is null");
            Assert.IsNotNull(systemCharacteristics.system_info, "the system info is not null.");
            Assert.IsTrue(systemCharacteristics.system_info.interfaces.Count() == 1, "the interfaces is not expected");
        }
        public void Should_be_possible_to_create_a_systemCharacteristics_eliminating_duplicate_references_for_itemType_in_the_systemData_property()
        {
            SystemCharacteristicsFactory factory = new SystemCharacteristicsFactory();
            ProbeResult probeResult = new ProbeResultFactory().CreateProbeResultForRegistryCollectWithSytemDataDuplicated();

            oval_system_characteristics systemCharacteristics = factory.CreateSystemCharacteristics(probeResult);

            Assert.IsNotNull(systemCharacteristics, "the systemCharacteristics expected is null");
            Assert.AreEqual(2, systemCharacteristics.system_data.Count(), "the quantity of system data is not expected");
        }
Пример #11
0
 public ProbeResult GetResultForFamily(CollectRequest collectRequest, List<string> resultsForObjects)
 {
     ProbeResultFactory factory = new ProbeResultFactory();
     IEnumerable<ObjectType> familyObjects = collectRequest.GetObjectTypes(session).OfType<family_object>();
     return factory.CreateProbeResultForFamilyWithSpecificObjectTypes(familyObjects, resultsForObjects);
 }
Пример #12
0
 private ProbeResult GetResultForRegistry(CollectRequest collectRequest, List<string> resultsForObjects)
 {
     ProbeResultFactory factory = new ProbeResultFactory();
     IEnumerable<ObjectType> registryObjects = collectRequest.GetObjectTypes(session).OfType<registry_object>();
     return factory.CreateProbeResultForRegistryWithSpecificObjectTypes(registryObjects, resultsForObjects);
 }
Пример #13
0
        public CollectRequest CreateCollectRequestIncompleteAfterCollect(IDocumentSession session)
        {
            CollectRequest collectRequest = new CollectRequest();

            string definitionsInXml = GetOvalObjectInXML(".definitions.fdcc_xpfirewall_oval.xml");
            StringBuilder builder = new StringBuilder(definitionsInXml);
            var newDefinitiondoc = new DefinitionDocument()
            {
                OriginalId = "01",
                Text = builder.ToString()
            };
            session.Store(newDefinitiondoc);
            collectRequest.OvalDefinitionsId = newDefinitiondoc.Oid ;
            session.Store(collectRequest);
            CollectExecution collectExecution = new CollectExecution();
            collectExecution.RequestId = collectRequest.Oid;
            session.Store(collectExecution);
            collectExecution.SetDateStartCollect();
            collectExecution.SetDateEndCollect();
            //collectRequest.Collects.Add(collectExecution);
            ProbeResult probeResult = new ProbeResultFactory().CreateProbeResultForRegistryCollect();

            CollectFactory collectFactory = new CollectFactory(session);
            ProbeExecution probeExecution = collectFactory.CreateAProbeExecution(probeResult, "registry");
            CollectResult collectResult = new CollectResultFactory().CreateCollectResultForTheProbeExecution(probeResult);
            string systemCharacteristicsXml = this.GetSystemCharacteristicsInXML(".system_characteristics.fdcc_xpfirewall_oval.sc_incomplete.xml");            
            collectResult.SystemCharacteristics = systemCharacteristicsXml;

            probeExecution.SystemCharacteristics = collectResult.SystemCharacteristics;
            collectExecution.ProbeExecutions.Add(probeExecution);
           // collectRequest.Collects.Add(collectExecution);
            this.CreateTarget(session, collectRequest);
            session.SaveChanges();
            return collectRequest;
        }
Пример #14
0
        public CollectRequest CreateCompleteCollectRequestAfterCollectWithSystemCharacteristics(
            IDocumentSession session, string definitionsFilename, string SystemCharacteristicsFilename, string externalVariables)
        {
            var probeResult = new ProbeResultFactory().CreateProbeResultForRegistryCollect();
            var definitionsInXML = GetOvalObjectInXML(definitionsFilename);
            var systemCharacteristicsXml = GetSystemCharacteristicsInXML(SystemCharacteristicsFilename);
            var collectResult = new CollectResultFactory().CreateCollectResultForTheProbeExecution(probeResult);
            collectResult.SystemCharacteristics = systemCharacteristicsXml;
            var probeExecution = new CollectFactory(session).CreateAProbeExecution(probeResult, "registry");
            probeExecution.SystemCharacteristics = collectResult.SystemCharacteristics;

            var collectRequest = GetOvalObjectInXML(session, definitionsInXML, externalVariables);
            var collectExecution = CreateCollectExecution(session, collectRequest);
            collectExecution.ProbeExecutions.Add(probeExecution);
           // collectRequest.Collects.Add(collectExecution);
            
            CreateTarget(session, collectRequest);
            
            return collectRequest;
        }
Пример #15
0
        public CollectRequest CreateCollectRequestCompleteAfterCollect(IDocumentSession session)
        {
            CollectRequest collectRequest = new CollectRequest();
            session.Store(collectRequest);
            CollectExecution collectExecution = new CollectExecution();
            session.Store(collectExecution);
            collectExecution.RequestId = collectRequest.Oid;
            collectExecution.SetDateStartCollect();
            collectExecution.SetDateEndCollect();
            ProbeResult probeResult = new ProbeResultFactory().CreateProbeResultForRegistryCollect();
            
            CollectFactory collectFactory = new CollectFactory(session);            
            ProbeExecution probeExecution = collectFactory.CreateAProbeExecution(probeResult, "registry");
            CollectResult collectResult = new CollectResultFactory().CreateCollectResultForTheProbeExecution(probeResult);
            collectRequest.Result = collectResult;
            string systemCharacteristicsXml = this.GetSystemCharacteristicsInXML(".system_characteristics.oval.org.mitre.oval.sc.5368.xml");
            collectResult.SystemCharacteristics = systemCharacteristicsXml;

            probeExecution.SystemCharacteristics = collectResult.SystemCharacteristics;
            collectExecution.ProbeExecutions.Add(probeExecution);
            this.CreateTarget(session, collectRequest);
            //session.Store(collectRequest);
            collectExecution.RequestId = collectRequest.Oid;
            return collectRequest;

        }