public ProbeExecution CreateAProbeExecution(ProbeResult probeResult, string capability) { ProbeExecution probe = new ProbeExecution(); probe.Capability = capability; this.SetExecutionLog(probeResult.ExecutionLog, probe); return probe; }
public static ProbeResult CreateProbeResultWithSpecificObject(IEnumerable<OVAL.Definitions.ObjectType> objectTypes, List<string> resultsForObjects) { ProbeResult probeResult = new ProbeResult(); probeResult.CollectedObjects = CreateCollectedObjectsForSpecificObjectTypes(objectTypes,resultsForObjects); probeResult.ExecutionLog = CreateAnExecutionLogForFamily(); return probeResult; }
public static ProbeResult CreateProbeResultForFamilyCollectWithError() { ProbeResult probeResult = new ProbeResult(); probeResult.CollectedObjects = CreateCollectedResultsForFamilyCollect(); probeResult.ExecutionLog = CreateAnExecutionLogForFamilyWithError(); return probeResult; }
public static ProbeResult CreateProbeResultForRegistryCollect() { ProbeResult probeResult = new ProbeResult(); probeResult.CollectedObjects = CreateCollectedResultsForRegistryCollect(); probeResult.ExecutionLog = CreateAnExecutionLogForRegistry(); return probeResult; }
/// <summary> /// Creates the system characteristics given the probeResult. /// </summary> /// <param name="probeResult">result of the probe execution.</param> /// <returns></returns> public oval_system_characteristics CreateSystemCharacteristics(ProbeResult probeResult) { oval_system_characteristics systemCharacteristics = new oval_system_characteristics(); systemCharacteristics.collected_objects = this.GetCollectedObjects(probeResult); systemCharacteristics.system_data = this.GetSystemType(probeResult); systemCharacteristics.generator = this.GetGenerator(); systemCharacteristics.system_info = this.GetSystemInfo(probeResult); return systemCharacteristics; }
public static ProbeResult CreateProbeResultForRegistryCollectWithVariables() { ProbeResult probeResult = new ProbeResult(); CollectedObject registryCollect = CreateRegistryCollectedObject(ID_REGISTRY_OBJECT, 2); registryCollect.AddVariableReference(CreateVariableReference()); List<CollectedObject> collectedObjects = new List<CollectedObject>() { registryCollect }; probeResult.CollectedObjects = collectedObjects; probeResult.ExecutionLog = CreateAnExecutionLogForRegistry(); return probeResult; }
public static ProbeResult CreateProbeResultForRegistryCollectWithSytemDataDuplicated() { ProbeResult probeResult = new ProbeResult(); CollectedObject registryCollect = CreateRegistryCollectedObject(ID_REGISTRY_OBJECT, 2); CollectedObject otherRegistryCollect = CreateRegistryCollectedObject(ID_OTHER_REGISTRY_OBJECT, 2); List<CollectedObject> collectedObjects = new List<CollectedObject>() { registryCollect, otherRegistryCollect }; probeResult.CollectedObjects = collectedObjects; probeResult.ExecutionLog = CreateAnExecutionLogForRegistry(); return probeResult; }
/// <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; }
private void doBasicProbeResultAssert(ProbeResult resultToAssert) { Assert.IsNotNull(resultToAssert, "The result of probe execution cannot be null."); Assert.IsNotNull(resultToAssert.ExecutionLog, "The ExecutionLog of RegKeyEffectiveRightsProber was not created."); Assert.IsNotNull(resultToAssert.CollectedObjects, "There are no collected objects."); }
/// <summary> /// Gets the collect result status. /// </summary> /// <param name="probeResult">The probe result.</param> /// <returns></returns> private CollectStatus GetCollectResultStatus(ProbeResult probeResult) { return probeResult.HasErrors() ? CollectStatus.Error : CollectStatus.Complete; }
/// <summary> /// Creates the CollectResult specific for the ProbeExecution. /// </summary> /// <param name="probeResult">The probe result.</param> /// <returns></returns> public CollectResult CreateCollectResultForTheProbeExecution(ProbeResult probeResult) { var systemCharacteristics = systemCharacteristicsFactory.CreateSystemCharacteristicsInXMLFormat(probeResult); return this.CreateCollectResult(GetCollectResultStatus(probeResult), systemCharacteristics); }
/// <summary> /// Returns the oval ItemType from the ProbeResult. /// </summary> /// <param name="probeResult">The probe result.</param> /// <returns></returns> private ItemType[] GetSystemType(ProbeResult probeResult) { List<ItemType> itemTypes = new List<ItemType>(); foreach (CollectedObject collectedObject in probeResult.CollectedObjects) { //itemTypes.AddRange(collectedObject.SystemData); this.AddItemTypesInTheList(itemTypes, collectedObject.SystemData); } return itemTypes.ToArray(); }
private void initializeProbeResult() { this.probeResult = new ProbeResult(); this.probeResult.CollectedObjects = new List<CollectedObject>(); this.probeResult.ExecutionLog = new List<ProbeLogItem>(); }
private void DoAssertForSetCase(ProbeResult executionResult, int expectedCollectedObjectsCount) { Assert.IsNotNull(executionResult, "The probe execution cannot be null."); Assert.IsNotNull(executionResult.ExecutionLog, "The probe execution log cannot be null"); Assert.AreEqual(expectedCollectedObjectsCount, executionResult.CollectedObjects.Count(), "Only one collected object is expected for this test."); foreach (var collectedObject in executionResult.CollectedObjects) { var collectedItems = collectedObject.SystemData; Assert.AreEqual(collectedObject.ObjectType.reference.Count(), 1, "Unexpected number of item references was found."); Assert.AreEqual(collectedObject.ObjectType.reference.Count(), collectedItems.Count, "Unexpected number of generated items type was found."); Assert.AreEqual(1, collectedItems.Count, "Only one item is expected on system data."); Assert.IsInstanceOfType(collectedItems.Single(), typeof(accesstoken_item), "An unexpected instance of item type was found in system data."); Assert.AreEqual(StatusEnumeration.exists, collectedItems.Single().status, "An unexpected item status was found in system data."); } }
/// <summary> /// Creates the system characteristics in XML format. /// </summary> /// <param name="probeResult">result of the probe execution.</param> /// <returns></returns> public string CreateSystemCharacteristicsInXMLFormat(ProbeResult probeResult) { oval_system_characteristics systemCharacteristics = this.CreateSystemCharacteristics(probeResult); return systemCharacteristics.GetSystemCharacteristicsXML(); }
/// <summary> /// Gets the system info. /// The system info are informations about the station that was executed the collect. /// </summary> /// <param name="probeResult">The probe result.</param> /// <returns></returns> private SystemInfoType GetSystemInfo(ProbeResult probeResult) { SystemInfoType systemInfo = new SystemInfoType(); if (probeResult.SystemInformation != null) { systemInfo.architecture = probeResult.SystemInformation.Architecture; systemInfo.os_name = probeResult.SystemInformation.SystemName; systemInfo.os_version = probeResult.SystemInformation.SystemVersion; systemInfo.primary_host_name = probeResult.SystemInformation.PrimaryHostName; systemInfo.interfaces = new InterfaceType[probeResult.SystemInformation.Interfaces.Count()]; for (int i = 0; i <= (probeResult.SystemInformation.Interfaces.Count - 1); i++) { NetworkInterface networkInterface = probeResult.SystemInformation.Interfaces[i]; InterfaceType interfaceType = new InterfaceType(); interfaceType.interface_name = networkInterface.Name; interfaceType.ip_address = new EntityItemIPAddressStringType() { datatype = SimpleDatatypeEnumeration.ipv4_address, Value = networkInterface.IpAddress }; interfaceType.mac_address = networkInterface.MacAddress; systemInfo.interfaces[i] = interfaceType; } } return systemInfo; }
/// <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(); }
private void DoBasicProbeResultAssert(ProbeResult resultToAssert, int expectedCollectedObjectsCount) { Assert.IsNotNull(resultToAssert, "The result of probe execution cannot be null."); Assert.IsNotNull(resultToAssert.ExecutionLog, "The ExecutionLog of TextFileContentProber was not created."); Assert.IsNotNull(resultToAssert.CollectedObjects, "There are no collected objects."); Assert.AreEqual(expectedCollectedObjectsCount, resultToAssert.CollectedObjects.Count(), "Unexpected collected objects count."); }
/// <summary> /// This method returns the CollectedObjects from the ProbeResult. /// </summary> /// <param name="probeResult">The probe result.</param> /// <returns></returns> private ObjectType[] GetCollectedObjects(ProbeResult probeResult) { ObjectType[] objectTypes = new ObjectType[probeResult.CollectedObjects.Count()]; for(int i = 0; i <= (probeResult.CollectedObjects.Count() - 1); i++) { CollectedObject collectedObject = probeResult.CollectedObjects.ElementAt(i); objectTypes[i] = collectedObject.ObjectType; } return objectTypes; }