Exemple #1
0
        protected override async Task <object> Run_Internal(IObserver observer, string asset, IScanRepository repository,
                                                            object args)
        {
            GetResultResponse ret = null;

            if (!String.IsNullOrEmpty(asset) && args is IDictionary <string, object> dic)
            {
                string niktoRestApiAddress = dic[nameof(niktoRestApiAddress)]?.ToString();
                if (!String.IsNullOrEmpty(niktoRestApiAddress))
                {
                    NiktoApi api = new NiktoApi(niktoRestApiAddress);

                    var scan = await api.CreateScan(new CreateScanRequest { Asset = asset });

                    //testden sonra çıkar
                    await Task.Delay(10000);

                    var r = await api.StopScan(new StopScanRequest { Id0 = scan.Id0, Id1 = scan.Id1 });

                    //

                    while (true)
                    {
                        await Task.Delay(1000);

                        ret = api.GetResult(scan.Id0).Result;
                        if (null != ret)
                        {
                            break;
                        }
                    }
                }
            }

            return(ret);
        }
Exemple #2
0
        public GetResultResponse Beatify()
        {
            GetResultResponse ret = new GetResultResponse();

            if (null != this.Niktoscan)
            {
                if (null != this.Niktoscan.Empty)
                {
                    ret.Info = new GetResultResponse.BasicInfo();
                    CopyPropertiesFrom(ret.Info, this.Niktoscan.Empty);
                }

                if (null != this.Niktoscan.Scandetails && 0 != this.Niktoscan.Scandetails.Length)
                {
                    var first = this.Niktoscan.Scandetails[0];
                    if (null != first.Empty)
                    {
                        CopyPropertiesFrom(ret.Info, first.Empty);
                    }

                    if (null != first.Ssl && 0 != first.Ssl.Length)
                    {
                        var f1 = first.Ssl[0]?.Empty;
                        if (null != f1)
                        {
                            ret.Ssl = new GetResultResponse.SslInfo();
                            CopyPropertiesFrom(ret.Ssl, f1);
                        }
                    }
                    if (null != first.Statistics && 0 != first.Statistics.Length)
                    {
                        var f1 = first.Statistics[0]?.Empty;
                        if (null != f1)
                        {
                            ret.Statistics = new GetResultResponse.StatisticsInfo();
                            CopyPropertiesFrom(ret.Statistics, f1);
                        }
                    }

                    if (null != first.Item && 0 != first.Item.Length)
                    {
                        ret.Items = new List <GetResultResponse.Item>();
                        foreach (var item in first.Item)
                        {
                            GetResultResponse.Item i = new GetResultResponse.Item();
                            if (null != item.Empty)
                            {
                                CopyPropertiesFrom(i, item.Empty);
                            }

                            i.Description = item.Description?.FirstOrDefault();
                            i.Uri         = item.Uri?.FirstOrDefault();
                            i.Namelink    = item.Namelink?.FirstOrDefault();
                            i.Iplink      = item.Iplink?.FirstOrDefault();

                            ret.Items.Add(i);
                        }
                    }
                }
            }

            return(ret);
        }