[AppSec] Update waf and ruleset 1.3.0#2638
Conversation
d4b9cdf to
c82b21b
Compare
c709be4 to
6b0e9d2
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
715100c to
34683c1
Compare
This comment has been minimized.
This comment has been minimized.
211b43b to
0dadf62
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| } | ||
| internal void ObjectFreePtr(IntPtr input) => _freeObjectield(input); | ||
|
|
||
| internal void ResultFree(ref DdwafResultStruct output) => _freeResultField(ref output); |
There was a problem hiding this comment.
Looks like this isn't being used, I think it should be.
There was a problem hiding this comment.
It is used here
and disposed in security with
**using** var wafResult = additiveContext.Run(args, _settings.WafTimeoutMicroSeconds);
robertpi
left a comment
There was a problem hiding this comment.
I think you need to double check the WAF memory structures are being freed correctly. The throughput tests, will probably show increased memory usage if they are not, so this could be a good way to check.
Also, it looks like you've not implemented the env var DD_APPSEC_OBFUSCATION_PARAMETER_KEY_REGEXP and DD_APPSEC_OBFUSCATION_PARAMETER_VALUE_REGEXP. I'm okay with that going in a separate PR if you want to get this one merged as is.
bfdc6ac to
7318349
Compare
This comment has been minimized.
This comment has been minimized.
fd0d20b to
50c1359
Compare
This comment has been minimized.
This comment has been minimized.
Fixing tests to match 1.3.0 fix snapshots
Add default rule file
…hould be a map coming from the waf
2e852af to
114abe9
Compare
Code Coverage Report 📊✔️ Merging #2638 into master will not change line coverage
View the full report for further details: Datadog.Trace Breakdown ✔️
The following classes have significant coverage changes.
The following classes were added in #2638:
View the full reports for further details: |
Benchmarks Report 🐌Benchmarks for #2638 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AppSecBodyBenchmark - Slower
|
| Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.AppSecBodyBenchmark.BodyExtractorMoreComplexBody‑netcoreapp3.1 | 1.172 | 20,126.09 | 23,591.39 |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | AllCycleSimpleBody |
net472 | 294ns | 1.38ns | 5.36ns | 0.0519 | 0 | 0 | 329 B |
| master | AllCycleSimpleBody |
netcoreapp3.1 | 367ns | 2ns | 11.1ns | 0.00449 | 0 | 0 | 328 B |
| master | AllCycleMoreComplexBody |
net472 | 286ns | 0.823ns | 2.97ns | 0.0482 | 0 | 0 | 305 B |
| master | AllCycleMoreComplexBody |
netcoreapp3.1 | 365ns | 1.43ns | 5.56ns | 0.00411 | 0 | 0 | 304 B |
| master | BodyExtractorSimpleBody |
net472 | 417ns | 1.91ns | 7.14ns | 0.057 | 0 | 0 | 361 B |
| master | BodyExtractorSimpleBody |
netcoreapp3.1 | 428ns | 1.97ns | 7.63ns | 0.00376 | 0 | 0 | 272 B |
| master | BodyExtractorMoreComplexBody |
net472 | 23.7μs | 118ns | 526ns | 1.19 | 0.0117 | 0 | 7.62 KB |
| master | BodyExtractorMoreComplexBody |
netcoreapp3.1 | 20.2μs | 95ns | 380ns | 0.0896 | 0 | 0 | 6.75 KB |
| #2638 | AllCycleSimpleBody |
net472 | 300ns | 1.68ns | 10.2ns | 0.052 | 0 | 0 | 329 B |
| #2638 | AllCycleSimpleBody |
netcoreapp3.1 | 385ns | 1.27ns | 4.93ns | 0.00459 | 0 | 0 | 328 B |
| #2638 | AllCycleMoreComplexBody |
net472 | 292ns | 1.23ns | 4.24ns | 0.0482 | 0 | 0 | 305 B |
| #2638 | AllCycleMoreComplexBody |
netcoreapp3.1 | 372ns | 1.88ns | 8.81ns | 0.00416 | 0 | 0 | 304 B |
| #2638 | BodyExtractorSimpleBody |
net472 | 434ns | 2.24ns | 11ns | 0.057 | 0 | 0 | 361 B |
| #2638 | BodyExtractorSimpleBody |
netcoreapp3.1 | 437ns | 2.05ns | 7.95ns | 0.00366 | 0 | 0 | 272 B |
| #2638 | BodyExtractorMoreComplexBody |
net472 | 24.8μs | 123ns | 565ns | 1.19 | 0.0118 | 0 | 7.62 KB |
| #2638 | BodyExtractorMoreComplexBody |
netcoreapp3.1 | 23.5μs | 120ns | 551ns | 0.096 | 0 | 0 | 6.75 KB |
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | SendRequest |
net472 | 0ns | 0ns | 0ns | 0 | 0 | 0 | 0 b |
| master | SendRequest |
netcoreapp3.1 | 294μs | 1.45μs | 7.54μs | 0.148 | 0 | 0 | 19.74 KB |
| #2638 | SendRequest |
net472 | 0ns | 0ns | 0ns | 0 | 0 | 0 | 0 b |
| #2638 | SendRequest |
netcoreapp3.1 | 288μs | 1.3μs | 5.03μs | 0.142 | 0 | 0 | 19.74 KB |
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | ExecuteNonQuery |
net472 | 1.79μs | 9.77ns | 54.4ns | 0.0938 | 0 | 0 | 594 B |
| master | ExecuteNonQuery |
netcoreapp3.1 | 1.46μs | 6.34ns | 23.7ns | 0.00891 | 0 | 0 | 632 B |
| #2638 | ExecuteNonQuery |
net472 | 1.79μs | 9.9ns | 61.8ns | 0.0941 | 0.00088 | 0 | 594 B |
| #2638 | ExecuteNonQuery |
netcoreapp3.1 | 1.46μs | 6.69ns | 26.8ns | 0.00864 | 0 | 0 | 632 B |
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | CallElasticsearch |
net472 | 2.66μs | 12.3ns | 46.1ns | 0.127 | 0 | 0 | 803 B |
| master | CallElasticsearch |
netcoreapp3.1 | 1.62μs | 8.16ns | 38.3ns | 0.0106 | 0 | 0 | 792 B |
| master | CallElasticsearchAsync |
net472 | 2.9μs | 14.2ns | 63.3ns | 0.149 | 0.00144 | 0 | 939 B |
| master | CallElasticsearchAsync |
netcoreapp3.1 | 1.78μs | 5.51ns | 20.6ns | 0.0125 | 0 | 0 | 912 B |
| #2638 | CallElasticsearch |
net472 | 2.8μs | 16.1ns | 123ns | 0.125 | 0 | 0 | 802 B |
| #2638 | CallElasticsearch |
netcoreapp3.1 | 1.81μs | 5.73ns | 21.5ns | 0.0108 | 0 | 0 | 792 B |
| #2638 | CallElasticsearchAsync |
net472 | 2.89μs | 12.4ns | 46.6ns | 0.149 | 0.00147 | 0 | 939 B |
| #2638 | CallElasticsearchAsync |
netcoreapp3.1 | 1.83μs | 8.89ns | 36.6ns | 0.0119 | 0 | 0 | 912 B |
Benchmarks.Trace.GraphQLBenchmark - Slower ⚠️ Same allocations ✔️
Slower ⚠️ in #2638
Benchmark
diff/base
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync‑net472
1.171
3,152.99
3,693.22
| Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync‑net472 | 1.171 | 3,152.99 | 3,693.22 |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | ExecuteAsync |
net472 | 3.16μs | 18ns | 127ns | 0.165 | 0 | 0 | 1.06 KB |
| master | ExecuteAsync |
netcoreapp3.1 | 1.98μs | 7.63ns | 28.5ns | 0.0139 | 0 | 0 | 1.03 KB |
| #2638 | ExecuteAsync |
net472 | 3.7μs | 18.5ns | 80.7ns | 0.168 | 0 | 0 | 1.06 KB |
| #2638 | ExecuteAsync |
netcoreapp3.1 | 2.1μs | 12.2ns | 101ns | 0.0142 | 0 | 0 | 1.03 KB |
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | SendAsync |
net472 | 7.19μs | 38ns | 231ns | 0.354 | 0 | 0 | 2.28 KB |
| master | SendAsync |
netcoreapp3.1 | 4.88μs | 28ns | 222ns | 0.0306 | 0 | 0 | 2.21 KB |
| #2638 | SendAsync |
net472 | 6.93μs | 34.1ns | 180ns | 0.36 | 0 | 0 | 2.28 KB |
| #2638 | SendAsync |
netcoreapp3.1 | 5.13μs | 27.8ns | 155ns | 0.031 | 0 | 0 | 2.21 KB |
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | EnrichedLog |
net472 | 3.38μs | 16.4ns | 71.6ns | 0.228 | 0 | 0 | 1.45 KB |
| master | EnrichedLog |
netcoreapp3.1 | 3.04μs | 11.1ns | 44.3ns | 0.0205 | 0 | 0 | 1.53 KB |
| #2638 | EnrichedLog |
net472 | 3.4μs | 17.1ns | 97ns | 0.227 | 0 | 0 | 1.45 KB |
| #2638 | EnrichedLog |
netcoreapp3.1 | 3.07μs | 14.7ns | 58.8ns | 0.0208 | 0 | 0 | 1.53 KB |
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | EnrichedLog |
net472 | 295μs | 1.39μs | 5.74μs | 0.442 | 0.147 | 0 | 4.33 KB |
| master | EnrichedLog |
netcoreapp3.1 | 231μs | 1.11μs | 4.29μs | 0 | 0 | 0 | 4.21 KB |
| #2638 | EnrichedLog |
net472 | 295μs | 1.66μs | 10.7μs | 0.457 | 0.152 | 0 | 4.33 KB |
| #2638 | EnrichedLog |
netcoreapp3.1 | 232μs | 982ns | 3.54μs | 0 | 0 | 0 | 4.21 KB |
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | EnrichedLog |
net472 | 8.04μs | 38.6ns | 189ns | 0.503 | 0 | 0 | 3.23 KB |
| master | EnrichedLog |
netcoreapp3.1 | 6.38μs | 25.1ns | 118ns | 0.0489 | 0 | 0 | 3.6 KB |
| #2638 | EnrichedLog |
net472 | 7.95μs | 43.8ns | 324ns | 0.506 | 0 | 0 | 3.23 KB |
| #2638 | EnrichedLog |
netcoreapp3.1 | 6.98μs | 39.5ns | 364ns | 0.0471 | 0 | 0 | 3.6 KB |
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | SendReceive |
net472 | 2.3μs | 8.37ns | 32.4ns | 0.16 | 0 | 0 | 1.01 KB |
| master | SendReceive |
netcoreapp3.1 | 2.01μs | 5.67ns | 21.2ns | 0.0141 | 0 | 0 | 1.01 KB |
| #2638 | SendReceive |
net472 | 2.45μs | 12.5ns | 83.1ns | 0.158 | 0 | 0 | 1.01 KB |
| #2638 | SendReceive |
netcoreapp3.1 | 2.18μs | 11.9ns | 81.5ns | 0.0142 | 0 | 0 | 1.01 KB |
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | EnrichedLog |
net472 | 5.88μs | 22.5ns | 84.1ns | 0.292 | 0 | 0 | 1.87 KB |
| master | EnrichedLog |
netcoreapp3.1 | 5.01μs | 27.2ns | 178ns | 0.0195 | 0 | 0 | 1.49 KB |
| #2638 | EnrichedLog |
net472 | 6.13μs | 32.5ns | 169ns | 0.291 | 0 | 0 | 1.87 KB |
| #2638 | EnrichedLog |
netcoreapp3.1 | 5.4μs | 28.3ns | 142ns | 0.0189 | 0 | 0 | 1.49 KB |
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | StartFinishSpan |
net472 | 941ns | 4.71ns | 22.1ns | 0.0719 | 0 | 0 | 457 B |
| master | StartFinishSpan |
netcoreapp3.1 | 852ns | 2.78ns | 10.4ns | 0.00612 | 0 | 0 | 456 B |
| master | StartFinishScope |
net472 | 1.15μs | 6.56ns | 46.4ns | 0.0842 | 0 | 0 | 538 B |
| master | StartFinishScope |
netcoreapp3.1 | 1.02μs | 4.92ns | 20.3ns | 0.00806 | 0 | 0 | 576 B |
| #2638 | StartFinishSpan |
net472 | 908ns | 5.02ns | 34.1ns | 0.0717 | 0 | 0 | 457 B |
| #2638 | StartFinishSpan |
netcoreapp3.1 | 868ns | 3.95ns | 15.3ns | 0.00599 | 0 | 0 | 456 B |
| #2638 | StartFinishScope |
net472 | 1.13μs | 6.43ns | 45.5ns | 0.084 | 0 | 0 | 538 B |
| #2638 | StartFinishScope |
netcoreapp3.1 | 1.08μs | 6.15ns | 46.8ns | 0.00804 | 0 | 0 | 576 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 |
net472 | 1.27μs | 6.47ns | 30.4ns | 0.0842 | 0 | 0 | 538 B |
| master | RunOnMethodBegin |
netcoreapp3.1 | 1.26μs | 6.4ns | 29.3ns | 0.00794 | 0 | 0 | 576 B |
| #2638 | RunOnMethodBegin |
net472 | 1.3μs | 6.77ns | 41.7ns | 0.0843 | 0 | 0 | 538 B |
| #2638 | RunOnMethodBegin |
netcoreapp3.1 | 1.17μs | 3.92ns | 15.2ns | 0.00789 | 0 | 0 | 576 B |
Summary of changes
Update of the security component libddwaf to 1.3.0
Update of ruleset for waf to 1.3.0
Initialization code refactor to collect results from the waf new metrics
Added metrics and tags to appsec spans
Reason for change
Updating waf with new rules and new metrics
https://docs.google.com/document/d/1qBDsS_ZKeov226CPx2DneolxaARd66hUJJ5Lh9wjhlE/edit#heading=h.o5gstqo08gu5
New version also provides an embedded obfuscator
Implementation details
Cookies waf unit tests are skipped because they have been removed from the new rule sets
As we are mostly interested in testing integration with waf and rules and the whole cycle, we keep rule set 3.0 for integration tests as an injection rule has completely changed and is breaking the tests.
Test coverage
Added integration tests for waf initialization
Other details