Skip to content

Commit

Permalink
Populate ddbb before test
Browse files Browse the repository at this point in the history
  • Loading branch information
NachoEchevarria committed May 29, 2024
1 parent a27358b commit 0b71a3e
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ public async Task TestRaspRequestBody(string url, string exploit, string body =
IncludeAllHttpSpans = true;
await TryStartApp();
var agent = Fixture.Agent;
_ = await SendRequestsAsync(agent, "/Iast/PopulateDDBB", null, 1, 1, string.Empty, "application/json", null);
var spans = await SendRequestsAsync(agent, url, body, 1, 1, string.Empty, "application/json", null);
var spansFiltered = spans.Where(x => x.Type == SpanTypes.Web).ToList();
var spansFiltered = spans.Where(x => x.Type == SpanTypes.Web && !x.Resource.Contains("/Iast/PopulateDDBB")).ToList();
var settings = VerifyHelper.GetSpanVerifierSettings();
settings.UseParameters(url, exploit, body);
settings.AddIastScrubbing();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ public async Task TestRaspRequestBody(string url, string exploit, string body =
IncludeAllHttpSpans = true;
await TryStartApp();
var agent = Fixture.Agent;
_ = await SendRequestsAsync(agent, "/Iast/PopulateDDBB", null, 1, 1, string.Empty, "application/json", null);
var spans = await SendRequestsAsync(agent, url, body, 1, 1, string.Empty, "application/json", null);
var spansFiltered = spans.Where(x => x.Type == SpanTypes.Web).ToList();
var spansFiltered = spans.Where(x => x.Type == SpanTypes.Web && !x.Resource.Contains("/Iast/PopulateDDBB")).ToList();
var settings = VerifyHelper.GetSpanVerifierSettings();
settings.UseParameters(url, exploit, body);
settings.AddIastScrubbing();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public async Task TestRaspRequestBody(string url, string exploit, string body =
settings.UseParameters(url, exploit, body);
settings.AddIastScrubbing();
var dateTime = DateTime.UtcNow;
var answer = await SubmitRequest("/Iast/PopulateDDBB", null, string.Empty);
_iisFixture.Agent.SpanFilters.Add(s => !s.Resource.Contains("/Iast/PopulateDDBB"));
agent.WaitForSpans(2, minDateTime: dateTime);
dateTime = DateTime.UtcNow;
var testName = _enableIast ? "RaspIast.AspNetMvc5" : "Rasp.AspNetMvc5";
testName += _classicMode ? ".Classic" : ".Integrated";
await SubmitRequest(url, body, "application/json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
_dd.appsec.enabled: 1.0,
_dd.appsec.rasp.duration: 0.0,
_dd.appsec.rasp.duration_ext: 0.0,
_dd.appsec.rasp.rule.eval: 17.0,
_dd.appsec.rasp.rule.eval: 1.0,
_dd.appsec.waf.duration: 0.0,
_dd.appsec.waf.duration_ext: 0.0,
_dd.top_level: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
_dd.appsec.enabled: 1.0,
_dd.appsec.rasp.duration: 0.0,
_dd.appsec.rasp.duration_ext: 0.0,
_dd.appsec.rasp.rule.eval: 17.0,
_dd.appsec.rasp.rule.eval: 1.0,
_dd.appsec.waf.duration: 0.0,
_dd.appsec.waf.duration_ext: 0.0,
_dd.top_level: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
_dd.appsec.enabled: 1.0,
_dd.appsec.rasp.duration: 0.0,
_dd.appsec.rasp.duration_ext: 0.0,
_dd.appsec.rasp.rule.eval: 17.0,
_dd.appsec.rasp.rule.eval: 1.0,
_dd.appsec.waf.duration: 0.0,
_dd.appsec.waf.duration_ext: 0.0,
_dd.top_level: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
_dd.appsec.enabled: 1.0,
_dd.appsec.rasp.duration: 0.0,
_dd.appsec.rasp.duration_ext: 0.0,
_dd.appsec.rasp.rule.eval: 17.0,
_dd.appsec.rasp.rule.eval: 1.0,
_dd.appsec.waf.duration: 0.0,
_dd.appsec.waf.duration_ext: 0.0,
_dd.top_level: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
_dd.appsec.enabled: 1.0,
_dd.appsec.rasp.duration: 0.0,
_dd.appsec.rasp.duration_ext: 0.0,
_dd.appsec.rasp.rule.eval: 17.0,
_dd.appsec.rasp.rule.eval: 1.0,
_dd.appsec.waf.duration: 0.0,
_dd.appsec.waf.duration_ext: 0.0,
_dd.top_level: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
_dd.appsec.enabled: 1.0,
_dd.appsec.rasp.duration: 0.0,
_dd.appsec.rasp.duration_ext: 0.0,
_dd.appsec.rasp.rule.eval: 17.0,
_dd.appsec.rasp.rule.eval: 1.0,
_dd.appsec.waf.duration: 0.0,
_dd.appsec.waf.duration_ext: 0.0,
_dd.top_level: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
_dd.appsec.enabled: 1.0,
_dd.appsec.rasp.duration: 0.0,
_dd.appsec.rasp.duration_ext: 0.0,
_dd.appsec.rasp.rule.eval: 17.0,
_dd.appsec.rasp.rule.eval: 1.0,
_dd.appsec.waf.duration: 0.0,
_dd.appsec.waf.duration_ext: 0.0,
_dd.top_level: 1.0,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
_dd.appsec.enabled: 1.0,
_dd.appsec.rasp.duration: 0.0,
_dd.appsec.rasp.duration_ext: 0.0,
_dd.appsec.rasp.rule.eval: 17.0,
_dd.appsec.rasp.rule.eval: 1.0,
_dd.appsec.waf.duration: 0.0,
_dd.appsec.waf.duration_ext: 0.0,
_dd.top_level: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ public IActionResult WeakHashing(int delay1 = 0, int delay2 = 0)
#pragma warning restore SYSLIB0021 // Type or member is obsolete
}

[HttpGet("PopulateDDBB")]
[Route("PopulateDDBB")]
public IActionResult PopulateDDBB()
{
try
{
dbConnection ??= IastControllerHelper.CreateDatabase();
return Content("OK");
}
catch (SQLiteException ex)
{
return StatusCode(500, IastControllerHelper.ToFormattedString(ex));
}
}

[HttpGet("SqlQuery")]
[Route("SqlQuery")]
public IActionResult SqlQuery(string username, string query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ public ActionResult WeakHashing(int delay1 = 0, int delay2 = 0)
#pragma warning restore SYSLIB0021 // Type or member is obsolete
}

[Route("PopulateDDBB")]
public ActionResult PopulateDDBB()
{
try
{
dbConnection = dbConnection ?? IastControllerHelper.CreateDatabase();
return Content("OK");
}
catch (SQLiteException ex)
{
return Content(IastControllerHelper.ToFormattedString(ex));
}
}

[Route("SqlQuery")]
public ActionResult SqlQuery(string username, string query)
{
Expand Down

0 comments on commit 0b71a3e

Please sign in to comment.