void DoAnalysis() { try { BehaviourAnalysis BA = new BehaviourAnalysis(ScanTraceBehaviourAnalysis.DefaultErrorKeywords, ScanTraceBehaviourAnalysis.DefaultResponseTimeChange, ScanTraceBehaviourAnalysis.DefaultResponseTimeChangeFactor, ScanTraceBehaviourAnalysis.DefaultCharsCount); BA.Analyze(this.Trace.OverviewXml, this.Trace.Section); ScanTraceBehaviourAnalysisResultsUiInformation UiReslts = ScanTraceBehaviourAnalysis.GetUiDisplayResults(BA.ResultsXml, BA.BaseLineSession.Response.Code.ToString(), BA.BaseLineRoundtripTime.ToString()); SetAnalysisUiResults(UiReslts); } catch (Exception Exp) { IronException.Report("Error calculating Payload Effect Analysis", Exp); SetAnalysisUiResults(new ScanTraceBehaviourAnalysisResultsUiInformation()); } }
internal LogTraceViewer(int TraceId, ScanTraceBehaviourAnalysisResultsUiInformation UiResults) { this.TraceId = TraceId; this.UiResults = UiResults; InitializeComponent(); }
void SetAnalysisUiResults(ScanTraceBehaviourAnalysisResultsUiInformation UiResults) { if (this.PayloadEffectTabs.InvokeRequired) { SetAnalysisUiResults_d CALL_d = new SetAnalysisUiResults_d(SetAnalysisUiResults); this.PayloadEffectTabs.Invoke(CALL_d, new object[] { UiResults }); } else { StringBuilder SB = new StringBuilder(@"{\rtf1{\colortbl ;\red0\green77\blue187;\red247\green150\blue70;\red255\green0\blue0;\red0\green200\blue50;\red255\green255\blue255;}"); SB.Append(Tools.RtfSafe(UiResults.SummaryText)); this.SummaryRTB.Rtf = SB.ToString(); if (UiResults.CodeGridRows.Count > 0) { this.PayloadEffectTabs.TabPages["CodeTab"].Text = " Code Variation "; foreach (object[] Row in UiResults.CodeGridRows) { this.CodeGrid.Rows.Add(Row); } } else { this.PayloadEffectTabs.TabPages["CodeTab"].Text = " - "; } if (UiResults.TimeGridRows.Count > 0) { this.PayloadEffectTabs.TabPages["TimeTab"].Text = " Time Variation "; foreach (object[] Row in UiResults.TimeGridRows) { this.RoundtripGrid.Rows.Add(Row); } } else { this.PayloadEffectTabs.TabPages["TimeTab"].Text = " - "; } if (UiResults.KeywordGridRows.Count > 0) { this.PayloadEffectTabs.TabPages["KeywordsTab"].Text = " Keywords Inserted "; foreach (object[] Row in UiResults.KeywordGridRows) { this.KeywordsGrid.Rows.Add(Row); } } else { this.PayloadEffectTabs.TabPages["KeywordsTab"].Text = " - "; } if (UiResults.BodyGridRows.Count > 0) { this.PayloadEffectTabs.TabPages["BodyTab"].Text = " Body Variation "; foreach (object[] Row in UiResults.BodyGridRows) { this.BodyGrid.Rows.Add(Row); } } else { this.PayloadEffectTabs.TabPages["BodyTab"].Text = " - "; } if (UiResults.SetCookieGridRows.Count > 0) { this.PayloadEffectTabs.TabPages["SetCookieTab"].Text = " Set-Cookie Variations "; foreach (object[] Row in UiResults.SetCookieGridRows) { this.SetCookieGrid.Rows.Add(Row); } } else { this.PayloadEffectTabs.TabPages["SetCookieTab"].Text = " - "; } if (UiResults.HeadersGridRows.Count > 0) { this.PayloadEffectTabs.TabPages["HeadersTab"].Text = " Headers Variation "; foreach (object[] Row in UiResults.HeadersGridRows) { this.HeadersGrid.Rows.Add(Row); } } else { this.PayloadEffectTabs.TabPages["HeadersTab"].Text = " - "; } this.AnalysisProgressBar.Visible = false; this.PayloadEffectTabs.Visible = true; } }
internal static ScanTraceBehaviourAnalysisResultsUiInformation GetUiDisplayResults(string ResultsXml, string BaselineCode, string BaselineRoundtrip) { List <BehaviourAnalysisResult> Results = BehaviourAnalysisResult.ToObjectList(ResultsXml); List <int> Codes = new List <int>(); List <string> Keywords = new List <string>(); List <string> Roundtrips = new List <string>(); List <int> InsertedChars = new List <int>(); List <string> SetCookies = new List <string>(); List <string> Headers = new List <string>(); List <object[]> CodeGridRows = new List <object[]>(); List <object[]> KeywordGridRows = new List <object[]>(); List <object[]> SetCookieGridRows = new List <object[]>(); List <object[]> HeadersGridRows = new List <object[]>(); List <object[]> BodyGridRows = new List <object[]>(); List <object[]> TimeGridRows = new List <object[]>(); Dictionary <string, string> HeaderVariationMessage = new Dictionary <string, string>() { { "+", "Header added, this header was missing in baseline response" }, { "-", "Missing header, this header was present in baseline response" }, { ">", "Value added, this header had an empty value in baseline" }, { "<", "Empty value, this header had a non-empty value in baseline" } }; Dictionary <string, string> SetCookieVariationMessage = new Dictionary <string, string>() { { "+", "Cookie added, this cookie was missing in baseline response" }, { "-", "Missing cookie, this cookie was present in baseline response" }, { ">", "Value added, this cookie had an empty value in baseline" }, { "<", "Empty value, this cookie had a non-empty value in baseline" } }; Dictionary <string, string> HeaderVariationMessageForSummary = new Dictionary <string, string>() { { "+", "header added, this header was missing in baseline response" }, { "-", "header is missing, this header was present in baseline response" }, { ">", "header's value added, this header had an empty value in baseline" }, { "<", "header's value is empty, this header had a non-empty value in baseline" } }; Dictionary <string, string> SetCookieVariationMessageForSummary = new Dictionary <string, string>() { { "+", "cookie added, this cookie was missing in baseline response" }, { "-", "cookie is missing, this cookie was present in baseline response" }, { ">", "cookie's value added, this cookie had an empty value in baseline" }, { "<", "cookie's value is empty, this cookie had a non-empty value in baseline" } }; foreach (BehaviourAnalysisResult Result in Results) { if (Result.ResponseCodeResult > 0) { CodeGridRows.Add(new object[] { Result.LogId, Result.ResponseCodeResult, Result.Payload }); if (!Codes.Contains(Result.ResponseCodeResult)) { Codes.Add(Result.ResponseCodeResult); } } if (Result.ResponseContentResult > 0) { BodyGridRows.Add(new object[] { Result.LogId, Result.ResponseContentResult, Result.Payload }); if (!InsertedChars.Contains(Result.ResponseContentResult)) { InsertedChars.Add(Result.ResponseContentResult); } } if (Result.RoundtripTimeResult.Length > 0) { TimeGridRows.Add(new object[] { Result.LogId, Result.RoundtripTimeResult, Result.Payload }); if (Int32.Parse(Result.RoundtripTimeResult.Trim(new char[] { '+', '-', 'm', 's' })) > 0) { if (!Roundtrips.Contains(Result.RoundtripTimeResult)) { Roundtrips.Add(Result.RoundtripTimeResult); } } } if (Result.ResponseKeywordsResult.Count > 0) { KeywordGridRows.Add(new object[] { Result.LogId, string.Join(", ", Result.ResponseKeywordsResult.ToArray()), Result.Payload }); } foreach (string Keyword in Result.ResponseKeywordsResult) { if (!Keywords.Contains(Keyword)) { Keywords.Add(Keyword); } } if (Result.SetCookieHeaderResult.Count > 0) { foreach (string SetCook in Result.SetCookieHeaderResult) { SetCookieGridRows.Add(new object[] { Result.LogId, SetCook.Substring(1), SetCookieVariationMessage[SetCook[0].ToString()], Result.Payload }); } } foreach (string SC in Result.SetCookieHeaderResult) { if (!SetCookies.Contains(SC)) { SetCookies.Add(SC); } } if (Result.ResponseHeadersResult.Count > 0) { foreach (string HeaderRes in Result.ResponseHeadersResult) { HeadersGridRows.Add(new object[] { Result.LogId, HeaderRes.Substring(1), HeaderVariationMessage[HeaderRes[0].ToString()], Result.Payload }); } } foreach (string H in Result.ResponseHeadersResult) { if (!Headers.Contains(H)) { Headers.Add(H); } } } StringBuilder Summary = new StringBuilder(); if (Codes.Count > 0) { Summary.Append(string.Format("Response codes changed from the baseline value of <i<cg>><i<b>>{0}<i</b>><i</cg>> to ", BaselineCode)); for (int i = 0; i < Codes.Count; i++) { Summary.Append(string.Format("<i<cb>><i<b>>{0}<i</b>><i</cb>>", Codes[i])); if (i < Codes.Count - 1) { Summary.Append(", "); } } Summary.Append("<i<br>><i<br>>"); } if (Keywords.Count > 0) { Summary.Append("Occurance of the following keywords in the response: "); for (int i = 0; i < Keywords.Count; i++) { Summary.Append("<i<cr>><i<b>>"); Summary.Append(Keywords[i]); Summary.Append("<i</b>><i</cr>>"); if (i < Keywords.Count - 1) { Summary.Append(", "); } } Summary.Append("<i<br>><i<br>>"); } if (InsertedChars.Count > 0) { InsertedChars.Sort(); Summary.Append(string.Format("Up to <i<cb>><i<b>>{0}<i</b>><i</cb>> characters of new content found in some responses.", InsertedChars[0])); Summary.Append("<i<br>><i<br>>"); } if (SetCookies.Count > 0) { Summary.Append("Changes in Set-Cookie values:<i<br>>"); foreach (string SetCookie in SetCookies) { Summary.Append(" "); Summary.Append("<i<co>><i<b>>"); Summary.Append(SetCookie.Substring(1)); Summary.Append("<i</b>><i</co>> "); Summary.Append(SetCookieVariationMessageForSummary[SetCookie[0].ToString()]); Summary.Append("<i<br>>"); } Summary.Append("<i<br>>"); } if (Headers.Count > 0) { Summary.Append("Changes in Response Headers:<i<br>>"); foreach (string Header in Headers) { Summary.Append(" "); Summary.Append("<i<co>><i<b>>"); Summary.Append(Header.Substring(1)); Summary.Append("<i</b>><i</co>> "); Summary.Append(HeaderVariationMessageForSummary[Header[0].ToString()]); Summary.Append("<i<br>>"); } Summary.Append("<i<br>>"); } if (Roundtrips.Count > 0) { int BaselineRoundtripInt = Int32.Parse(BaselineRoundtrip); List <int> PlusRoundtripIntList = new List <int>(); List <int> MinusRoundtripIntList = new List <int>(); for (int i = 0; i < Roundtrips.Count; i++) { int RoundtripDiff = Int32.Parse(Roundtrips[i].Trim(new char[] { '+', '-', 'm', 's', ' ' })); if (Roundtrips[i][0] == '+') { PlusRoundtripIntList.Add(BaselineRoundtripInt + RoundtripDiff); } else { MinusRoundtripIntList.Add(BaselineRoundtripInt - RoundtripDiff); } } PlusRoundtripIntList.Sort(); MinusRoundtripIntList.Sort(); Summary.Append(string.Format("Variation in the response roundtrip time from baseline value {0} ms:<i<br>><i<br>>", BaselineRoundtripInt)); string BaselineTimeStr = string.Format("{0} ms (Normal)", BaselineRoundtripInt); string HighestTimeStr = ""; string LowestTimeStr = ""; double Factor = (double)BaselineRoundtripInt / 100.0; if (Factor == 0) { Factor = 1.0; //To avoid divide by 0 exception or multiply by 0 and get 0 } if (PlusRoundtripIntList.Count > 0) { HighestTimeStr = string.Format("{0} ms (Highest variation)", PlusRoundtripIntList[0]); if ((double)PlusRoundtripIntList[0] / Factor > 250.0) { Factor = (double)PlusRoundtripIntList[0] / 250.0; if (Factor == 0) { Factor = 1.0; } } else if ((double)PlusRoundtripIntList[0] / Factor < 100.0) { Factor = (double)PlusRoundtripIntList[0] / 100.0; if (Factor == 0) { Factor = 1.0; } } } if (MinusRoundtripIntList.Count > 0) { LowestTimeStr = string.Format("{0} ms (Lowest variation)", MinusRoundtripIntList[0]); } Summary.Append("<i<hlg>>"); Summary.Append(new String(' ', (int)Math.Round(((double)BaselineRoundtripInt / Factor)))); Summary.Append("<i</hlg>>"); Summary.Append(" "); Summary.Append(BaselineTimeStr); Summary.Append("<i<br>>"); if (HighestTimeStr.Length > 0) { Summary.Append("<i<hlb>>"); Summary.Append(new String(' ', (int)Math.Round(((double)PlusRoundtripIntList[0] / Factor)))); Summary.Append("<i</hlb>>"); Summary.Append(" "); Summary.Append(HighestTimeStr); Summary.Append("<i<br>>"); } if (LowestTimeStr.Length > 0) { Summary.Append("<i<hlo>>"); Summary.Append(new String(' ', (int)Math.Round(((double)MinusRoundtripIntList[0] / Factor)))); Summary.Append("<i</hlo>>"); Summary.Append(" "); Summary.Append(LowestTimeStr); Summary.Append("<i<br>>"); } Summary.Append("<i<br>>"); } ScanTraceBehaviourAnalysisResultsUiInformation UiResult = new ScanTraceBehaviourAnalysisResultsUiInformation(); string SummaryText = Summary.ToString(); if (Summary.Length == 0) { UiResult.SummaryText = "<i<h1>>No significant variations could be observed<i</h1>><i<br>><i<br>>"; } else { UiResult.SummaryText = string.Format("<i<h1>>Some payloads caused the following effects:<i</h1>><i<br>><i<br>>{0}", SummaryText); } UiResult.SummaryText = Summary.ToString(); UiResult.CodeGridRows = new List <object[]>(CodeGridRows); UiResult.KeywordGridRows = new List <object[]>(KeywordGridRows); UiResult.SetCookieGridRows = new List <object[]>(SetCookieGridRows); UiResult.HeadersGridRows = new List <object[]>(HeadersGridRows); UiResult.BodyGridRows = new List <object[]>(BodyGridRows); UiResult.TimeGridRows = new List <object[]>(TimeGridRows); return(UiResult); }
private void TraceGrid_SelectionChanged(object sender, EventArgs e) { if (TraceGrid.SelectedCells.Count < 1 || TraceGrid.SelectedCells[0].Value == null) { return; } SelectedTraceId = Int32.Parse(TraceGrid.SelectedRows[0].Cells["IDClmn"].Value.ToString()); LoadTraceViewerBtn.Enabled = true; ClearResultsTabs(); string BaselineLogId = TraceGrid.SelectedRows[0].Cells["BaselineLogIdClmn"].Value.ToString(); string BaselinePayload = TraceGrid.SelectedRows[0].Cells["BaselinePayloadClmn"].Value.ToString(); string ResultsXml = TraceGrid.SelectedRows[0].Cells["XmlClmn"].Value.ToString(); string BaselineCode = TraceGrid.SelectedRows[0].Cells["BaselineCodeClmn"].Value.ToString(); string BaselineRoundtrip = TraceGrid.SelectedRows[0].Cells["BaselineRoundtripClmn"].Value.ToString(); ScanTraceBehaviourAnalysisResultsUiInformation UiResults = GetUiDisplayResults(ResultsXml, BaselineCode, BaselineRoundtrip); this.CurrentUiResults = UiResults; StringBuilder SB = new StringBuilder(@"{\rtf1{\colortbl ;\red0\green77\blue187;\red247\green150\blue70;\red255\green0\blue0;\red0\green200\blue50;\red255\green255\blue255;}"); SB.Append(Tools.RtfSafe(UiResults.SummaryText)); SummaryRTB.Rtf = SB.ToString(); if (UiResults.CodeGridRows.Count > 0) { BottomTabs.TabPages["CodeTab"].Text = " Code Variation "; foreach (object[] Row in UiResults.CodeGridRows) { CodeGrid.Rows.Add(Row); } } else { BottomTabs.TabPages["CodeTab"].Text = " - "; } if (UiResults.TimeGridRows.Count > 0) { BottomTabs.TabPages["TimeTab"].Text = " Time Variation "; foreach (object[] Row in UiResults.TimeGridRows) { RoundtripGrid.Rows.Add(Row); } } else { BottomTabs.TabPages["TimeTab"].Text = " - "; } if (UiResults.KeywordGridRows.Count > 0) { BottomTabs.TabPages["KeywordsTab"].Text = " Keywords Inserted "; foreach (object[] Row in UiResults.KeywordGridRows) { KeywordsGrid.Rows.Add(Row); } } else { BottomTabs.TabPages["KeywordsTab"].Text = " - "; } if (UiResults.BodyGridRows.Count > 0) { BottomTabs.TabPages["BodyTab"].Text = " Body Variation "; foreach (object[] Row in UiResults.BodyGridRows) { BodyGrid.Rows.Add(Row); } } else { BottomTabs.TabPages["BodyTab"].Text = " - "; } if (UiResults.SetCookieGridRows.Count > 0) { BottomTabs.TabPages["SetCookieTab"].Text = " Set-Cookie Variations "; foreach (object[] Row in UiResults.SetCookieGridRows) { SetCookieGrid.Rows.Add(Row); } } else { BottomTabs.TabPages["SetCookieTab"].Text = " - "; } if (UiResults.HeadersGridRows.Count > 0) { BottomTabs.TabPages["HeadersTab"].Text = " Headers Variation "; foreach (object[] Row in UiResults.HeadersGridRows) { HeadersGrid.Rows.Add(Row); } HeadersGrid.Columns[1].SortMode = DataGridViewColumnSortMode.Programmatic; } else { BottomTabs.TabPages["HeadersTab"].Text = " - "; } }
internal static ScanTraceBehaviourAnalysisResultsUiInformation GetUiDisplayResults(string ResultsXml, string BaselineCode, string BaselineRoundtrip) { List<BehaviourAnalysisResult> Results = BehaviourAnalysisResult.ToObjectList(ResultsXml); List<int> Codes = new List<int>(); List<string> Keywords = new List<string>(); List<string> Roundtrips = new List<string>(); List<int> InsertedChars = new List<int>(); List<string> SetCookies = new List<string>(); List<string> Headers = new List<string>(); List<object[]> CodeGridRows = new List<object[]>(); List<object[]> KeywordGridRows = new List<object[]>(); List<object[]> SetCookieGridRows = new List<object[]>(); List<object[]> HeadersGridRows = new List<object[]>(); List<object[]> BodyGridRows = new List<object[]>(); List<object[]> TimeGridRows = new List<object[]>(); Dictionary<string, string> HeaderVariationMessage = new Dictionary<string, string>() { {"+", "Header added, this header was missing in baseline response"}, {"-", "Missing header, this header was present in baseline response"}, {">", "Value added, this header had an empty value in baseline"}, {"<", "Empty value, this header had a non-empty value in baseline"} }; Dictionary<string, string> SetCookieVariationMessage = new Dictionary<string, string>() { {"+", "Cookie added, this cookie was missing in baseline response"}, {"-", "Missing cookie, this cookie was present in baseline response"}, {">", "Value added, this cookie had an empty value in baseline"}, {"<", "Empty value, this cookie had a non-empty value in baseline"} }; Dictionary<string, string> HeaderVariationMessageForSummary = new Dictionary<string, string>() { {"+", "header added, this header was missing in baseline response"}, {"-", "header is missing, this header was present in baseline response"}, {">", "header's value added, this header had an empty value in baseline"}, {"<", "header's value is empty, this header had a non-empty value in baseline"} }; Dictionary<string, string> SetCookieVariationMessageForSummary = new Dictionary<string, string>() { {"+", "cookie added, this cookie was missing in baseline response"}, {"-", "cookie is missing, this cookie was present in baseline response"}, {">", "cookie's value added, this cookie had an empty value in baseline"}, {"<", "cookie's value is empty, this cookie had a non-empty value in baseline"} }; foreach (BehaviourAnalysisResult Result in Results) { if (Result.ResponseCodeResult > 0) { CodeGridRows.Add(new object[] { Result.LogId, Result.ResponseCodeResult, Result.Payload }); if (!Codes.Contains(Result.ResponseCodeResult)) Codes.Add(Result.ResponseCodeResult); } if (Result.ResponseContentResult > 0) { BodyGridRows.Add(new object[] { Result.LogId, Result.ResponseContentResult, Result.Payload }); if (!InsertedChars.Contains(Result.ResponseContentResult)) InsertedChars.Add(Result.ResponseContentResult); } if (Result.RoundtripTimeResult.Length > 0) { TimeGridRows.Add(new object[] { Result.LogId, Result.RoundtripTimeResult, Result.Payload }); if (Int32.Parse(Result.RoundtripTimeResult.Trim(new char[] { '+', '-', 'm', 's' })) > 0) { if (!Roundtrips.Contains(Result.RoundtripTimeResult)) Roundtrips.Add(Result.RoundtripTimeResult); } } if (Result.ResponseKeywordsResult.Count > 0) KeywordGridRows.Add(new object[] { Result.LogId, string.Join(", ", Result.ResponseKeywordsResult.ToArray()), Result.Payload }); foreach (string Keyword in Result.ResponseKeywordsResult) { if (!Keywords.Contains(Keyword)) Keywords.Add(Keyword); } if (Result.SetCookieHeaderResult.Count > 0) { foreach (string SetCook in Result.SetCookieHeaderResult) { SetCookieGridRows.Add(new object[] { Result.LogId, SetCook.Substring(1), SetCookieVariationMessage[SetCook[0].ToString()], Result.Payload }); } } foreach (string SC in Result.SetCookieHeaderResult) { if (!SetCookies.Contains(SC)) SetCookies.Add(SC); } if (Result.ResponseHeadersResult.Count > 0) { foreach (string HeaderRes in Result.ResponseHeadersResult) { HeadersGridRows.Add(new object[] { Result.LogId, HeaderRes.Substring(1), HeaderVariationMessage[HeaderRes[0].ToString()], Result.Payload }); } } foreach (string H in Result.ResponseHeadersResult) { if (!Headers.Contains(H)) Headers.Add(H); } } StringBuilder Summary = new StringBuilder(); if (Codes.Count > 0) { Summary.Append(string.Format("Response codes changed from the baseline value of <i<cg>><i<b>>{0}<i</b>><i</cg>> to ", BaselineCode)); for (int i = 0; i < Codes.Count; i++) { Summary.Append(string.Format("<i<cb>><i<b>>{0}<i</b>><i</cb>>", Codes[i])); if (i < Codes.Count - 1) Summary.Append(", "); } Summary.Append("<i<br>><i<br>>"); } if (Keywords.Count > 0) { Summary.Append("Occurance of the following keywords in the response: "); for (int i = 0; i < Keywords.Count; i++) { Summary.Append("<i<cr>><i<b>>"); Summary.Append(Keywords[i]); Summary.Append("<i</b>><i</cr>>"); if (i < Keywords.Count - 1) Summary.Append(", "); } Summary.Append("<i<br>><i<br>>"); } if (InsertedChars.Count > 0) { InsertedChars.Sort(); Summary.Append(string.Format("Up to <i<cb>><i<b>>{0}<i</b>><i</cb>> characters of new content found in some responses.", InsertedChars[0])); Summary.Append("<i<br>><i<br>>"); } if (SetCookies.Count > 0) { Summary.Append("Changes in Set-Cookie values:<i<br>>"); foreach (string SetCookie in SetCookies) { Summary.Append(" "); Summary.Append("<i<co>><i<b>>"); Summary.Append(SetCookie.Substring(1)); Summary.Append("<i</b>><i</co>> "); Summary.Append(SetCookieVariationMessageForSummary[SetCookie[0].ToString()]); Summary.Append("<i<br>>"); } Summary.Append("<i<br>>"); } if (Headers.Count > 0) { Summary.Append("Changes in Response Headers:<i<br>>"); foreach (string Header in Headers) { Summary.Append(" "); Summary.Append("<i<co>><i<b>>"); Summary.Append(Header.Substring(1)); Summary.Append("<i</b>><i</co>> "); Summary.Append(HeaderVariationMessageForSummary[Header[0].ToString()]); Summary.Append("<i<br>>"); } Summary.Append("<i<br>>"); } if (Roundtrips.Count > 0) { int BaselineRoundtripInt = Int32.Parse(BaselineRoundtrip); List<int> PlusRoundtripIntList = new List<int>(); List<int> MinusRoundtripIntList = new List<int>(); for (int i = 0; i < Roundtrips.Count; i++) { int RoundtripDiff = Int32.Parse(Roundtrips[i].Trim(new char[] { '+', '-', 'm', 's', ' ' })); if (Roundtrips[i][0] == '+') { PlusRoundtripIntList.Add(BaselineRoundtripInt + RoundtripDiff); } else { MinusRoundtripIntList.Add(BaselineRoundtripInt - RoundtripDiff); } } PlusRoundtripIntList.Sort(); MinusRoundtripIntList.Sort(); Summary.Append(string.Format("Variation in the response roundtrip time from baseline value {0} ms:<i<br>><i<br>>", BaselineRoundtripInt)); string BaselineTimeStr = string.Format("{0} ms (Normal)", BaselineRoundtripInt); string HighestTimeStr = ""; string LowestTimeStr = ""; double Factor = (double)BaselineRoundtripInt / 100.0; if (Factor == 0) Factor = 1.0;//To avoid divide by 0 exception or multiply by 0 and get 0 if (PlusRoundtripIntList.Count > 0) { HighestTimeStr = string.Format("{0} ms (Highest variation)", PlusRoundtripIntList[0]); if ((double)PlusRoundtripIntList[0] / Factor > 250.0) { Factor = (double)PlusRoundtripIntList[0] / 250.0; if (Factor == 0) Factor = 1.0; } else if ((double)PlusRoundtripIntList[0] / Factor < 100.0) { Factor = (double)PlusRoundtripIntList[0] / 100.0; if (Factor == 0) Factor = 1.0; } } if (MinusRoundtripIntList.Count > 0) { LowestTimeStr = string.Format("{0} ms (Lowest variation)", MinusRoundtripIntList[0]); } Summary.Append("<i<hlg>>"); Summary.Append(new String(' ', (int)Math.Round(((double)BaselineRoundtripInt / Factor)))); Summary.Append("<i</hlg>>"); Summary.Append(" "); Summary.Append(BaselineTimeStr); Summary.Append("<i<br>>"); if (HighestTimeStr.Length > 0) { Summary.Append("<i<hlb>>"); Summary.Append(new String(' ', (int)Math.Round(((double)PlusRoundtripIntList[0] / Factor)))); Summary.Append("<i</hlb>>"); Summary.Append(" "); Summary.Append(HighestTimeStr); Summary.Append("<i<br>>"); } if (LowestTimeStr.Length > 0) { Summary.Append("<i<hlo>>"); Summary.Append(new String(' ', (int)Math.Round(((double)MinusRoundtripIntList[0] / Factor)))); Summary.Append("<i</hlo>>"); Summary.Append(" "); Summary.Append(LowestTimeStr); Summary.Append("<i<br>>"); } Summary.Append("<i<br>>"); } ScanTraceBehaviourAnalysisResultsUiInformation UiResult = new ScanTraceBehaviourAnalysisResultsUiInformation(); string SummaryText = Summary.ToString(); if (Summary.Length == 0) { UiResult.SummaryText = "<i<h1>>No significant variations could be observed<i</h1>><i<br>><i<br>>"; } else { UiResult.SummaryText = string.Format("<i<h1>>Some payloads caused the following effects:<i</h1>><i<br>><i<br>>{0}", SummaryText); } UiResult.SummaryText = Summary.ToString(); UiResult.CodeGridRows = new List<object[]>(CodeGridRows); UiResult.KeywordGridRows = new List<object[]>(KeywordGridRows); UiResult.SetCookieGridRows = new List<object[]>(SetCookieGridRows); UiResult.HeadersGridRows = new List<object[]>(HeadersGridRows); UiResult.BodyGridRows = new List<object[]>(BodyGridRows); UiResult.TimeGridRows = new List<object[]>(TimeGridRows); return UiResult; }