示例#1
0
        public static void CleanUpAndGenerateReport()
        {
            _zapClient.Dispose();

            var reportFilename = $"{DateTime.Now.ToString("dd-MMM-yyyy-hh-mm-ss")}_OWASP_ZAP_Report";

            GenerateXmlReport(reportFilename);
            GenerateHTMLReport(reportFilename);
            GenerateMarkdownReport(reportFilename);
        }
示例#2
0
        public static void RyddeOppOgGenerereRapport()
        {
            _zapClient.Dispose();

            var reportFilename = $"{DateTime.Now:dd-MMM-yyyy-hh-mm-ss}_OWASP_ZAP_Report";

            GenerereXmlRapport(reportFilename);
            GenerereHtmlRapport(reportFilename);
            GenerereMarkdownRapport(reportFilename);
        }
示例#3
0
        public void Dispose()
        {
            var report         = new GenerateReports(_zapApiKey, _zapClient);
            var reportFilename = $"{DateTime.Now.ToString("dd-MMM-yyyy-hh-mm-ss")}_OWASP_ZAP_Report";

            report.GenerateXmlReport(reportFilename);
            report.GenerateHTMLReport(reportFilename);
            report.GenerateMarkdownReport(reportFilename);
            _zapClient.Dispose();
        }
示例#4
0
        public void BExecuteActiveScan()
        {
            if (Convert.ToBoolean(ConfigurationManager.AppSettings.Get("ShouldRunSpiderAndScan").ToLower()))
            {
                var activeScanId = StartActiveScan();
                CheckActiveScanProgress(activeScanId);
                var reportFilename = $"{DateTime.Now:dd.MM.yy-hh.mm.ss}-ZAP_Report";
                SaveSession(reportFilename);
                zapClient.Dispose();

                GenerateReport(reportFilename, ReportFileExtention.Html);
            }
        }
示例#5
0
        public void SecondRunActiveScan()
        {
            if (Convert.ToBoolean(ConfigurationManager.AppSettings.Get("RunZAPScans").ToLower()))
            {
                var activeScanId = StartActiveScan();
                CheckActiveScanProgress(activeScanId);
                var reportFilename = $"{DateTime.Now:dd.MM.yy-hh.mm.ss}-ZAP_Report";
                SaveSession(reportFilename);
                zap.Dispose();

                GenerateScanReport(reportFilename, ReportFileExtention.Html);
                StopProc();
            }
        }
 public static void TearDown()
 {
     try
     {
         TakeScreenshotOnFailure();
     }
     finally
     {
         if (zapTest == true)
         {
             Zap.Dispose();
         }
         webDriver.Quit();
         extent.Flush();
     }
 }
示例#7
0
 public void DisposeClientApi()
 {
     zap.Dispose();
 }
示例#8
0
        private void EstablishConnection(bool tagged)
        {
            // If we're switching contexts from tagged to un-tagged,
            // then we need to reset the connection
            if ((m_ClientApi != null) && tagged != _tagged)
            {
                CloseConnection();
            }
            if (m_ClientApi == null)
            {
                m_ClientApi = new ClientApi();
            }
            if (m_ClientApi.Dropped() != 0)
            {
                // I can't figure out how to force this artificially, so currently untested :-(
                CloseConnection();
            }
            if (!_Initialized)
            {
                Error err = null;
                try
                {
                    _tagged = tagged;
                    err     = m_ClientApi.CreateError();
                    if (tagged)
                    {
                        m_ClientApi.SetProtocol("tag", "");
                    }
                    if (tagged)
                    {
                        m_ClientApi.SetProtocol("specstring", "");
                    }

                    //May have lost our settings... reset here
                    if (_Client != null)
                    {
                        m_ClientApi.SetClient(_Client);
                    }
                    if (_User != null)
                    {
                        m_ClientApi.SetUser(_User);
                    }
                    if (_CWD != null)
                    {
                        m_ClientApi.SetCwd(_CWD);
                    }
                    if (_Charset != null)
                    {
                        m_ClientApi.SetCharset(_Charset);
                    }
                    if (_Host != null)
                    {
                        m_ClientApi.SetHost(_Host);
                    }
                    if (_Port != null)
                    {
                        m_ClientApi.SetPort(_Port);
                    }
                    if (_maxResults != 0)
                    {
                        m_ClientApi.SetMaxResults(_maxResults);
                    }
                    if (_maxScanRows != 0)
                    {
                        m_ClientApi.SetMaxScanRows(_maxResults);
                    }
                    if (_maxLockTime != 0)
                    {
                        m_ClientApi.SetMaxLockTime(_maxLockTime);
                    }
                    if (_ApiLevel != 0)
                    {
                        m_ClientApi.SetProtocol("api", _ApiLevel.ToString());
                    }

                    m_ClientApi.Init(err);
                    if (err.Severity == Error.ErrorSeverity.Failed || err.Severity == Error.ErrorSeverity.Fatal)
                    {
                        //Trace.WriteLine(err.Fmt());
                        //Trace.WriteLine("Unable to connect to Perforce!");
                        throw new Exception("Unable to connect to Perforce!");
                    }

                    if (_CallingProgram != null)
                    {
                        m_ClientApi.SetProg(_CallingProgram);
                    }
                    if (_CallingProgramVersion != null)
                    {
                        m_ClientApi.SetVersion(_CallingProgramVersion);
                    }

                    _Initialized = true;
                    err.Dispose();
                }
                catch (Exception e)
                {
                    //Trace.WriteLine(e.Message);
                    m_ClientApi.Final(err);
                    err.Dispose();
                    m_ClientApi.Dispose();
                    m_ClientApi = null;
                    throw new PerforceInitializationError(e.Message);
                }
            }
        }
示例#9
0
        private void EstablishConnection(bool tagged, KeepAlive keepAlive)
        {
            if (m_ClientApi != null && m_ClientApi.Dropped() != 0)
            {
                // I can't figure out how to force this artificially, so currently untested :-(
                CloseConnection();
            }
            if (m_ClientApi == null)
            {
                m_ClientApi = new ClientApi();
            }
            if (!_Initialized)
            {
                Error err = null;
                try
                {
                    _tagged = tagged;
                    err     = m_ClientApi.CreateError();

                    // Always use the specstring protocol.  We'll controll form output via SetTag
                    // before each run
                    m_ClientApi.SetProtocol("specstring", "");

                    //May have lost our settings... reset here
                    if (_Client != null)
                    {
                        m_ClientApi.SetClient(_Client);
                    }
                    if (_User != null)
                    {
                        m_ClientApi.SetUser(_User);
                    }
                    if (_CWD != null)
                    {
                        m_ClientApi.SetCwd(_CWD);
                    }
                    if (_Charset != null)
                    {
                        m_ClientApi.SetCharset(_Charset);
                    }
                    if (_Host != null)
                    {
                        m_ClientApi.SetHost(_Host);
                    }
                    if (_Port != null)
                    {
                        m_ClientApi.SetPort(_Port);
                    }
                    if (_Password != null)
                    {
                        m_ClientApi.SetPassword(_Password);
                    }
                    if (_TicketFile != null)
                    {
                        m_ClientApi.SetTicketFile(_TicketFile);
                    }
                    if (_maxResults != 0)
                    {
                        m_ClientApi.SetMaxResults(_maxResults);
                    }
                    if (_maxScanRows != 0)
                    {
                        m_ClientApi.SetMaxScanRows(_maxResults);
                    }
                    if (_maxLockTime != 0)
                    {
                        m_ClientApi.SetMaxLockTime(_maxLockTime);
                    }
                    if (_ApiLevel != 0)
                    {
                        m_ClientApi.SetProtocol("api", _ApiLevel.ToString());
                    }

                    m_ClientApi.Init(err);
                    if (err.Severity == Error.ErrorSeverity.Failed || err.Severity == Error.ErrorSeverity.Fatal)
                    {
                        throw new Exception("Unable to connect to Perforce!");
                    }
                    _Initialized = true;
                    err.Dispose();
                }
                catch (Exception e)
                {
                    string message = "Perforce connection error.";
                    try
                    {
                        m_ClientApi.Final(err);
                        message = e.Message;
                        err.Dispose();
                        m_ClientApi.Dispose();
                        m_ClientApi = null;
                    }
                    catch { }
                    throw new PerforceInitializationError(message);
                }
            }
            if (tagged)
            {
                m_ClientApi.SetTag();
            }
            if (_CallingProgram != null)
            {
                m_ClientApi.SetProg(_CallingProgram);
            }
            if (_CallingProgramVersion != null)
            {
                m_ClientApi.SetVersion(_CallingProgramVersion);
            }
            m_ClientApi.SetBreak(keepAlive);
        }