Beispiel #1
0
        private static void TestImportParser(ITrafficParser parser, TempFile log, ParsingOptions profile)
        {
            TrafficViewerFile tvFile = new TrafficViewerFile();

            tvFile.StartImport(parser, log.Path, profile);
            ValidateASEFile(tvFile);
        }
Beispiel #2
0
        private static TrafficViewerFile MakeDummyTrafficFile()
        {
            TrafficViewerFile tvf    = new TrafficViewerFile();
            TempFile          log    = MakeDummyASETrafficLog();
            ITrafficParser    parser = new DefaultTrafficParser();

            tvf.StartImport(parser, log.Path, ParsingOptions.GetDefaultProfile());
            return(tvf);
        }
Beispiel #3
0
        private void Import(object param)
        {
            ImportInfo info = param as ImportInfo;

            if (info.TargetFiles != null && info.TargetFiles.Count > 0)
            {
                foreach (string path in info.TargetFiles)
                {
                    try
                    {
                        _trafficViewerFile.StartImport(info.Parser, path, info.Profile);
                    }
                    catch (Exception ex)
                    {
                        string error = String.Format(Resources.ImportException, path, info.Parser.Name);
                        SdkSettings.Instance.Logger.Log(TraceLevel.Error, "{0} exception thrown: {1}", error, ex.Message);
                        _trafficViewerFile.StopImport();
                        if (_exceptionMessageHandler != null)
                        {
                            _exceptionMessageHandler.Show(error);
                        }
                    }
                }
            }
            else if (info.Sender != null)
            {
                try
                {
                    _trafficViewerFile.StartImport(info.Parser, info.Sender, info.Profile);
                }
                catch (Exception ex)
                {
                    string error = String.Format(Resources.ImportException, info.Sender.ToString(), info.Parser.Name);
                    SdkSettings.Instance.Logger.Log(TraceLevel.Error, "{0}, exception thrown: {1}", error, ex.Message);
                    _trafficViewerFile.StopImport();
                    if (_exceptionMessageHandler != null)
                    {
                        _exceptionMessageHandler.Show(error);
                    }
                }
            }
        }
Beispiel #4
0
        public void ExportAppscanToEXD()
        {
            ParsingOptions options = ParsingOptions.GetLegacyAppScanProfile();

            ITrafficParser parser = new DefaultTrafficParser();

            //test appscan import
            TrafficViewerFile tvFile = new TrafficViewerFile();
            TempFile          log    = new TempFile();

            log.Write(Properties.Resources.AppScanMETraffic);

            tvFile.StartImport(parser, log.Path, options);

            Assert.AreEqual(8, tvFile.RequestCount);

            ITrafficExporter exdExporter = new ManualExploreExporter();

            TempFile temp = new TempFile();

            Stream stream = temp.OpenStream();

            exdExporter.Export(tvFile, stream, "newHost.com", 8080);

            Assert.IsTrue(stream.Length > 0);

            stream.Flush();

            stream.Position = 0;

            XmlDocument doc = new XmlDocument();

            doc.XmlResolver = null;
            doc.Load(stream);

            int noOfRequests = doc.SelectNodes("//request").Count;

            Assert.AreEqual(8, noOfRequests);

            //check that the post request is properly formed
            XmlNode postRequest = doc.SelectSingleNode("//request[@method='POST']");

            Assert.AreEqual(3, postRequest.SelectNodes("parameter").Count);
            Assert.AreEqual(2, postRequest.SelectNodes("cookie").Count);
            Assert.AreEqual(11, postRequest.SelectNodes("header").Count);

            stream.Close();
        }
Beispiel #5
0
        public void ImportAppscan()
        {
            ParsingOptions options = ParsingOptions.GetLegacyAppScanProfile();

            ITrafficParser parser = new DefaultTrafficParser();

            //test appscan import
            TrafficViewerFile tvFile = new TrafficViewerFile();
            TempFile          log    = new TempFile();

            log.Write(Properties.Resources.AppScanMETraffic);

            tvFile.StartImport(parser, log.Path, options);

            Assert.AreEqual(8, tvFile.RequestCount);

            string response = Encoding.UTF8.GetString(tvFile.LoadResponseData(3));

            Assert.IsTrue(response.Contains("ONLINE BANKING LOGIN"));
        }