void AnalyzeResponseCode(int Index, BehaviourAnalysisResult Result) { if (this.Logs[Index].Response.Code != this.BaseLineSession.Response.Code) { Result.ResponseCodeResult = this.Logs[Index].Response.Code; } }
void AnalyzePayloadBehaviour(int Index) { BehaviourAnalysisResult Result = new BehaviourAnalysisResult(); Result.LogId = this.Logs[Index].LogId; Result.Payload = this.Payloads[Index]; this.Results.Add(Result); AnalyzeResponseCode(Index, Result); AnalyzeRoundtripTime(Index, Result); AnalyzeSetCookieHeaders(Index, Result); AnalyzeResponseHeaders(Index, Result); AnalyzeResponseContent(Index, Result); }
void AnalyzeResponseHeaders(int Index, BehaviourAnalysisResult Result) { foreach (string BaseName in this.BaseLineSession.Response.Headers.GetNames()) { if (!this.Logs[Index].Response.Headers.GetNames().Contains(BaseName)) { Result.ResponseHeadersResult.Add(string.Format("-{0}", BaseName));//header deleted } } foreach (string CurrentName in this.Logs[Index].Response.Headers.GetNames()) { if (!this.BaseLineSession.Response.Headers.GetNames().Contains(CurrentName)) { Result.ResponseHeadersResult.Add(string.Format("+{0}", CurrentName));//header added } } }
void AnalyzeRoundtripTime(int Index, BehaviourAnalysisResult Result) { int CurrentRoundTrip = this.RoundtripTimes[Index]; if (CurrentRoundTrip == 0) { CurrentRoundTrip = 1; //this number to be used when multiplying so that the result is not 0 } if ((this.RoundtripTimes[Index] > (this.BaseLineRoundtripTime + RoundtripMinInterestingChange)) || (this.RoundtripTimes[Index] > (this.BaseLineRoundtripTime * RoundtripMinInterestingChangeFactor))) { Result.RoundtripTimeResult = string.Format("+{0} ms", this.RoundtripTimes[Index] - this.BaseLineRoundtripTime); } else if ((this.BaseLineRoundtripTime > (this.RoundtripTimes[Index] + RoundtripMinInterestingChange)) || (this.BaseLineRoundtripTime > (CurrentRoundTrip * RoundtripMinInterestingChangeFactor))) { Result.RoundtripTimeResult = string.Format("{0} ms", this.RoundtripTimes[Index] - this.BaseLineRoundtripTime); } }
internal void Analyze(List <string> Payloads, List <int> LogIds, List <int> RoundtripTimes, string ScannedSection) { if (Payloads.Count == 0 || LogIds.Count == 0 || Payloads.Count != LogIds.Count) { return; } CompileKeywordsRegex(); this.BaseLinePayload = Payloads[0]; this.BaseLineRoundtripTime = RoundtripTimes[0]; try { this.BaseLineSession = Session.FromScanLog(LogIds[0]); this.BaseLineLogId = this.BaseLineSession.LogId; } catch (Exception Exp) { IronException.Report("Unable to Load from Scan Log", Exp); } this.Payloads.Clear(); this.Logs.Clear(); for (int i = 1; i < Payloads.Count; i++) { this.Payloads.Add(Payloads[i]); this.RoundtripTimes.Add(RoundtripTimes[i]); try { this.Logs.Add(Session.FromScanLog(LogIds[i])); } catch (Exception Exp) { IronException.Report("Unable to Load from Scan Log", Exp); } AnalyzePayloadBehaviour(i - 1); } this.ResultsXml = BehaviourAnalysisResult.ToXml(this.Results); DoOverallComparitiveAnalysis(); }
void AnalyzeSetCookieHeaders(int Index, BehaviourAnalysisResult Result) { foreach (SetCookie BSC in this.BaseLineSession.Response.SetCookies) { bool Found = false; foreach (SetCookie CSC in this.Logs[Index].Response.SetCookies) { if (BSC.Name.Equals(CSC.Name)) { Found = true; if (BSC.Value.Length > 0 && CSC.Value.Length == 0) { Result.SetCookieHeaderResult.Add(string.Format("<{0}", BSC.Name));//value deleted } } } if (!Found) { Result.SetCookieHeaderResult.Add(string.Format("-{0}", BSC.Name));//cookie deleted } } foreach (SetCookie CSC in this.Logs[Index].Response.SetCookies) { bool Found = false; foreach (SetCookie BSC in this.BaseLineSession.Response.SetCookies) { if (BSC.Name.Equals(CSC.Name)) { Found = true; if (CSC.Value.Length > 0 && BSC.Value.Length == 0) { Result.SetCookieHeaderResult.Add(string.Format(">{0}", BSC.Name));//value added } } } if (!Found) { Result.SetCookieHeaderResult.Add(string.Format("+{0}", CSC.Name));//cookie added } } }
void AnalyzeResponseContent(int Index, BehaviourAnalysisResult Result) { DiffPlex.DiffBuilder.Model.SideBySideDiffModel DiffResult = IronDiffer.GetDiff(this.BaseLineSession.Response.BodyString, this.Logs[Index].Response.BodyString); int DiffLevel = IronDiffer.GetLevel(DiffResult, this.BaseLineSession.Response.BodyString, this.Logs[Index].Response.BodyString); List <string> InsertedStrings = IronDiffer.GetInsertedStrings(DiffResult); List <string> DeletedStrings = IronDiffer.GetDeletedStrings(DiffResult); List <string> KeywordsFound = new List <string>(); foreach (string Keyword in this.Keywords.Keys) { if (this.Logs[Index].Response.BodyString.IndexOf(Keyword, 0, StringComparison.OrdinalIgnoreCase) > -1) { KeywordsFound.Add(Keyword); } } int NoOfInsertedChars = 0; foreach (string InsertedString in InsertedStrings) { NoOfInsertedChars += InsertedString.Length; if (KeywordsFound.Count > 0) { foreach (string Keyword in KeywordsFound) { if (this.Keywords[Keyword].IsMatch(InsertedString)) { if (!Result.ResponseKeywordsResult.Contains(Keyword)) { Result.ResponseKeywordsResult.Add(Keyword); } } } } } if (NoOfInsertedChars > BodyDiffMinInterestingInsertedChars) { Result.ResponseContentResult = NoOfInsertedChars; } }
public static void Test() { BehaviourAnalysisResult Result = new BehaviourAnalysisResult(); Result.Payload = "lolz"; Result.ResponseCodeResult = 123; Result.ResponseContentResult = 321; Result.RoundtripTimeResult = "000"; Result.ResponseHeadersResult.Add("xxx"); Result.ResponseHeadersResult.Add("xxx1"); Result.ResponseHeadersResult.Add("xxx2"); Result.ResponseKeywordsResult.Add("yyy"); Result.ResponseKeywordsResult.Add("yyy1"); Result.ResponseKeywordsResult.Add("yyy2"); Result.SetCookieHeaderResult.Add("zzz"); Result.SetCookieHeaderResult.Add("zzz1"); Result.SetCookieHeaderResult.Add("zzz2"); string XML = ToXml(Result); BehaviourAnalysisResult R = ToObject(XML); }
internal List <string> ResponseKeywordsResult = new List <string>(); //{"error", "exception"} internal static string ToXml(BehaviourAnalysisResult Result) { StringBuilder SB = new StringBuilder(); XmlWriter XW = XmlWriter.Create(SB); XW.WriteStartDocument(); XW.WriteStartElement("BAR"); XW.WriteStartElement("Payload"); XW.WriteValue(Result.Payload); XW.WriteEndElement(); XW.WriteStartElement("LogId"); XW.WriteValue(Result.LogId); XW.WriteEndElement(); XW.WriteStartElement("Code"); XW.WriteValue(Result.ResponseCodeResult); XW.WriteEndElement(); XW.WriteStartElement("Content"); XW.WriteValue(Result.ResponseContentResult); XW.WriteEndElement(); XW.WriteStartElement("Time"); XW.WriteValue(Result.RoundtripTimeResult); XW.WriteEndElement(); XW.WriteStartElement("SetCookies"); foreach (string SC in Result.SetCookieHeaderResult) { XW.WriteStartElement("SetCookie"); XW.WriteValue(SC); XW.WriteEndElement(); } XW.WriteEndElement(); XW.WriteStartElement("Headers"); foreach (string H in Result.ResponseHeadersResult) { XW.WriteStartElement("Header"); XW.WriteValue(H); XW.WriteEndElement(); } XW.WriteEndElement(); XW.WriteStartElement("Keywords"); foreach (string K in Result.ResponseKeywordsResult) { XW.WriteStartElement("Keyword"); XW.WriteValue(K); XW.WriteEndElement(); } XW.WriteEndElement(); XW.WriteEndElement(); XW.WriteEndDocument(); XW.Close(); return(SB.ToString().Split(new string[] { "?>" }, StringSplitOptions.None)[1]); }
void AnalyzeRoundtripTime(int Index, BehaviourAnalysisResult Result) { int CurrentRoundTrip = this.RoundtripTimes[Index]; if (CurrentRoundTrip == 0) CurrentRoundTrip = 1;//this number to be used when multiplying so that the result is not 0 if ((this.RoundtripTimes[Index] > (this.BaseLineRoundtripTime + RoundtripMinInterestingChange)) || (this.RoundtripTimes[Index] > (this.BaseLineRoundtripTime * RoundtripMinInterestingChangeFactor))) { Result.RoundtripTimeResult = string.Format("+{0} ms", this.RoundtripTimes[Index] - this.BaseLineRoundtripTime); } else if ((this.BaseLineRoundtripTime > (this.RoundtripTimes[Index] + RoundtripMinInterestingChange)) || (this.BaseLineRoundtripTime > (CurrentRoundTrip * RoundtripMinInterestingChangeFactor))) { Result.RoundtripTimeResult = string.Format("{0} ms", this.RoundtripTimes[Index] - this.BaseLineRoundtripTime); } }
void AnalyzeResponseContent(int Index, BehaviourAnalysisResult Result) { DiffPlex.DiffBuilder.Model.SideBySideDiffModel DiffResult = IronDiffer.GetDiff(this.BaseLineSession.Response.BodyString, this.Logs[Index].Response.BodyString); int DiffLevel = IronDiffer.GetLevel(DiffResult, this.BaseLineSession.Response.BodyString, this.Logs[Index].Response.BodyString); List<string> InsertedStrings = IronDiffer.GetInsertedStrings(DiffResult); List<string> DeletedStrings = IronDiffer.GetDeletedStrings(DiffResult); List<string> KeywordsFound = new List<string>(); foreach (string Keyword in this.Keywords.Keys) { if (this.Logs[Index].Response.BodyString.IndexOf(Keyword, 0, StringComparison.OrdinalIgnoreCase) > -1) { KeywordsFound.Add(Keyword); } } int NoOfInsertedChars = 0; foreach (string InsertedString in InsertedStrings) { NoOfInsertedChars += InsertedString.Length; if (KeywordsFound.Count > 0) { foreach (string Keyword in KeywordsFound) { if (this.Keywords[Keyword].IsMatch(InsertedString)) { if (!Result.ResponseKeywordsResult.Contains(Keyword)) { Result.ResponseKeywordsResult.Add(Keyword); } } } } } if (NoOfInsertedChars > BodyDiffMinInterestingInsertedChars) { Result.ResponseContentResult = NoOfInsertedChars; } }
void AnalyzeResponseHeaders(int Index, BehaviourAnalysisResult Result) { foreach (string BaseName in this.BaseLineSession.Response.Headers.GetNames()) { if (!this.Logs[Index].Response.Headers.GetNames().Contains(BaseName)) { Result.ResponseHeadersResult.Add(string.Format("-{0}", BaseName));//header deleted } } foreach (string CurrentName in this.Logs[Index].Response.Headers.GetNames()) { if (!this.BaseLineSession.Response.Headers.GetNames().Contains(CurrentName)) { Result.ResponseHeadersResult.Add(string.Format("+{0}", CurrentName));//header added } } }
void AnalyzeResponseCode(int Index, BehaviourAnalysisResult Result) { if (this.Logs[Index].Response.Code != this.BaseLineSession.Response.Code) { Result.ResponseCodeResult = this.Logs[Index].Response.Code; } }
void AnalyzePayloadBehaviour(int Index) { BehaviourAnalysisResult Result = new BehaviourAnalysisResult(); Result.LogId = this.Logs[Index].LogId; Result.Payload = this.Payloads[Index]; this.Results.Add(Result); AnalyzeResponseCode(Index, Result); AnalyzeRoundtripTime(Index, Result); AnalyzeSetCookieHeaders(Index, Result); AnalyzeResponseHeaders(Index, Result); AnalyzeResponseContent(Index, Result); }
internal static string ToXml(BehaviourAnalysisResult Result) { StringBuilder SB = new StringBuilder(); XmlWriter XW = XmlWriter.Create(SB); XW.WriteStartDocument(); XW.WriteStartElement("BAR"); XW.WriteStartElement("Payload"); XW.WriteValue(Result.Payload); XW.WriteEndElement(); XW.WriteStartElement("LogId"); XW.WriteValue(Result.LogId); XW.WriteEndElement(); XW.WriteStartElement("Code"); XW.WriteValue(Result.ResponseCodeResult); XW.WriteEndElement(); XW.WriteStartElement("Content"); XW.WriteValue(Result.ResponseContentResult); XW.WriteEndElement(); XW.WriteStartElement("Time"); XW.WriteValue(Result.RoundtripTimeResult); XW.WriteEndElement(); XW.WriteStartElement("SetCookies"); foreach (string SC in Result.SetCookieHeaderResult) { XW.WriteStartElement("SetCookie"); XW.WriteValue(SC); XW.WriteEndElement(); } XW.WriteEndElement(); XW.WriteStartElement("Headers"); foreach (string H in Result.ResponseHeadersResult) { XW.WriteStartElement("Header"); XW.WriteValue(H); XW.WriteEndElement(); } XW.WriteEndElement(); XW.WriteStartElement("Keywords"); foreach (string K in Result.ResponseKeywordsResult) { XW.WriteStartElement("Keyword"); XW.WriteValue(K); XW.WriteEndElement(); } XW.WriteEndElement(); XW.WriteEndElement(); XW.WriteEndDocument(); XW.Close(); return SB.ToString().Split(new string[]{"?>"}, StringSplitOptions.None)[1]; }
void AnalyzeSetCookieHeaders(int Index, BehaviourAnalysisResult Result) { foreach (SetCookie BSC in this.BaseLineSession.Response.SetCookies) { bool Found = false; foreach (SetCookie CSC in this.Logs[Index].Response.SetCookies) { if (BSC.Name.Equals(CSC.Name)) { Found = true; if (BSC.Value.Length > 0 && CSC.Value.Length == 0) { Result.SetCookieHeaderResult.Add(string.Format("<{0}", BSC.Name));//value deleted } } } if (!Found) { Result.SetCookieHeaderResult.Add(string.Format("-{0}", BSC.Name));//cookie deleted } } foreach (SetCookie CSC in this.Logs[Index].Response.SetCookies) { bool Found = false; foreach (SetCookie BSC in this.BaseLineSession.Response.SetCookies) { if (BSC.Name.Equals(CSC.Name)) { Found = true; if (CSC.Value.Length > 0 && BSC.Value.Length == 0) { Result.SetCookieHeaderResult.Add(string.Format(">{0}", BSC.Name));//value added } } } if (!Found) { Result.SetCookieHeaderResult.Add(string.Format("+{0}", CSC.Name));//cookie added } } }
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); }
internal static BehaviourAnalysisResult ToObject(string XML) { StringReader SR = new StringReader(XML); XmlReader XR = XmlReader.Create(SR); BehaviourAnalysisResult Result = new BehaviourAnalysisResult(); while (XR.Read()) { if (XR.NodeType == XmlNodeType.Element) { switch (XR.Name) { case ("Payload"): XR.Read(); Result.Payload = XR.Value; break; case ("LogId"): XR.Read(); try { Result.LogId = Int32.Parse(XR.Value); } catch { } break; case ("Code"): XR.Read(); try { Result.ResponseCodeResult = Int32.Parse(XR.Value); } catch { } break; case ("Content"): XR.Read(); try { Result.ResponseContentResult = Int32.Parse(XR.Value); } catch { } break; case ("Time"): XR.Read(); try { Result.RoundtripTimeResult = XR.Value; } catch { } break; case ("SetCookie"): XR.Read(); Result.SetCookieHeaderResult.Add(XR.Value); break; case ("Header"): XR.Read(); Result.ResponseHeadersResult.Add(XR.Value); break; case ("Keyword"): XR.Read(); Result.ResponseKeywordsResult.Add(XR.Value); break; } } } return Result; }
internal static BehaviourAnalysisResult ToObject(string XML) { StringReader SR = new StringReader(XML); XmlReader XR = XmlReader.Create(SR); BehaviourAnalysisResult Result = new BehaviourAnalysisResult(); while (XR.Read()) { if (XR.NodeType == XmlNodeType.Element) { switch (XR.Name) { case ("Payload"): XR.Read(); Result.Payload = XR.Value; break; case ("LogId"): XR.Read(); try { Result.LogId = Int32.Parse(XR.Value); } catch { } break; case ("Code"): XR.Read(); try { Result.ResponseCodeResult = Int32.Parse(XR.Value); } catch { } break; case ("Content"): XR.Read(); try { Result.ResponseContentResult = Int32.Parse(XR.Value); } catch { } break; case ("Time"): XR.Read(); try { Result.RoundtripTimeResult = XR.Value; } catch { } break; case ("SetCookie"): XR.Read(); Result.SetCookieHeaderResult.Add(XR.Value); break; case ("Header"): XR.Read(); Result.ResponseHeadersResult.Add(XR.Value); break; case ("Keyword"): XR.Read(); Result.ResponseKeywordsResult.Add(XR.Value); break; } } } return(Result); }