Skip to content

Commit

Permalink
it's a fact
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-git committed Oct 1, 2024
1 parent 8098a61 commit e0807d5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tracer/test/Datadog.Trace.Security.Unit.Tests/ActionChangeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@ public void GivenADummyRule_WhenActionReturnCodeIsChanged_ThenChangesAreApplied(
}
}

[Fact]
public void GivenADummyRule_WhenActionReturnCodeIsChangedAfterInit_ThenChangesAreApplied()
{
var args = CreateArgs("dummyrule2");
var initResult = Waf.Create(
WafLibraryInvoker,
string.Empty,
string.Empty,
useUnsafeEncoder: true,
embeddedRulesetPath: "rasp-rule-set.json");

var waf = initResult.Waf;
waf.Should().NotBeNull();

UpdateWafWithActions([CreateNewStatusAction("customblock", BlockingAction.BlockRequestType, 500)], waf);

using var context = waf.CreateContext();
var result = context.Run(args, TimeoutMicroSeconds);
result.Timeout.Should().BeFalse("Timeout should be false");
result.BlockInfo["status_code"].Should().Be("500");
}

private Dictionary<string, object> CreateArgs(string requestParam) => new() { { AddressesConstants.RequestUriRaw, "http://localhost:54587/" }, { AddressesConstants.RequestBody, new[] { "param", requestParam } }, { AddressesConstants.RequestMethod, "GET" } };

private void UpdateWafWithActions(Action[] actions, Waf waf)
Expand Down

0 comments on commit e0807d5

Please sign in to comment.