Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void Should_be_possible_to_add_reference_for_variables_in_the_ObjectType()
        {
            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
            };

            CollectedObject collectedObject = new CollectedObject("oval:org.mitre.oval:obj:6000");

            collectedObject.AddVariableReference(variables);
            Assert.IsNotNull(collectedObject.ObjectType.variable_value, "the variables was not set");
            Assert.IsTrue(collectedObject.ObjectType.variable_value.Count() == 1, "the quantity of the variable_value is not expected");
            Assert.AreEqual(collectedObject.ObjectType.variable_value[0].Value, "Multiprocessor Free", "the value is not expected");
        }
Ejemplo n.º 3
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);
        }