[Appsec]Benchmarks#2537
Conversation
| { | ||
| // Build the actual integration test projects for Any CPU | ||
| var integrationTestProjects = TracerDirectory.GlobFiles("test/*.IntegrationTests/*.csproj"); | ||
| var integrationTestProjects = TracerDirectory.GlobFiles("test/*.Security.IntegrationTests/*.csproj"); |
robertpi
left a comment
There was a problem hiding this comment.
I think there's a minor fix needed, but otherwise looks good.
andrewlock
left a comment
There was a problem hiding this comment.
Just some minor suggestions/questions
| @@ -0,0 +1,5 @@ | |||
| { | |||
| "DD_APPSEC_ENABLED": true, | |||
| "DD_DOTNET_TRACER_HOME": "C:\Repositories\dd-trace-dotnet\tracer\bin\dd-tracer-home\win-x64", | |||
There was a problem hiding this comment.
Should this really be hard-coded? 🤔
There was a problem hiding this comment.
indeed I forgot to change it, removed the file and setting environment variables in the constructor, thanks
| #if !NETFRAMEWORK | ||
| public class HttpContextMock : HttpContext | ||
| { | ||
| private readonly HttpResponseMock responseMock; | ||
|
|
||
| public HttpContextMock(HttpResponseMock responseMock) | ||
| { | ||
| this.responseMock = responseMock; | ||
| } | ||
| public override ConnectionInfo Connection => throw new NotImplementedException(); |
There was a problem hiding this comment.
I'm not sure all this is necessary? I think you can use DefaultHttpContext?
There was a problem hiding this comment.
yes I wasnt sure how to make sure the response was disposing the waf pointers, but with disposing them manually now in 8eda4fe, no need for all this anymore thanks
| [GlobalSetup] | ||
| public void Setup() | ||
| { | ||
| security = Security.Instance; | ||
| } |
There was a problem hiding this comment.
nit: rather than using GlobalSetup we typically use a static constructor. Nothing wrong with this AFAIK, just wondered if there was a specific reason for this approach?
There was a problem hiding this comment.
there was no reason , as I had problems initializing Security, I tried this and left it 😅
| [Benchmark] | ||
| public void AllCycleSimpleBody() | ||
| { | ||
| #if NETFRAMEWORK | ||
| Debugger.Break(); | ||
| using var ms = new MemoryStream(); | ||
| using var sw = new StreamWriter(ms); | ||
| var httpContextMock = new HttpContext(new HttpRequest(string.Empty, string.Empty, string.Empty), new HttpResponse(sw)); | ||
| security.InstrumentationGateway.RaiseBodyAvailable(httpContextMock, new Span(new SpanContext(1, 1), DateTimeOffset.UtcNow), new { }); | ||
| #else | ||
| var httpContextMock = new HttpContextMock(new HttpResponseMock()); | ||
| security.InstrumentationGateway.RaiseBodyAvailable(httpContextMock, new Span(new SpanContext(1, 1), DateTimeOffset.UtcNow), new { }); | ||
| #endif | ||
| } |
There was a problem hiding this comment.
It would be nice to be able to compare these to benchmarks where security is disabled, do we do that currently?
There was a problem hiding this comment.
we have that in the crank but this was more to benchmark the body, and in particular, the body reflection algorithm.
| using var ms = new MemoryStream(); | ||
| using var sw = new StreamWriter(ms); | ||
| var httpContextMock = new HttpContext(new HttpRequest(string.Empty, string.Empty, string.Empty), new HttpResponse(sw)); |
There was a problem hiding this comment.
I wonder if this setup should be outside the benchmark itself? Probably not necessary though.
There was a problem hiding this comment.
thanks! Fixed in 8eda4fe, resources are then disposed after the execution
* first appsec benchmark * Remove required filter and add more benchmarks * Fix benchmarks for .NET framework * add a more complex object * fix build steps * Env variables * fix benchmarks * Init httpcontext outside of benchmark * remove global setup Co-authored-by: Robert Pickering <[email protected]>
* first appsec benchmark * Remove required filter and add more benchmarks * Fix benchmarks for .NET framework * add a more complex object * fix build steps * Env variables * fix benchmarks * Init httpcontext outside of benchmark * remove global setup Co-authored-by: Robert Pickering <[email protected]>
* first appsec benchmark * Remove required filter and add more benchmarks * Fix benchmarks for .NET framework * add a more complex object * fix build steps * Env variables * fix benchmarks * Init httpcontext outside of benchmark * remove global setup Co-authored-by: Robert Pickering <[email protected]>
* first appsec benchmark * Remove required filter and add more benchmarks * Fix benchmarks for .NET framework * add a more complex object * fix build steps * Env variables * fix benchmarks * Init httpcontext outside of benchmark * remove global setup Co-authored-by: Robert Pickering <[email protected]>
* first appsec benchmark * Remove required filter and add more benchmarks * Fix benchmarks for .NET framework * add a more complex object * fix build steps * Env variables * fix benchmarks * Init httpcontext outside of benchmark * remove global setup Co-authored-by: Robert Pickering <[email protected]>
* first appsec benchmark * Remove required filter and add more benchmarks * Fix benchmarks for .NET framework * add a more complex object * fix build steps * Env variables * fix benchmarks * Init httpcontext outside of benchmark * remove global setup Co-authored-by: Robert Pickering <[email protected]>
* first appsec benchmark * Remove required filter and add more benchmarks * Fix benchmarks for .NET framework * add a more complex object * fix build steps * Env variables * fix benchmarks * Init httpcontext outside of benchmark * remove global setup Co-authored-by: Robert Pickering <[email protected]>
* Failing test for framework * Adding extractor for body model and event * Subscribing to body available in security * add content type for post request * Read the parsed body in .NET Framework Includes: * Win Forms * WebApi * MVC * Read the parsed body in Net Core (#2501) Adding a more complex model Removing tests with block enabled Removing tests with block enabled Renaming samples wth security prefix to avoid nuke confusion Changing sln accordingly * Adapt build steps for linux and rename integration right * Changing snapshot files to match new ressponse content length * Publish views dll for linux cause we use the publish folder for inte test fix build * Start of unit tests for parsed body * Unit tests and handle some serialization corner cases * Move code from IG into BodyExtractor.cs * Better detection of primatives Detect object graphs with cycles Only look at instance properties * Use fields instead of property to avoid side effects Use fields instead of property to avoid side effects Fix possible null ref * [Appsec]Benchmarks (#2537) * first appsec benchmark * Remove required filter and add more benchmarks * Fix benchmarks for .NET framework * add a more complex object * fix build steps * Env variables * fix benchmarks * Init httpcontext outside of benchmark * remove global setup Co-authored-by: Robert Pickering <[email protected]> * Adding enum to body extractor * Remove unneeded code containing a TODO Adding verified files * First response to comments * Fixing duck typing Factorize peek and pop with Func remove duck type on real type * Repsonse to comments Response to comments * Fix integration tests * Fix called several times if 2 binding sources with different id , fix derived attribute * Adding instrumentation scenario filter to instrumentations * Readonlydictionary and reuse the empty one Co-authored-by: Anna <[email protected]>
Summary of changes
Reason for change
Implementation details
Test coverage
Other details