コード例 #1
0
 internal JobDetails(string appHash, string label, string package, string platform,
                     int?progressFinished, int?progressTotal, string riskGrade, int?riskScore, long?scanDuration,
                     Dictionary <string, string> scanErrors, Guid?scanID, string status, string submitter,
                     ThreatCounts threatCounts, List <ThreatLocation> threatLocations,
                     List <ThreatSummary> threatSummaries, DateTime?scanStart, DateTime?scanFinish, DateTime?upload,
                     Guid?uuid, string version)
 {
     AppHash          = appHash;
     Label            = label;
     Package          = package;
     Platform         = platform;
     ProgressFinished = progressFinished;
     ProgressTotal    = progressTotal;
     RiskGrade        = riskGrade;
     RiskScore        = riskScore;
     ScanDuration     = scanDuration;
     ScanErrors       = scanErrors;
     ScanID           = scanID;
     Status           = status;
     Submitter        = submitter;
     ThreatCounts     = threatCounts;
     ThreatLocations  = threatLocations;
     ThreatSummaries  = threatSummaries;
     ScanStart        = scanStart;
     ScanFinish       = scanFinish;
     Upload           = upload;
     Uuid             = uuid;
     Version          = version;
 }
コード例 #2
0
        internal static List <JobResult> ParseJobResults(string json)
        {
            List <JobResult> result = new List <JobResult>();

            JArray jobs = JArray.Parse(json);

            foreach (var item in jobs)
            {
                var threatCounts = new ThreatCounts(
                    item["threat_counts"] != null
                            ? item["threat_counts"]["low"].SafeValue <int?>()
                            : null,
                    item["threat_counts"] != null
                            ? item["threat_counts"]["medium"].SafeValue <int?>()
                            : null,
                    item["threat_counts"] != null
                            ? item["threat_counts"]["high"].SafeValue <int?>()
                            : null
                    );

                var jobResult = new JobResult(
                    item["app_hash"].SafeValue <string>(),
                    item["label"].SafeValue <string>(),
                    item["package"].SafeValue <string>(),
                    item["platform"].SafeValue <string>(),
                    item["progress_finished"].SafeValue <int?>(),
                    item["progress_total"].SafeValue <int?>(),
                    item["risk_grade"].SafeValue <string>(),
                    item["risk_score"].SafeValue <int?>(),
                    item["scan_id"].SafeValue <string>() == null ? null : (Guid?)Guid.Parse(item["scan_id"].SafeValue <string>()),
                    item["status"].SafeValue <string>(),
                    item["submitter"].SafeValue <string>(),
                    threatCounts,
                    item["timestamp_scan_start"].SafeValue <long?>().ToUnixDateTime(),
                    item["timestamp_scan_finish"].SafeValue <long?>().ToUnixDateTime(),
                    item["timestamp_upload"].SafeValue <long?>().ToUnixDateTime(),
                    item["uuid"].SafeValue <string>() == null ? null : (Guid?)Guid.Parse(item["uuid"].SafeValue <string>()),
                    item["version"].SafeValue <string>()
                    );

                result.Add(jobResult);
            }

            return(result);
        }
コード例 #3
0
ファイル: JobResult.cs プロジェクト: App-Ray/dot-net-sdk
 internal JobResult(string appHash, string label, string package, string platform,
                    int?progressFinished, int?progressTotal, string riskGrade, int?riskScore,
                    Guid?scanID, string status, string submitter, ThreatCounts threatCounts,
                    DateTime?scanStart, DateTime?scanFinish, DateTime?upload, Guid?uuid,
                    string version)
 {
     AppHash          = appHash;
     Label            = label;
     Package          = package;
     Platform         = platform;
     ProgressFinished = progressFinished;
     ProgressTotal    = progressTotal;
     RiskGrade        = riskGrade;
     RiskScore        = riskScore;
     ScanID           = scanID;
     Status           = status;
     Submitter        = submitter;
     ThreatCounts     = threatCounts;
     ScanStart        = scanStart;
     ScanFinish       = scanFinish;
     Upload           = upload;
     Uuid             = uuid;
     Version          = version;
 }
コード例 #4
0
        internal static JobDetails ParseJobDetails(string json)
        {
            JobDetails result;

            JObject job = JObject.Parse(json);

            var threatCounts = new ThreatCounts(
                job["threat_counts"] != null
                            ? job["threat_counts"]["low"].SafeValue <int?>()
                            : null,
                job["threat_counts"] != null
                            ? job["threat_counts"]["medium"].SafeValue <int?>()
                            : null,
                job["threat_counts"] != null
                            ? job["threat_counts"]["high"].SafeValue <int?>()
                            : null
                );

            List <ThreatLocation> threatLocations = new List <ThreatLocation>();
            List <ThreatSummary>  threatSummaries = new List <ThreatSummary>();

            foreach (var item in job["threat_locations"].Value <JObject>())
            {
                List <string> locations = new List <string>();

                foreach (var location in item.Value)
                {
                    locations.Add(location.Value <string>());
                }

                threatLocations.Add(new ThreatLocation(item.Key, locations));
            }

            foreach (var item in job["threat_summaries"])
            {
                threatSummaries.Add(new ThreatSummary(
                                        item["id"].SafeValue <string>(),
                                        item["description"].SafeValue <string>(),
                                        item["explanation"].SafeValue <string>()
                                        ));
            }

            var scanErrors = new Dictionary <string, string>();

            foreach (var item in job["scan_errors"].Value <JObject>())
            {
                var key   = item.Key;
                var value = item.Value.SafeValue <string>();

                scanErrors.Add(key, value);
            }

            result = new JobDetails(
                job["app_hash"].SafeValue <string>(),
                job["label"].SafeValue <string>(),
                job["package"].SafeValue <string>(),
                job["platform"].SafeValue <string>(),
                job["progress_finished"].SafeValue <int?>(),
                job["progress_total"].SafeValue <int?>(),
                job["risk_grade"].SafeValue <string>(),
                job["risk_score"].SafeValue <int?>(),
                job["scan_duration"].SafeValue <long?>(),
                scanErrors,
                job["scan_id"].SafeValue <string>() == null ? null : (Guid?)Guid.Parse(job["scan_id"].SafeValue <string>()),
                job["status"].SafeValue <string>(),
                job["submitter"].SafeValue <string>(),
                threatCounts,
                threatLocations,
                threatSummaries,
                job["timestamp_scan_start"].SafeValue <long?>().ToUnixDateTime(),
                job["timestamp_scan_finish"].SafeValue <long?>().ToUnixDateTime(),
                job["timestamp_upload"].SafeValue <long?>().ToUnixDateTime(),
                job["uuid"].SafeValue <string>() == null ? null : (Guid?)Guid.Parse(job["uuid"].SafeValue <string>()),
                job["version"].SafeValue <string>());

            return(result);
        }