예제 #1
0
        public IEnumerable <Build> GetAllBuildsForApp(string appId)
        {
            var       xml      = _wrapper.GetBuildList(appId);
            BuildList response = XmlParseHelper.Parse <BuildList>(xml);

            return(response.Builds);
        }
예제 #2
0
        public Mitigation GetAllMitigationsForBuildAndFlaws(string buildIds, string[] flawIds)
        {
            var flaw_string = string.Join(",", flawIds);
            var xml         = _wrapper.GetMitigationInfo(buildIds, flaw_string);

            return(XmlParseHelper.Parse <Mitigation>(xml));
        }
예제 #3
0
        public string Get(string path, NameValueCollection queryParams)
        {
            var webClient = new WebClient {
                BaseAddress = $"https://{_base}"
            };

            var queryString = "";

            if (queryParams.Count > 0)
            {
                queryString = ToQueryString(queryParams);
            }

            var hmacRequest = new HmacRequest
            {
                ApiId      = _apiId,
                ApiKey     = _apiKey,
                HostName   = _base,
                HttpMethod = "GET",
                Url        = path + queryString
            };

            var authorization = _cryptoService.GetHmacHeader(hmacRequest);

            webClient.Headers.Add(_authHeader, authorization);
            var response = webClient.DownloadString($"{path}{queryString}");

            return(XmlParseHelper.GetDecodedXmlResponse(response, true));
        }
예제 #4
0
        public IEnumerable <VeracodeApp> GetAllApps()
        {
            var     xml  = _wrapper.GetAppList();
            AppList list = XmlParseHelper.Parse <AppList>(xml);

            return(list.Apps);
        }
예제 #5
0
        public string PostFile(string path, NameValueCollection queryParams, string filepath)
        {
            var webClient = new WebClient {
                BaseAddress = $"https://{_base}"
            };

            var queryString = "";

            if (queryParams.Count > 0)
            {
                queryString = ToQueryString(queryParams);
            }

            var hmacRequest = new HmacRequest
            {
                ApiId      = _apiId,
                ApiKey     = _apiKey,
                HostName   = _base,
                HttpMethod = "POST",
                Url        = path + queryString
            };

            var authorization = _cryptoService.GetHmacHeader(hmacRequest);

            webClient.Headers.Add(_authHeader, authorization);
            webClient.Headers[HttpRequestHeader.ContentType] = "binary/octet-stream";
            byte[] bytes          = File.ReadAllBytes(filepath);
            var    responseBytes  = webClient.UploadData($"{path}{queryString}", "POST", bytes);
            var    responseString = Encoding.ASCII.GetString(responseBytes);

            return(XmlParseHelper.GetDecodedXmlResponse(responseString, true));
        }
예제 #6
0
        public void TestParse2Vocabulary()
        {
            var result = XmlParseHelper.Parse("bing.xml");

            Assert.IsNotNull(result);
            foreach (var vocabulary in result)
            {
                Debug.WriteLine(vocabulary.ToString());
            }
        }
예제 #7
0
        public Flaw[] GetFlaws(string buildId)
        {
            var xml    = _wrapper.GetDetailedResults(buildId);
            var report = XmlParseHelper.Parse <DetailedReport>(xml);

            return(report.Severity
                   .SelectMany(sev => sev.Category
                               .SelectMany(cat => cat.Cwe
                                           .SelectMany(cwe => cwe.Staticflaws.Flaw)))
                   .ToArray());
        }
예제 #8
0
        public detailedreport GetDetailedReport(string buildId)
        {
            var xml = _wrapper.GetDetailedResults(buildId);

            if (string.IsNullOrWhiteSpace(xml))
            {
                return(null);
            }

            return(XmlParseHelper.Parse <detailedreport>(xml));
        }
예제 #9
0
 /// <summary>
 /// 获取主题名
 /// </summary>
 public void GetTitle()
 {
     try
     {
         recordTitle = XmlParseHelper.GetSingNode("PlayTitle");
     }
     catch (Exception ex)
     {
         WriteLog.WriteErrorLogToFile(string.Format("获取播放主题错误-错误信息:{0},{1}", ex.Message.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), true);
         throw ex;
     }
 }
예제 #10
0
        public IEnumerable <Build> GetAllBuildsForApp(string appId)
        {
            var       xml      = _wrapper.GetBuildList(appId);
            BuildList response = XmlParseHelper.Parse <BuildList>(xml);

            if (string.IsNullOrWhiteSpace(xml))
            {
                return(new Build[0]);
            }

            return(response.Builds);
        }
예제 #11
0
        public IEnumerable <VeracodeApp> GetAllApps()
        {
            var xml = _wrapper.GetAppList();

            if (string.IsNullOrWhiteSpace(xml))
            {
                return(new VeracodeApp[0]);
            }

            AppList list = XmlParseHelper.Parse <AppList>(xml);

            return(list.Apps);
        }
예제 #12
0
        public SeverityType[] GetSeverity(string buildId)
        {
            var xml = _wrapper.GetDetailedResults(buildId);

            if (string.IsNullOrWhiteSpace(xml))
            {
                return(new SeverityType[0]);
            }

            var report = XmlParseHelper.Parse <detailedreport>(xml);

            return(report.severity.ToArray());
        }
예제 #13
0
        public FlawType[] GetFlaws(string buildId)
        {
            var xml = _wrapper.GetDetailedResults(buildId);

            if (string.IsNullOrWhiteSpace(xml))
            {
                return(new FlawType[0]);
            }

            var report = XmlParseHelper.Parse <detailedreport>(xml);

            if (report.severity == null || !report.severity.Any())
            {
                return(new FlawType[0]);
            }

            return(report.severity.Where(x => x.category != null && x.category.Any())
                   .SelectMany(sev => sev.category.Where(x => x.cwe != null && x.cwe.Any())
                               .SelectMany(cat => cat.cwe.Where(x => x.staticflaws != null && x.staticflaws.Any())
                                           .SelectMany(cwe => cwe.staticflaws)))
                   .ToArray());
        }
예제 #14
0
        /// <summary>
        /// 判断播放是否已到期
        /// </summary>
        /// <returns></returns>
        public bool isDeadline()
        {
            try
            {
                //截止日期还未到
                bool     isOverDue = false;
                DateTime start     = DateTime.Now;
                DateTime end;

                List <string> stopDate  = XmlParseHelper.GetNodeList("PlayTime", "StopDate", "deadline");
                List <string> startDate = XmlParseHelper.GetNodeList("PlayTime", "StartDate");

                //开始时间
                if (startDate != null && startDate.Count > 0)
                {
                    start = Convert.ToDateTime(startDate.First());
                }

                //结束时间
                if (stopDate != null && stopDate.Count > 0 && stopDate.First() != "")
                {
                    end = Convert.ToDateTime(stopDate.First());
                }
                else
                {
                    string unit             = "";
                    int    unitConverToDays = 0;
                    int    num = 0;

                    //单位
                    List <string> stopUnit = XmlParseHelper.GetNodeList("PlayTime", "StopDate", "unit");

                    //数量
                    List <string> stopNum = XmlParseHelper.GetNodeList("PlayTime", "StopDate", "num");

                    if (stopUnit != null && stopUnit.Count > 0)
                    {
                        unit = stopUnit.First();
                    }

                    if (stopNum != null && stopNum.Count > 0)
                    {
                        num = Convert.ToInt32(stopNum.First());
                    }
                    switch (unit)
                    {
                    case "week":
                        unitConverToDays = 7;
                        break;

                    case "day":
                        unitConverToDays = 1;
                        break;

                    case "year":
                        unitConverToDays = 365;
                        break;

                    case "month":
                        unitConverToDays = 30;
                        break;

                    default:
                        unitConverToDays = 0;
                        break;
                    }

                    int sumDays = num * unitConverToDays;
                    end = start.AddDays(sumDays);
                }

                DateTime now = DateTime.Now;

                //开始时间未到 strat>now 截止日期已过 now>end     start<=now<=end

                //小于开始时间 开始时间大于现在的时间,过期
                if (DateTime.Compare(start, now) > 0)
                {
                    isOverDue = true;
                }
                else
                {
                    //大于开始时间,如果还大于了截止日期 也是过期
                    if (DateTime.Compare(end, now) <= 0)
                    {
                        isOverDue = true;
                    }
                }

                return(isOverDue);
            }
            catch (Exception ex)
            {
                WriteLog.WriteErrorLogToFile(string.Format("判断播放语音是否已到截止日期错误-错误信息:{0},{1}", ex.Message.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), true);
                throw ex;
            }
        }
예제 #15
0
 internal static void RegisterAttributes()
 {
     XmlParseHelper.RegisterAttribute("LockSetting", CheckFieldLocked);
     XmlParseHelper.RegisterAttribute("DisableSettings", CheckDisabledSettings);
 }
예제 #16
0
        public DetailedReport GetDetailedReport(string buildId)
        {
            var xml = _wrapper.GetDetailedResults(buildId);

            return(XmlParseHelper.Parse <DetailedReport>(xml));
        }