Esempio n. 1
0
        public List <ScanObject> getScanbyId(resultClass token, string projectId)
        {
            List <ScanObject> sclass = new List <ScanObject>();
            string            path   = String.Empty;

            try
            {
                get    httpGet      = new get();
                secure token_secure = new secure(token);
                token_secure.findToken(token);
                path = token_secure.get_rest_Uri(String.Format(CxConstant.CxProjectScan, projectId));
                if (token.debug && token.verbosity > 1)
                {
                    Console.WriteLine("API: {0}", path);
                }
                httpGet.get_Http(token, path, 10);
                if (token.status == 0)
                {
                    sclass = JsonConvert.DeserializeObject <List <ScanObject> >(token.op_result);
                }
                else
                {
                    throw new MissingFieldException("Failure to get scan results. Please check token validity and try again");
                }
            }
            catch (Exception ex)
            {
                if (token.debug && token.verbosity > 0)
                {
                    Console.Error.WriteLine("getScan: {0}, Message: {1} Trace: {2}", path, ex.Message, ex.StackTrace);
                }
            }
            return(sclass);
        }
Esempio n. 2
0
 public bool GetResultStatus(long report_id, resultClass token)
 {
     try
     {
         get    httpGet      = new get();
         secure token_secure = new secure(token);
         token_secure.findToken(token);
         string path = token_secure.get_rest_Uri(String.Format(CxConstant.CxReportStatus, report_id));
         httpGet.get_Http(token, path);
         if (token.status == 0)
         {
             ReportReady ready = JsonConvert.DeserializeObject <ReportReady>(token.op_result);
             if (ready.Status.Id == 2)
             {
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         token.status        = -1;
         token.statusMessage = ex.Message;
     }
     return(false);
 }
Esempio n. 3
0
        public ScanStatistics getScansStatistics(long scanId, resultClass token)
        {
            ScanStatistics scanStatistics = new ScanStatistics();
            string         path           = String.Empty;

            try
            {
                get    httpGet      = new get();
                secure token_secure = new secure(token);
                token_secure.findToken(token);
                path = token_secure.get_rest_Uri(String.Format(CxConstant.CxScanStatistics, scanId));
                if (token.debug && token.verbosity > 1)
                {
                    Console.WriteLine("API: {0}", path);
                }


                httpGet.get_Http(token, path);
                if (token.status == 0)
                {
                    scanStatistics = JsonConvert.DeserializeObject <ScanStatistics>(token.op_result);
                }
            }
            catch (Exception ex)
            {
                if (token.debug && token.verbosity > 0)
                {
                    Console.Error.WriteLine("getScansStatistics: {0}, Message: {1} Trace: {2}", path, ex.Message, ex.StackTrace);
                }
            }
            return(scanStatistics);
        }
Esempio n. 4
0
        public bool GetResultStatus(long report_id, resultClass token)
        {
            string path = String.Empty;

            try
            {
                get    httpGet      = new get();
                secure token_secure = new secure(token);
                token_secure.findToken(token);
                path = token_secure.get_rest_Uri(String.Format(CxConstant.CxReportStatus, report_id));
                if (token.debug && token.verbosity > 1)
                {
                    Console.WriteLine("API: {0}", path);
                }
                httpGet.get_Http(token, path);
                if (token.status == 0)
                {
                    ReportReady ready = JsonConvert.DeserializeObject <ReportReady>(token.op_result);
                    if (ready.Status.Id == 2)
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                token.status        = -1;
                token.statusMessage = ex.Message;
                if (token.debug && token.verbosity > 0)
                {
                    Console.Error.WriteLine("GetResultStatus: {0}, Message: {1} Trace: {2}", path, ex.Message, ex.StackTrace);
                }
            }
            return(false);
        }
Esempio n. 5
0
        public byte[] GetGenaricResult(long report_id, resultClass token)
        {
            string path = String.Empty;

            try
            {
                get httpGet = new get();

                secure token_secure = new secure(token);
                token_secure.findToken(token);
                path = token_secure.get_rest_Uri(String.Format(CxConstant.CxReportFetch, report_id));
                if (token.debug && token.verbosity > 1)
                {
                    Console.WriteLine("API: {0}", path);
                }
                httpGet.get_Http(token, path);
                if (token.status == 0)
                {
                    return(token.byte_result);
                }
            }
            catch (Exception ex)
            {
                token.status        = -1;
                token.statusMessage = ex.Message;
                if (token.debug && token.verbosity > 0)
                {
                    Console.Error.WriteLine("GetGenaricResult: {0}, Message: {1} Trace: {2}", path, ex.Message, ex.StackTrace);
                }
            }
            return(null);
        }
Esempio n. 6
0
        public ScanStatistics getScansStatistics(long scanId, resultClass token)
        {
            get            httpGet        = new get();
            ScanStatistics scanStatistics = new ScanStatistics();
            secure         token_secure   = new secure(token);

            token_secure.findToken(token);
            string path = token_secure.get_rest_Uri(String.Format(CxConstant.CxScanStatistics, scanId));

            httpGet.get_Http(token, path);
            if (token.status == 0)
            {
                scanStatistics = JsonConvert.DeserializeObject <ScanStatistics>(token.op_result);
            }
            return(scanStatistics);
        }
Esempio n. 7
0
        public List <ScanObject> getScan(resultClass token)
        {
            get httpGet = new get();
            List <ScanObject> sclass       = new List <ScanObject>();
            secure            token_secure = new secure(token);

            token_secure.findToken(token);
            string path = token_secure.get_rest_Uri(CxConstant.CxScans);

            httpGet.get_Http(token, path);
            if (token.status == 0)
            {
                sclass = JsonConvert.DeserializeObject <List <ScanObject> >(token.op_result);
            }
            return(sclass);
        }
Esempio n. 8
0
        public List <ScanObject> getScan(resultClass token)
        {
            get httpGet = new get();
            List <ScanObject> sclass       = new List <ScanObject>();
            secure            token_secure = new secure(token);

            token_secure.findToken(token);
            string path = token_secure.get_rest_Uri(CxConstant.CxScans);

            httpGet.get_Http(token, path);
            if (token.status == 0)
            {
                sclass = JsonConvert.DeserializeObject <List <ScanObject> >(token.op_result);
            }
            else
            {
                throw new MissingFieldException("Failure to get scan results. Please check token validity and try again");
            }
            return(sclass);
        }
Esempio n. 9
0
        public List <Presets> get_presets(resultClass token)
        {
            get            httpGet = new get();
            List <Presets> pclass  = new List <Presets>();

            secure token_secure = new secure(token);

            token_secure.findToken(token);
            string path = token_secure.get_rest_Uri(CxConstant.CxPresets);

            if (token.debug && token.verbosity > 1)
            {
                Console.WriteLine("API: {0}", path);
            }
            httpGet.get_Http(token, path);
            if (token.status == 0)
            {
                pclass = JsonConvert.DeserializeObject <List <Presets> >(token.op_result);
            }
            return(pclass);
        }
Esempio n. 10
0
        public XElement GetResult(long report_id, resultClass token)
        {
            try
            {
                get httpGet = new get();

                secure token_secure = new secure(token);
                token_secure.findToken(token);
                string path = token_secure.get_rest_Uri(String.Format(CxConstant.CxReportFetch, report_id));
                httpGet.get_Http(token, path);
                if (token.status == 0)
                {
                    string   result = token.op_result;
                    XElement xl     = XElement.Parse(result);
                    return(xl);
                }
            }
            catch (Exception ex)
            {
                token.status        = -1;
                token.statusMessage = ex.Message;
            }
            return(null);
        }