Skip to content

Commit

Permalink
Merge pull request #319 from cmu-sei/v8
Browse files Browse the repository at this point in the history
V8
  • Loading branch information
sei-dupdyke authored Apr 15, 2024
2 parents 4426a01 + 0bfc67b commit 6772e90
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/Ghosts.Client/Handlers/BaseBrowserHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using Actions = OpenQA.Selenium.Interactions.Actions;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using Remotion.Linq.Parsing.Structure.IntermediateModel;

namespace Ghosts.Client.Handlers
{
Expand Down Expand Up @@ -170,8 +170,8 @@ public void ExecuteEvents(TimelineHandler handler)
config = RequestConfiguration.Load(handler, timelineEvent.CommandArgs[0]);
if (config.Uri.IsWellFormedOriginalString())
{
MakeRequest(config);
Report(new ReportItem { Handler = handler.HandlerType.ToString(), Command = timelineEvent.Command, Arg = config.ToString(), Trackable = timelineEvent.TrackableId });
var r = FilterWebResponse(MakeRequest(config));
Report(new ReportItem { Handler = handler.HandlerType.ToString(), Command = timelineEvent.Command, Arg = config.ToString(), Trackable = timelineEvent.TrackableId, Result = r});
}
break;
case "download":
Expand Down Expand Up @@ -302,8 +302,8 @@ public void DoRandomCommand(TimelineHandler handler, TimelineEvent timelineEvent
if (config.Uri != null && config.Uri.IsWellFormedOriginalString())
{
this.LinkManager.SetCurrent(config.Uri);
var s = MakeRequest(config);
Report(new ReportItem { Handler = handler.HandlerType.ToString(), Command = timelineEvent.Command, Arg = config.ToString(), Trackable = timelineEvent.TrackableId, Result = s});
var r = FilterWebResponse(MakeRequest(config));
Report(new ReportItem { Handler = handler.HandlerType.ToString(), Command = timelineEvent.Command, Arg = config.ToString(), Trackable = timelineEvent.TrackableId, Result = r});
Thread.Sleep(timelineEvent.DelayAfterActual);

if (this.Stickiness > 0)
Expand All @@ -329,8 +329,8 @@ public void DoRandomCommand(TimelineHandler handler, TimelineEvent timelineEvent
config.Uri = link.Url;

Log.Trace($"Making request #{loopNumber + 1}/{loops} to {config.Uri}");
MakeRequest(config);
Report(new ReportItem { Handler = handler.HandlerType.ToString(), Command = timelineEvent.Command, Arg = config.ToString(), Trackable = timelineEvent.TrackableId });
r = FilterWebResponse(MakeRequest(config));
Report(new ReportItem { Handler = handler.HandlerType.ToString(), Command = timelineEvent.Command, Arg = config.ToString(), Trackable = timelineEvent.TrackableId, Result = r});
}
catch (Exception e)
{
Expand Down Expand Up @@ -666,8 +666,8 @@ public void DoRandomAltCommand(TimelineHandler handler, TimelineEvent timelineEv
{
var urlDict = new Dictionary<string, int>();
var urlQueue = new LifoQueue<Uri>(VisitedRemember);
MakeRequest(config);
Report(new ReportItem { Handler = handler.HandlerType.ToString(), Command = timelineEvent.Command, Arg = config.ToString(), Trackable = timelineEvent.TrackableId });
var r = FilterWebResponse(MakeRequest(config));
Report(new ReportItem { Handler = handler.HandlerType.ToString(), Command = timelineEvent.Command, Arg = config.ToString(), Trackable = timelineEvent.TrackableId, Result = r});
Thread.Sleep(timelineEvent.DelayAfterActual);

if (this.Stickiness > 0)
Expand Down Expand Up @@ -754,5 +754,11 @@ public void Close()
Report(new ReportItem { Handler = BrowserType.ToString(), Command = "Close" });
Driver.Close();
}

public string FilterWebResponse(string rawResponse)
{
string[] s = { "404", "500" };
return s.Contains(rawResponse) ? rawResponse : "";
}
}
}

0 comments on commit 6772e90

Please sign in to comment.