示例#1
0
        public ProbeResult CreateProbeResultForRegistryCollectWithSytemDataDuplicated()
        {
            ProbeResult probeResult = RegistryProbeFactory.CreateProbeResultForRegistryCollectWithSytemDataDuplicated();

            probeResult.SystemInformation = this.CreateSystemInformation();
            return(probeResult);
        }
示例#2
0
        public ProbeResult CreateProbeREsultForFamilyCollect()
        {
            ProbeResult probeResult = FamilyProbeResultFactory.CreateProbeResultForFamilyollect();

            probeResult.SystemInformation = this.CreateSystemInformation();
            return(probeResult);
        }
示例#3
0
        public ProbeResult CreateProbeResultForFamilyWithSpecificObjectTypes(IEnumerable <definitions.ObjectType> objectTypes, List <string> resultsForObjects)
        {
            ProbeResult probeResult = FamilyProbeResultFactory.CreateProbeResultWithSpecificObject(objectTypes, resultsForObjects);

            probeResult.SystemInformation = this.CreateSystemInformation();
            return(probeResult);
        }
示例#4
0
        public ProbeResult CreateProbeResultForRegistryCollectWithVariables()
        {
            ProbeResult probeResult = RegistryProbeFactory.CreateProbeResultForRegistryCollectWithVariables();

            probeResult.SystemInformation = this.CreateSystemInformation();
            return(probeResult);
        }
示例#5
0
        public void TestProbeResult()
        {
            var outputs = ProbeResult.ReadProbeResults(Path.Combine(folder, "internalCloud"));

            Assert.IsTrue(outputs.ContainsKey("p"));
            Assert.IsTrue(outputs.ContainsKey("U"));
        }
示例#6
0
        // Token: 0x0600156D RID: 5485 RVA: 0x00079DC8 File Offset: 0x00077FC8
        public MailboxProcessorNotificationEntry(ProbeResult probeResult)
        {
            Guid guid;

            if (!Guid.TryParse(probeResult.StateAttribute1, out guid))
            {
                throw new FailedToReadProbeResultException(1, "mailboxGuid", probeResult.StateAttribute1);
            }
            Guid guid2;

            if (!Guid.TryParse(probeResult.StateAttribute2, out guid2))
            {
                throw new FailedToReadProbeResultException(2, "databaseGuid", probeResult.StateAttribute2);
            }
            int num;

            if (!int.TryParse(probeResult.StateAttribute4, out num))
            {
                throw new FailedToReadProbeResultException(3, "issueDetectedCount", probeResult.StateAttribute3);
            }
            this.issueDetectedCount = num;
            this.mailboxGuid        = guid;
            this.databaseGuid       = guid2;
            Guid guid3;

            Guid.TryParse(probeResult.StateAttribute3, out guid3);
            this.externalDirectoryOrganizationId = guid3;
        }
示例#7
0
 protected virtual void NotifyObservers(ProbeResult result)
 {
     foreach (var observer in _resultObservers)
     {
         observer.OnNext(new () { Result = result, Timestamp = DateTimeOffset.Now });
     }
 }
示例#8
0
        /// <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);
        }
示例#9
0
        public void Should_be_possible_to_collect_file_effective_rights()
        {
            #region File Effective Rights Object
            //<fileeffectiverights_object id="oval:modulo:obj:7" version="1" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#windows">
            //    <path>c:\temp</path>
            //    <filename>file1.txt</filename>
            //    <trustee_name>mss\lfernandes</trustee_name>
            //</fileeffectiverights_object>
            #endregion

            oval_definitions            definitions               = ProbeHelper.GetFakeOvalDefinitions("definitionsSimple.xml");
            CollectInfo                 fakeCollectInfo           = ProbeHelper.CreateFakeCollectInfo(definitions.objects, null, null);
            Definitions::ObjectType     fileEffectiveRightsObject = ProbeHelper.GetOvalComponentByOvalID(definitions, "oval:modulo:obj:7");
            IEnumerable <CollectedItem> fakeCollectedItems        = new CollectedItem[] { this.createFakeCollectedItem(fileEffectiveRightsObject) };

            FileEffectiveRightsProber prober = this.createMockedFileEffectiveRightsProber(fakeCollectedItems);
            ProbeResult result = prober.Execute(ProbeHelper.CreateFakeContext(), ProbeHelper.CreateFakeTarget(), fakeCollectInfo);

            Assert.IsNotNull(result, "The result of FileEffectiveRightsProber execution cannot be null.");
            Assert.IsNotNull(result.ExecutionLog, "The ExecutionLog of FileEffectiveRightsProber was not created.");
            Assert.IsNotNull(result.CollectedObjects, "There are no collected objects.");
            Assert.AreEqual(1, result.CollectedObjects.Count(), "Unexpected collected objects count found.");

            this.AssertCollectedFileItems(fileEffectiveRightsObject, result.CollectedObjects.ElementAt(0), fakeCollectedItems);
        }
示例#10
0
        private async void AssignProbe(SimulatedUser user)
        {
            if (user.bHasFinishedWork)
            {
                return;
            }

            user.NumberOfConcurrentUsers =
                SimulatedUserList.Where(x =>
                                        x.bHasStartedWork && !x.bHasFinishedWork).Count();

            EndpointProbe probe = TestSchedule.GetNextProbe();

            await Task.Run(async() =>
            {
                if (probe != null)
                {
                    if (user.bAsyncUser)
                    {
                        AssignProbe(user);
                    }

                    ProbeResult probeResult = await user.ExecuteProbe(probe);

                    ResultSet.Add(probeResult);
                    RaiseNewFreeUser(user);
                }
            });
        }
        public CollectExecutionManager CreateExecutionManagerForTheSuccessScenario(ProbeResult resultForRegistry, ProbeResult resultForFamily)
        {
            MockRepository mocks = new MockRepository();

            probeManager             = mocks.DynamicMock <IProbeManager>();
            probe                    = mocks.DynamicMock <IProbe>();
            familyProbe              = mocks.DynamicMock <IProbe>();
            dataProvider             = mocks.DynamicMock <IDataProvider>();
            systemInformationService = mocks.DynamicMock <ISystemInformationService>();
            connectionContext        = this.CreateConnectionContext();

            CollectInfo collectInfo = new CollectInfo()
            {
                ObjectTypes = ovalObjects
            };

            Expect.Call(probeManager.GetProbesFor(null, FamilyEnumeration.windows)).IgnoreArguments().Repeat.Any().Return(this.GetSelectedProbes());
            Expect.Call(probeManager.GetSystemInformationService(FamilyEnumeration.windows)).IgnoreArguments().Repeat.Any().Return(systemInformationService);
            Expect.Call(probe.Execute(connectionContext, target, collectInfo)).IgnoreArguments().Repeat.Any().Return(resultForRegistry);
            Expect.Call(familyProbe.Execute(connectionContext, target, collectInfo)).IgnoreArguments().Repeat.Any().Return(resultForFamily);
            Expect.Call(dataProvider.GetSession()).Repeat.Any().Return(session).IgnoreArguments();
            Expect.Call(dataProvider.GetTransaction(session)).Repeat.Any().Return(new Transaction(session)).IgnoreArguments();
            Expect.Call(systemInformationService.GetSystemInformationFrom(target)).IgnoreArguments().Return(this.GetExpectedSystemInformation());

            mocks.ReplayAll();

            return(new CollectExecutionManager(probeManager)
            {
                Target = target, connectionContext = connectionContext
            });
        }
示例#12
0
 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.");
 }
示例#13
0
 protected virtual void NotifyObservers(ProbeResult result)
 {
     foreach (var observer in _resultObservers)
     {
         observer.OnNext(new ProbeContextImpl(result));
     }
 }
示例#14
0
        public static IBus CreateWebToGatewayBus()
        {
            var sb = Bus.Factory.CreateUsingRabbitMq(
                sbc =>
            {
                sbc.UseLog4Net();

                var host = sbc.Host(new Uri(rabbitMqServer), h =>
                {
                    h.Username(rabbitMqUsername);
                    h.Password(rabbitMqPassword);
                });

                sbc.ReceiveEndpoint(
                    host,
                    "ZZ_Web_To_Gateway_Queue",
                    ep =>
                {
                    ep.UseConcurrencyLimit(8);
                    ep.UseRetry(Retry.None);

                    ep.Consumer <GatewayConsumer>();
                });
                ConsoleHelper.WriteLine(rabbitMqServer + "ZZ_Web_To_Gateway_Queue");
            });

            sb.Start();

            ProbeResult result = sb.GetProbeResult();

            ConsoleHelper.WriteDebugLine(result.ToJsonString());

            return(sb);
        }
示例#15
0
        public async Task HealthCheckResultProcessor_should_fail_with_bad_probes()
        {
            // arrange
            var watch = new Stopwatch();

            watch.Start();
            var context = new Mock <IAutoHealthCheckContext>();

            context.Setup(c => c.Configurations)
            .Returns(new AutoHealthCheckConfigurations());     // default rule

            var probes = new List <ProbeResult>
            {
                ProbeResult.Error("error"),
                ProbeResult.Ok()
            };

            // act
            var result = await HealthCheckResultProcessor.ProcessResult(
                context.Object,
                watch,
                new HttpResponseMessage[0],
                probes.ToArray());

            // assert
            Assert.NotNull(result);
            Assert.Equal(500, (int)result.HttpStatus);
            Assert.Equal("error", result.UnhealthyProbes.First().ErrorMessage);
            Assert.False(result.Success);
        }
示例#16
0
        public async Task HealthCheckResultProcessor_should_return_ok_with_successfully_probes()
        {
            // arrange
            var watch = new Stopwatch();

            watch.Start();
            var context = new Mock <IAutoHealthCheckContext>();

            context.Setup(c => c.Configurations)
            .Returns(new AutoHealthCheckConfigurations());     // default rule

            var probes = new List <ProbeResult>
            {
                ProbeResult.Ok(),
                ProbeResult.Ok()
            };

            // act
            var result = await HealthCheckResultProcessor.ProcessResult(
                context.Object,
                watch,
                new HttpResponseMessage[0],
                probes.ToArray());

            // assert
            Assert.NotNull(result);
            Assert.Equal(200, (int)result.HttpStatus);
            Assert.True(result.Success);
        }
示例#17
0
        public void Should_Be_Possible_To_Execute_A_Family_Probe()
        {
            var fakeDefinitions = ProbeHelper.GetFakeOvalDefinitions("fdcc_xpfirewall_oval_regex_on_value.xml");
            var fakeCollectInfo = new CollectInfo()
            {
                ObjectTypes = fakeDefinitions.objects.OfType <family_object>()
            };

            ProbeResult result =
                GetFamilyProber()
                .Execute(null, ProbeHelper.CreateFakeTarget(), fakeCollectInfo);

            var collectedFamily = result.CollectedObjects.ElementAt(0);

            Assert.IsNotNull(result.CollectedObjects);
            Assert.AreEqual(1, result.CollectedObjects.Count());
            Assert.AreEqual(1, collectedFamily.ObjectType.reference.Count());
            Assert.AreEqual(collectedFamily.ObjectType.reference.Count(), collectedFamily.SystemData.Count);
            Assert.AreEqual("oval:modulo:obj:99", collectedFamily.ObjectType.id);
            Assert.AreEqual(collectedFamily.ObjectType.reference[0].item_ref, collectedFamily.SystemData[0].id);

            var familyItem = (family_item)collectedFamily.SystemData[0];

            Assert.AreEqual(StatusEnumeration.exists, familyItem.status);
            Assert.AreEqual("Windows", familyItem.family.Value);
        }
示例#18
0
        public ProbeExecution CreateAProbeExecution(ProbeResult probeResult, string capability)
        {
            ProbeExecution probe = new ProbeExecution();

            probe.Capability = capability;
            this.SetExecutionLog(probeResult.ExecutionLog, probe);
            return(probe);
        }
        public static ProbeResult CreateProbeResultForFamilyollect()
        {
            ProbeResult probeResult = new ProbeResult();

            probeResult.CollectedObjects = CreateCollectedResultsForFamilyCollect();
            probeResult.ExecutionLog     = CreateAnExecutionLogForFamily();
            return(probeResult);
        }
示例#20
0
            public async Task <ProbeResult> Check()
            {
                await Task.Delay(1000);

                Order++;

                return(ProbeResult.Ok());
            }
示例#21
0
        public static ProbeResult CreateProbeResultForRegostryCollectWithError()
        {
            ProbeResult probeResult = new ProbeResult();

            probeResult.CollectedObjects = CreateCollectedResultsForRegistryCollect();
            probeResult.ExecutionLog     = CreateAnExecutionLogForRegistryWithError();
            return(probeResult);
        }
示例#22
0
        public static ProbeResult CreateProbeResultWithSpecificObject(IEnumerable <definitions.ObjectType> objectTypes, List <string> resultsForObjects)
        {
            ProbeResult probeResult = new ProbeResult();

            probeResult.CollectedObjects = CreateCollectedObjectsForSpecificObjectTypes(objectTypes, resultsForObjects);
            probeResult.ExecutionLog     = CreateAnExecutionLogForRegistry();
            return(probeResult);
        }
示例#23
0
 /// <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);
 }
示例#24
0
        public async Task Should_return_a_wonderful_breakdown_of_the_guts_inside_it()
        {
            await Bus.Publish(new PingMessage());

            await _handled;

            ProbeResult result = Bus.GetProbeResult();

            Console.WriteLine(result.ToJsonString());
        }
示例#25
0
        /// <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);
        }
示例#26
0
        public void ProbeResult_ok_should_be_successfully()
        {
            // arrange
            // act
            var result = ProbeResult.Ok();

            // assert
            Assert.True(result.Succeed);
            Assert.Null(result.ErrorMessage);
        }
示例#27
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);
        }
示例#28
0
        //protected CollectInfo GetFakeCollectInfoWithManyObjectTypes(string[] objectTypeIDs)
        //{
        //    var fakeObjectTypes = new List<OVAL.Definitions.ObjectType>();
        //    foreach (var objectID in objectTypeIDs)
        //    {
        //        var newObjectType = ProbeHelper.GetDefinitionObjectTypeByID("definitionsSimple.xml", objectID);
        //        fakeObjectTypes.Add(newObjectType);
        //    }

        //    return ProbeHelper.CreateFakeCollectInfo(fakeObjectTypes.ToArray(), null, null);
        //}

        protected void DoAssertForSingleCollectedObject(
            ProbeResult executionResult,
            Type expectedItemInstanceType)
        {
            DoBasicAssert(executionResult);

            var collectedItems = executionResult.CollectedObjects.Single().SystemData;

            Assert.AreEqual(1, collectedItems.Count, "Only one item is expected on system data.");
            Assert.IsInstanceOfType(collectedItems.Single(), expectedItemInstanceType, "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.");
        }
示例#29
0
        private void DoBasicAssert(ProbeResult executionResult)
        {
            Assert.IsNotNull(executionResult, "The probe execution cannot be null.");
            Assert.IsNotNull(executionResult.ExecutionLog, "The probe execution log cannot be null");
            Assert.AreEqual(1, executionResult.CollectedObjects.Count(), "Only one collected object is expected for this test.");

            var collectedObject = executionResult.CollectedObjects.Single();
            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.");
        }
示例#30
0
        /// <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());
        }
        /// <summary>
        /// Probes a <paramref name="uri"/> to see whether there is
        /// container active there.
        /// </summary>
        /// <param name="uri">A <see langword="string"/> containing the 
        /// unique reosurce identifier of a possible remote container.
        /// </param>
        /// <returns>A <see cref="T:Aneka.UI.Configuration.ProbeResult"/> specifing the
        /// result of the probe operation.</returns>
        protected ProbeResult ProbeContainer(string uri)
        {
            ProbeResult result = null;
            try
            {
                ProbeQueryMessage probe = new ProbeQueryMessage("");
                Message msg = MessageDispatcher.SendMessage(new Uri(uri), probe);
                ProbeReplyMessage reply = msg as ProbeReplyMessage;

                Exception inner = null;

                if (reply == null)
                {
                    ErrorMessage error = msg as ErrorMessage;
                    if (error != null)
                    {
                        inner = error.Cause;
                    }
                    else
                    {
                        string errMsg = string.Format("Invalid response to probe: " + msg.GetType().FullName);
                        inner = new Exception(errMsg);
                        inner.Data.Add("message", msg);
                    }

                }

                result = new ProbeResult(uri, ProbeStatus.ServiceActive, inner);
            }
            catch (Exception ex)
            {

                // [CV] NOTE: we already know that the port is active if we call
                //            this method, hence it might be another service.
                result = new ProbeResult(uri, ProbeStatus.ServiceUnknown, ex);
            }

            return result;
        }
        /// <summary>
        /// Performs a test to check whether the master container
        /// is active on the given uri.
        /// </summary>
        /// <param name="state">An instance of <see cref="T:System.Uri"/>
        /// representing the unique resource identifier of the container.</param>
        private ProbeResult ProbeWorker(Uri state)
        {
            ProbeResult outcome = null;
            Uri workerUri = state;
            try
            {
                string ip = workerUri.Host;
                if (workerUri.HostNameType == UriHostNameType.Dns)
                {
                    ip = NetworkUtil.GetIPByHostName(workerUri.Host);
                }
                bool bActive = NetworkUtil.Ping(ip);
                if (bActive == true)
                {
                    bActive = NetworkUtil.Probe(ip, workerUri.Port);
                    if (bActive == true)
                    {
                        outcome = ProbeContainer(workerUri.OriginalString);
                    }
                    else
                    {
                        outcome = new ProbeResult(workerUri.OriginalString, ProbeStatus.ServiceUnactive);
                    }
                }
                else
                {
                    outcome = new ProbeResult(workerUri.OriginalString, ProbeStatus.NetworkUnreachable);
                }
            }
            catch (Exception ex)
            {
                outcome = new ProbeResult(workerUri.OriginalString, ProbeStatus.Error, ex);
                return outcome;
            }

            if (outcome == null)
            {
                outcome = new ProbeResult(workerUri.Host, ProbeStatus.ServiceActive);
            }
            //try
            //{
            //    this.Invoke(new ProbeUpdater(this.UpdateMasterUI), new object[] { outcome });
            //}
            //catch (Exception ex)
            //{
            //    // if the dialog is closing and the thread is trying to update
            //    // the user interface we have an exception, we then wrap it and
            //    // everything should be fine...
            //}
            return outcome;
        }
        /// <summary>
        /// Refresh Worker Status
        /// </summary>
        /// <param name="WorkerID">Worker ID</param>
        /// <returns>Worker Status</returns>
        public ProbeResult RefreshWorker(int WorkerID)
        {
            Worker worker = db.Workers.Find(WorkerID);
            Cloud cloud = cloudLookupFromWorkerId(WorkerID);
            CloudWebPortal.Areas.Aneka.Models.Machine machine = machineLookupFromWorkerId(WorkerID);

            ProbeResult result = new ProbeResult(GetContainerUri(machine.IP, worker.Port), ProbeStatus.Error);

            Uri workerUri = null;
            string container = null;

            try
            {
                if (machine == null || worker.AnekaContainerID == null)
                    return result;

                container = GetContainerUri(machine.IP, worker.Port);
                workerUri = new Uri(container);

                // [CV] NOTE: we are now sure that everything is at least
                //            feasible for starting asynchronous probing.
                result = ProbeWorker(workerUri);

            }
            catch (Exception ex)
            {
                result = new ProbeResult(container, ProbeStatus.Error, ex);
            }
            finally
            {
                worker.StatusEnum = result.Status;
                if (result.Status == ProbeStatus.ServiceActive)
                    worker.isInstalled = true;
                db.SaveChanges();
            }

            return result;
        }