-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ASM][IAST] NHibernate support (SQLI Vuln) #5347
Conversation
Datadog ReportBranch report: ✅ 0 Failed, 327852 Passed, 1587 Skipped, 42m 37.13s Wall Time New Flaky Tests (1)
|
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing the following branches/commits: Execution-time benchmarks measure the whole time it takes to execute a program. And are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are shown in red. The following thresholds were used for comparing the execution times:
Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard. Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph). gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (5347) - mean (74ms) : 66, 82
. : milestone, 74,
master - mean (73ms) : 65, 81
. : milestone, 73,
section CallTarget+Inlining+NGEN
This PR (5347) - mean (1,007ms) : 989, 1024
. : milestone, 1007,
master - mean (1,004ms) : 981, 1026
. : milestone, 1004,
gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (5347) - mean (112ms) : 109, 115
. : milestone, 112,
master - mean (111ms) : 108, 115
. : milestone, 111,
section CallTarget+Inlining+NGEN
This PR (5347) - mean (726ms) : 698, 754
. : milestone, 726,
master - mean (724ms) : 700, 749
. : milestone, 724,
gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (5347) - mean (97ms) : 94, 101
. : milestone, 97,
master - mean (94ms) : 91, 97
. : milestone, 94,
section CallTarget+Inlining+NGEN
This PR (5347) - mean (685ms) : 661, 709
. : milestone, 685,
master - mean (679ms) : 656, 702
. : milestone, 679,
gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (5347) - mean (188ms) : 185, 192
. : milestone, 188,
master - mean (188ms) : 183, 193
. : milestone, 188,
section CallTarget+Inlining+NGEN
This PR (5347) - mean (1,079ms) : 1054, 1105
. : milestone, 1079,
master - mean (1,071ms) : 1052, 1090
. : milestone, 1071,
gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (5347) - mean (271ms) : 266, 275
. : milestone, 271,
master - mean (270ms) : 263, 276
. : milestone, 270,
section CallTarget+Inlining+NGEN
This PR (5347) - mean (875ms) : 848, 902
. : milestone, 875,
master - mean (866ms) : 844, 888
. : milestone, 866,
gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (5347) - mean (260ms) : 257, 264
. : milestone, 260,
master - mean (260ms) : 254, 266
. : milestone, 260,
section CallTarget+Inlining+NGEN
This PR (5347) - mean (853ms) : 828, 877
. : milestone, 853,
master - mean (852ms) : 826, 877
. : milestone, 852,
|
Benchmarks Report for tracer 🐌Benchmarks for #5347 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.ActivityBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SpanBenchmark - Faster 🎉 Same allocations ✔️
|
Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net6.0 | 1.178 | 685.08 | 581.48 |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | StartFinishSpan |
net6.0 | 464ns | 0.309ns | 1.16ns | 0.00761 | 0 | 0 | 552 B |
master | StartFinishSpan |
netcoreapp3.1 | 685ns | 0.576ns | 2.16ns | 0.0072 | 0 | 0 | 552 B |
master | StartFinishSpan |
net472 | 803ns | 1.01ns | 3.64ns | 0.0879 | 0 | 0 | 554 B |
master | StartFinishScope |
net6.0 | 685ns | 0.886ns | 3.43ns | 0.00959 | 0 | 0 | 672 B |
master | StartFinishScope |
netcoreapp3.1 | 872ns | 0.722ns | 2.8ns | 0.00878 | 0 | 0 | 672 B |
master | StartFinishScope |
net472 | 977ns | 1.28ns | 4.95ns | 0.1 | 0 | 0 | 634 B |
#5347 | StartFinishSpan |
net6.0 | 483ns | 0.63ns | 2.44ns | 0.00784 | 0 | 0 | 552 B |
#5347 | StartFinishSpan |
netcoreapp3.1 | 663ns | 1.22ns | 4.72ns | 0.00724 | 0 | 0 | 552 B |
#5347 | StartFinishSpan |
net472 | 751ns | 1.42ns | 5.51ns | 0.0879 | 0 | 0 | 554 B |
#5347 | StartFinishScope |
net6.0 | 581ns | 0.697ns | 2.7ns | 0.00944 | 0 | 0 | 672 B |
#5347 | StartFinishScope |
netcoreapp3.1 | 892ns | 3.36ns | 13ns | 0.00925 | 0 | 0 | 672 B |
#5347 | StartFinishScope |
net472 | 916ns | 1.68ns | 6.52ns | 0.101 | 0 | 0 | 634 B |
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | RunOnMethodBegin |
net6.0 | 750ns | 0.672ns | 2.6ns | 0.00945 | 0 | 0 | 672 B |
master | RunOnMethodBegin |
netcoreapp3.1 | 943ns | 0.716ns | 2.58ns | 0.00918 | 0 | 0 | 672 B |
master | RunOnMethodBegin |
net472 | 1.1μs | 1.29ns | 4.99ns | 0.101 | 0 | 0 | 634 B |
#5347 | RunOnMethodBegin |
net6.0 | 721ns | 0.675ns | 2.61ns | 0.00935 | 0 | 0 | 672 B |
#5347 | RunOnMethodBegin |
netcoreapp3.1 | 961ns | 1.65ns | 6.38ns | 0.00897 | 0 | 0 | 672 B |
#5347 | RunOnMethodBegin |
net472 | 1.03μs | 1.17ns | 4.53ns | 0.1 | 0 | 0 | 634 B |
ed4220c
to
ecc10a2
Compare
Benchmarks Report for appsec 🐌Benchmarks for #5347 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.Asm.AppSecBodyBenchmark - Faster 🎉 Same allocations ✔️
|
Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody‑netcoreapp3.1 | 1.294 | 255.94 | 197.75 |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | AllCycleSimpleBody |
net6.0 | 578ns | 0.422ns | 1.63ns | 0.0153 | 0 | 0 | 1.08 KB |
master | AllCycleSimpleBody |
netcoreapp3.1 | 858ns | 0.494ns | 1.91ns | 0.0146 | 0 | 0 | 1.06 KB |
master | AllCycleSimpleBody |
net472 | 690ns | 0.214ns | 0.802ns | 0.174 | 0.000347 | 0 | 1.1 KB |
master | AllCycleMoreComplexBody |
net6.0 | 3.51μs | 2.26ns | 8.77ns | 0.065 | 0 | 0 | 4.58 KB |
master | AllCycleMoreComplexBody |
netcoreapp3.1 | 4.76μs | 2.38ns | 9.2ns | 0.0597 | 0 | 0 | 4.48 KB |
master | AllCycleMoreComplexBody |
net472 | 4.33μs | 4.21ns | 16.3ns | 0.732 | 0.00864 | 0 | 4.61 KB |
master | ObjectExtractorSimpleBody |
net6.0 | 142ns | 0.102ns | 0.394ns | 0.00393 | 0 | 0 | 280 B |
master | ObjectExtractorSimpleBody |
netcoreapp3.1 | 256ns | 0.131ns | 0.509ns | 0.00371 | 0 | 0 | 272 B |
master | ObjectExtractorSimpleBody |
net472 | 174ns | 0.263ns | 1.02ns | 0.0446 | 0 | 0 | 281 B |
master | ObjectExtractorMoreComplexBody |
net6.0 | 3.08μs | 1.26ns | 4.72ns | 0.0526 | 0 | 0 | 3.78 KB |
master | ObjectExtractorMoreComplexBody |
netcoreapp3.1 | 4.04μs | 2.63ns | 10.2ns | 0.0503 | 0 | 0 | 3.69 KB |
master | ObjectExtractorMoreComplexBody |
net472 | 4.2μs | 2.86ns | 10.7ns | 0.602 | 0.00627 | 0 | 3.8 KB |
#5347 | AllCycleSimpleBody |
net6.0 | 548ns | 0.496ns | 1.86ns | 0.0152 | 0 | 0 | 1.08 KB |
#5347 | AllCycleSimpleBody |
netcoreapp3.1 | 819ns | 0.901ns | 3.49ns | 0.0144 | 0 | 0 | 1.06 KB |
#5347 | AllCycleSimpleBody |
net472 | 624ns | 0.273ns | 1.06ns | 0.175 | 0.000313 | 0 | 1.1 KB |
#5347 | AllCycleMoreComplexBody |
net6.0 | 3.64μs | 2.06ns | 7.98ns | 0.0635 | 0 | 0 | 4.58 KB |
#5347 | AllCycleMoreComplexBody |
netcoreapp3.1 | 4.77μs | 3.26ns | 12.2ns | 0.0614 | 0 | 0 | 4.48 KB |
#5347 | AllCycleMoreComplexBody |
net472 | 4.37μs | 2.33ns | 9.04ns | 0.731 | 0.00873 | 0 | 4.61 KB |
#5347 | ObjectExtractorSimpleBody |
net6.0 | 139ns | 0.155ns | 0.601ns | 0.00393 | 0 | 0 | 280 B |
#5347 | ObjectExtractorSimpleBody |
netcoreapp3.1 | 198ns | 0.142ns | 0.549ns | 0.00369 | 0 | 0 | 272 B |
#5347 | ObjectExtractorSimpleBody |
net472 | 167ns | 0.0846ns | 0.305ns | 0.0446 | 0 | 0 | 281 B |
#5347 | ObjectExtractorMoreComplexBody |
net6.0 | 3.1μs | 1.86ns | 6.95ns | 0.0525 | 0 | 0 | 3.78 KB |
#5347 | ObjectExtractorMoreComplexBody |
netcoreapp3.1 | 4.06μs | 5.76ns | 20.8ns | 0.0509 | 0 | 0 | 3.69 KB |
#5347 | ObjectExtractorMoreComplexBody |
net472 | 3.84μs | 2.06ns | 7.98ns | 0.602 | 0.00578 | 0 | 3.8 KB |
Benchmarks.Trace.Asm.AppSecWafBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | RunWafRealisticBenchmark |
net6.0 | 187μs | 82.7ns | 320ns | 0 | 0 | 0 | 6.51 KB |
master | RunWafRealisticBenchmark |
netcoreapp3.1 | 205μs | 687ns | 2.57μs | 0 | 0 | 0 | 6.49 KB |
master | RunWafRealisticBenchmark |
net472 | 222μs | 58.4ns | 202ns | 1.02 | 0 | 0 | 6.59 KB |
master | RunWafRealisticBenchmarkWithAttack |
net6.0 | 125μs | 331ns | 1.28μs | 0 | 0 | 0 | 4.15 KB |
master | RunWafRealisticBenchmarkWithAttack |
netcoreapp3.1 | 133μs | 144ns | 498ns | 0 | 0 | 0 | 4.14 KB |
master | RunWafRealisticBenchmarkWithAttack |
net472 | 147μs | 125ns | 468ns | 0.656 | 0 | 0 | 4.19 KB |
#5347 | RunWafRealisticBenchmark |
net6.0 | 189μs | 333ns | 1.29μs | 0 | 0 | 0 | 6.51 KB |
#5347 | RunWafRealisticBenchmark |
netcoreapp3.1 | 205μs | 295ns | 1.14μs | 0 | 0 | 0 | 6.49 KB |
#5347 | RunWafRealisticBenchmark |
net472 | 226μs | 446ns | 1.73μs | 1.02 | 0 | 0 | 6.59 KB |
#5347 | RunWafRealisticBenchmarkWithAttack |
net6.0 | 124μs | 56.8ns | 220ns | 0 | 0 | 0 | 4.15 KB |
#5347 | RunWafRealisticBenchmarkWithAttack |
netcoreapp3.1 | 134μs | 157ns | 588ns | 0 | 0 | 0 | 4.14 KB |
#5347 | RunWafRealisticBenchmarkWithAttack |
net472 | 146μs | 168ns | 650ns | 0.655 | 0 | 0 | 4.19 KB |
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations ⚠️
More allocations ⚠️ in #5347
Benchmark
Base Allocated
Diff Allocated
Change
Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1
202.09 KB
203.55 KB
1.46 KB
0.72%
Fewer allocations 🎉 in #5347
Benchmark
Base Allocated
Diff Allocated
Change
Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0
205.27 KB
203.57 KB
-1.7 KB
-0.83%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472
62.2 KB
59.07 KB
-3.13 KB
-5.03%
Benchmark | Base Allocated | Diff Allocated | Change | Change % |
---|---|---|---|---|
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 | 202.09 KB | 203.55 KB | 1.46 KB | 0.72% |
Benchmark | Base Allocated | Diff Allocated | Change | Change % |
---|---|---|---|---|
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 | 205.27 KB | 203.57 KB | -1.7 KB | -0.83% |
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472 | 62.2 KB | 59.07 KB | -3.13 KB | -5.03% |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | StringConcatBenchmark |
net6.0 | 60.1μs | 656ns | 6.4μs | 0 | 0 | 0 | 43.44 KB |
master | StringConcatBenchmark |
netcoreapp3.1 | 61.7μs | 894ns | 8.76μs | 0 | 0 | 0 | 42.64 KB |
master | StringConcatBenchmark |
net472 | 37.6μs | 148ns | 553ns | 0 | 0 | 0 | 62.2 KB |
master | StringConcatAspectBenchmark |
net6.0 | 298μs | 1.65μs | 11.5μs | 0 | 0 | 0 | 205.27 KB |
master | StringConcatAspectBenchmark |
netcoreapp3.1 | 307μs | 1.64μs | 8.38μs | 0 | 0 | 0 | 202.09 KB |
master | StringConcatAspectBenchmark |
net472 | 263μs | 4.63μs | 44.9μs | 0 | 0 | 0 | 221.18 KB |
#5347 | StringConcatBenchmark |
net6.0 | 53.1μs | 198ns | 715ns | 0 | 0 | 0 | 43.44 KB |
#5347 | StringConcatBenchmark |
netcoreapp3.1 | 58.7μs | 694ns | 6.8μs | 0 | 0 | 0 | 42.64 KB |
#5347 | StringConcatBenchmark |
net472 | 38.5μs | 136ns | 472ns | 0 | 0 | 0 | 59.07 KB |
#5347 | StringConcatAspectBenchmark |
net6.0 | 287μs | 1.49μs | 8.7μs | 0 | 0 | 0 | 203.57 KB |
#5347 | StringConcatAspectBenchmark |
netcoreapp3.1 | 319μs | 1.78μs | 11.6μs | 0 | 0 | 0 | 203.55 KB |
#5347 | StringConcatAspectBenchmark |
net472 | 259μs | 4.28μs | 40.1μs | 0 | 0 | 0 | 221.18 KB |
tracer/src/Datadog.Trace/Iast/Aspects/NHibernate/IQueryAspect.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, with a little NIT. Thanks a lot.
7c00cf7
to
1d659e2
Compare
Summary of changes
Detect SQL Injection Vulnerabilities from
CreateQuery
andCreateSQLQuery
forNHibernate
.Reason for change
Add IAST support to hibernate queries for SQL injection.
Test coverage
CreateQuery
andCreateSQLQuery
NHibernateQuery
endpoint