示例#1
0
        public void SetResultError()
        {
            var collectResultFactory = new CollectResultFactory();
            var collectResult        = collectResultFactory.CreateCollectResult(CollectStatus.Error, null);

            this.Result = collectResult;
        }
示例#2
0
 private ProbeExecution GetProbeExecutionWithError(IDocumentSession session)
 {
     ProbeResult probeResult = new ProbeResultFactory().CreateProbeResultForRegostryCollectWithError();
     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
        /// <summary>
        /// Build the SystemCharacteristics for this collectRequest.
        /// It is necessary because the SystemCharacteristics, in this case,
        /// must be a merge of results of the all probeExecutions.
        /// The systemCharacteristics, must be have all the object collected by all probes.
        /// </summary>
        private void BuildSystemCharacteristics(IDocumentSession session)
        {
            var systemCharacteristics = this.GetCompleteSystemCharacteristics(session);
            var collectResultFactory  = new CollectResultFactory();

            if (systemCharacteristics != null)
            {
                var systemCharacteristicsInXML = systemCharacteristics.GetSystemCharacteristicsXML();
                var result = collectResultFactory.CreateCollectResult(CollectStatus.Partial, systemCharacteristicsInXML);

                //result.CollectRequestId = Oid;
                //if (Results.Count() > 0)
                //    Results.Remove(Result);

                Result = result;
                session.SaveChanges();
            }
        }
示例#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_create_a_collectResult_given_a_set_of_CollectExecutions()
        {
            CollectResultFactory factory = new CollectResultFactory();

            CollectRequest collectRequest = new CollectRequestFactory().CreateCollectRequestCompleteAfterCollect(provider.GetSession());

            //CollectResult collectResult = factory.CreateCollectResultFromOvalSystemCharacteristics(collectRequest.GetExecutedSystemCharacteristics());

            //Assert.IsNotNull(collectResult);
        }
示例#6
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");
        }
        /// <summary>
        /// Creates the probe execution with his collect result
        /// </summary>
        /// <param name="probeResult">The probe result.</param>
        /// <param name="probe">The probe.</param>
        /// <param name="session">The session.</param>
        /// <returns></returns>
        private ProbeExecution CreateTheProbeExecution(ProbeResult probeResult, SelectedProbe probe)
        {
            CollectResultFactory collectResultFactory = new CollectResultFactory();

            ProbeExecution executionOfCurrentProbe = collectFactory.CreateAProbeExecution(probeResult, probe.Capability.OvalObject);
            CollectResult probeExecutionResult = collectResultFactory.CreateCollectResultForTheProbeExecution(probeResult);
            executionOfCurrentProbe.SystemCharacteristics = probeExecutionResult.SystemCharacteristics;

            return executionOfCurrentProbe;
        }
示例#8
0
        /// <summary>
        /// Build the SystemCharacteristics for this collectRequest.
        /// It is necessary because the SystemCharacteristics, in this case,
        /// must be a merge of results of the all probeExecutions.
        /// The systemCharacteristics, must be have all the object collected by all probes.
        /// </summary>
        private void BuildSystemCharacteristics(IDocumentSession session)
        {
            var systemCharacteristics = this.GetCompleteSystemCharacteristics(session);
            var collectResultFactory = new CollectResultFactory();

            if (systemCharacteristics != null)
            {               
                var systemCharacteristicsInXML = systemCharacteristics.GetSystemCharacteristicsXML();
                var result = collectResultFactory.CreateCollectResult(CollectStatus.Partial, systemCharacteristicsInXML);

                //result.CollectRequestId = Oid;
                //if (Results.Count() > 0)
                //    Results.Remove(Result);

                Result = result;
                session.SaveChanges();
            }           
        }
示例#9
0
 public void SetResultError()
 {
     var collectResultFactory = new CollectResultFactory();
     var collectResult = collectResultFactory.CreateCollectResult(CollectStatus.Error, null);
     this.Result = collectResult;
 }  
示例#10
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;
        }
示例#11
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;
        }
示例#12
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;

        }