Exemplo n.º 1
0
        public void Should_be_possible_add_a_detail_information_in_the_log()
        {
            ExecutionLogBuilder executionLogDetailBuilder = new ExecutionLogBuilder();

            executionLogDetailBuilder.CollectingDataFrom("Key: HKEY_LOCAL_MACHINE\\software\\microsoft\\windows\\currentVersion\\BuildType");
            executionLogDetailBuilder.CollectingDataFrom("Key: HKEY_LOCAL_MACHINE\\software\\microsoft\\windows\\currentVersion\\PathName");
            IEnumerable <ProbeLogItem> executionLogDetail = executionLogDetailBuilder.BuildExecutionLogs();

            ExecutionLogBuilder executionLog = new ExecutionLogBuilder();

            executionLog.StartCollectOf("Registry");
            executionLog.TryConnectToHost("176.16.3.166");

            executionLog.AddDetailInformation(executionLogDetail);

            executionLog.CollectingInformationFrom("oval:id:7589");
            executionLog.EndCollect();
            IEnumerable <ProbeLogItem> executionLogComplete = executionLog.BuildExecutionLogs();

            Assert.AreEqual(6, executionLogComplete.Count(), "the quantity of logs entries is not expected");
            Assert.AreEqual(executionLogComplete.ElementAt(2).Message, executionLogDetail.ElementAt(0).Message, "the detail log is no found in the correct position in the complete log");
            Assert.AreEqual(executionLogComplete.ElementAt(3).Message, executionLogDetail.ElementAt(1).Message, "the detail log is no found in the correct position in the complete log");
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
 /// <summary>
 /// this method makes the combination between probeLogs and contextLog, provided by ExecutionManager.
 /// This process normally occours in the end of collect of a probe.
 /// Because this, in this process is included the End entry in the log.
 /// </summary>
 /// <param name="probe">The probe.</param>
 /// <param name="probeResult">The probe result.</param>
 private void MergeExecutionLogs(ExecutionLogBuilder executionLog, SelectedProbe probe, ProbeResult probeResult)
 {
     executionLog.AddDetailInformation(probeResult.ExecutionLog);
     executionLog.EndCollectOf(probe.Capability.OvalObject);
     probeResult.ExecutionLog = executionLog.BuildExecutionLogs();
 }