private IEnumerable <RegistryObject> ProcessVariables(RegistryObject registry)
        {
            var hiveValues = this.ProcessEntityVariables(registry, registry_object_ItemsChoices.hive.ToString()).Distinct();
            var keyValues  = this.ProcessEntityVariables(registry, registry_object_ItemsChoices.key.ToString()).Distinct();
            var nameValues = this.ProcessEntityVariables(registry, registry_object_ItemsChoices.name.ToString()).Distinct();

            return(RegistryObjectFactory
                   .CreateRegistryObjectsByCombinationOfEntitiesFrom(
                       hiveValues, keyValues, nameValues, registry));
        }
예제 #2
0
        public void Should_be_possible_create_a_registryObject_by_the_combination_of_multiples_entities()
        {
            List <string> hives = new List <string>()
            {
                "HKEY_LOCAL_MACHINE"
            };
            List <string> keys = new List <string>()
            {
                @"Software\Microsoft\Windows", @"Software\Microsoft\Windows NT"
            };
            List <string> names = new List <string>()
            {
                "CurrentVersion"
            };

            IEnumerable <RegistryObject> registryObjects = RegistryObjectFactory.CreateRegistryObjectsByCombinationOfEntitiesFrom(hives, keys, names, this.GetRegistryObject());

            Assert.IsTrue(registryObjects.Count() == 2, "the quantity of registryObjects is not expected");
            Assert.AreEqual(registryObjects.ElementAt(0).Hive, hives.ElementAt(0), "the hive is not expected");
            Assert.AreEqual(registryObjects.ElementAt(0).Key, keys.ElementAt(0), "the key is not expected");
            Assert.AreEqual(registryObjects.ElementAt(0).Name, names.ElementAt(0), "the name is not expected");
            Assert.AreEqual(registryObjects.ElementAt(1).Hive, hives.ElementAt(0), "the hive is not expected");
            Assert.AreEqual(registryObjects.ElementAt(1).Key, keys.ElementAt(1), "the key is not expected");
            Assert.AreEqual(registryObjects.ElementAt(1).Name, names.ElementAt(0), "the name is not expected");

            hives = new List <string>()
            {
                "HKEY_LOCAL_MACHINE"
            };
            keys = new List <string>()
            {
                @"Software\Microsoft\Windows", @"Software\Microsoft\Windows NT"
            };
            names = new List <string>()
            {
                "CurrentVersion", "CurrentBuild"
            };

            registryObjects = RegistryObjectFactory.CreateRegistryObjectsByCombinationOfEntitiesFrom(hives, keys, names, this.GetRegistryObject());
            Assert.IsTrue(registryObjects.Count() == 4, "the quantity of registryObjects is not expected");
            Assert.AreEqual(registryObjects.ElementAt(0).Hive, hives.ElementAt(0), "the hive is not expected");
            Assert.AreEqual(registryObjects.ElementAt(0).Key, keys.ElementAt(0), "the key is not expected");
            Assert.AreEqual(registryObjects.ElementAt(0).Name, names.ElementAt(0), "the name is not expected");
            Assert.AreEqual(registryObjects.ElementAt(1).Hive, hives.ElementAt(0), "the hive is not expected");
            Assert.AreEqual(registryObjects.ElementAt(1).Key, keys.ElementAt(0), "the key is not expected");
            Assert.AreEqual(registryObjects.ElementAt(1).Name, names.ElementAt(1), "the name is not expected");
            Assert.AreEqual(registryObjects.ElementAt(2).Hive, hives.ElementAt(0), "the hive is not expected");
            Assert.AreEqual(registryObjects.ElementAt(2).Key, keys.ElementAt(1), "the key is not expected");
            Assert.AreEqual(registryObjects.ElementAt(2).Name, names.ElementAt(0), "the name is not expected");
            Assert.AreEqual(registryObjects.ElementAt(3).Hive, hives.ElementAt(0), "the hive is not expected");
            Assert.AreEqual(registryObjects.ElementAt(3).Key, keys.ElementAt(1), "the key is not expected");
            Assert.AreEqual(registryObjects.ElementAt(3).Name, names.ElementAt(1), "the name is not expected");
        }
예제 #3
0
        public void Should_be_possible_create_a_registryObject_by_the_combination_of_entities()
        {
            List <string> hives = new List <string>()
            {
                "HKEY_LOCAL_MACHINE"
            };
            List <string> keys = new List <string>()
            {
                @"Software\Microsoft\Windows"
            };
            List <string> names = new List <string>()
            {
                "CurrentVersion"
            };

            IEnumerable <RegistryObject> registryObjects = RegistryObjectFactory.CreateRegistryObjectsByCombinationOfEntitiesFrom(hives, keys, names, this.GetRegistryObject());

            Assert.IsTrue(registryObjects.Count() == 1, "the quantity of registryObjects is not expected");
            Assert.AreEqual(registryObjects.ElementAt(0).Hive, hives.ElementAt(0), "the hive is not expected");
            Assert.AreEqual(registryObjects.ElementAt(0).Key, keys.ElementAt(0), "the key is not expected");
            Assert.AreEqual(registryObjects.ElementAt(0).GetVariableId(registry_object_ItemsChoices.key.ToString()), "oval:org.mitre.oval:var:3000", "the variable Id is not expected");
            Assert.AreEqual(registryObjects.ElementAt(0).Name, names.ElementAt(0), "the name is not expected");
            Assert.AreEqual(registryObjects.ElementAt(0).GetOperationOfEntity(registry_object_ItemsChoices.name.ToString()), OperationEnumeration.equals, "the name operation is not expected");
        }