Skip to content

[ASM] Appsec events in meta struct#5779

Merged
e-n-0 merged 4 commits into
masterfrom
flavien/asm/meta_struct_triggers
Jul 17, 2024
Merged

[ASM] Appsec events in meta struct#5779
e-n-0 merged 4 commits into
masterfrom
flavien/asm/meta_struct_triggers

Conversation

@e-n-0

@e-n-0 e-n-0 commented Jul 8, 2024

Copy link
Copy Markdown
Member

Summary of changes

Move appsec event data from the _dd.appsec.json tag to a messagepack-encoded data serialized into meta struct.
RFC Linked to that change.

Implementation details

  • Check for meta struct compatibility with the connected agent
  • Fallback to json serialization if not supported

Reason for change

Better performance.

Test coverage

  • By default, now the mocked trace agent is set to support meta struct, so all appsec events will be set on meta struct
  • To keep all existing snapshots unchanged, meta struct appsec events are set back as json on the same tag into snapshots
  • Add a new option in the test: "forceMetaStruct". When enabled, the tag _dd.appsec.json.metastruct.test is set when appsec events from metastruct are serialized back to json. This is to be sure that meta struct is used in the test.

@andrewlock

andrewlock commented Jul 8, 2024

Copy link
Copy Markdown
Member

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:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

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 (5779) - mean (76ms)  : 67, 84
     .   : milestone, 76,
    master - mean (75ms)  : 64, 87
     .   : milestone, 75,

    section CallTarget+Inlining+NGEN
    This PR (5779) - mean (1,047ms)  : 1024, 1070
     .   : milestone, 1047,
    master - mean (1,048ms)  : 1030, 1067
     .   : milestone, 1048,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5779) - mean (112ms)  : 109, 115
     .   : milestone, 112,
    master - mean (112ms)  : 108, 116
     .   : milestone, 112,

    section CallTarget+Inlining+NGEN
    This PR (5779) - mean (737ms)  : 713, 762
     .   : milestone, 737,
    master - mean (735ms)  : 713, 756
     .   : milestone, 735,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5779) - mean (93ms)  : 91, 96
     .   : milestone, 93,
    master - mean (95ms)  : 92, 98
     .   : milestone, 95,

    section CallTarget+Inlining+NGEN
    This PR (5779) - mean (684ms)  : 661, 708
     .   : milestone, 684,
    master - mean (688ms)  : 661, 716
     .   : milestone, 688,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5779) - mean (192ms)  : 189, 196
     .   : milestone, 192,
    master - mean (192ms)  : 187, 196
     .   : milestone, 192,

    section CallTarget+Inlining+NGEN
    This PR (5779) - mean (1,156ms)  : 1136, 1177
     .   : milestone, 1156,
    master - mean (1,160ms)  : 1140, 1180
     .   : milestone, 1160,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5779) - mean (277ms)  : 274, 281
     .   : milestone, 277,
    master - mean (277ms)  : 273, 281
     .   : milestone, 277,

    section CallTarget+Inlining+NGEN
    This PR (5779) - mean (939ms)  : 917, 962
     .   : milestone, 939,
    master - mean (949ms)  : 930, 967
     .   : milestone, 949,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5779) - mean (265ms)  : 259, 271
     .   : milestone, 265,
    master - mean (265ms)  : 260, 269
     .   : milestone, 265,

    section CallTarget+Inlining+NGEN
    This PR (5779) - mean (914ms)  : 891, 937
     .   : milestone, 914,
    master - mean (922ms)  : 902, 941
     .   : milestone, 922,

Loading

@datadog-ddstaging

datadog-ddstaging Bot commented Jul 8, 2024

Copy link
Copy Markdown

Datadog Report

Branch report: flavien/asm/meta_struct_triggers
Commit report: 847f2a5
Test service: dd-trace-dotnet

✅ 0 Failed, 349036 Passed, 1752 Skipped, 15h 11m 26.68s Total Time

@andrewlock

andrewlock commented Jul 8, 2024

Copy link
Copy Markdown
Member

Benchmarks Report for tracer 🐌

Benchmarks for #5779 compared to master:

  • All benchmarks have the same speed
  • All benchmarks have the same allocations

The following thresholds were used for comparing the benchmark speeds:

  • Mann–Whitney U test with statistical test for significance of 5%
  • Only results indicating a difference greater than 10% and 0.3 ns are considered.

Allocation changes below 0.5% are ignored.

Benchmark details

Benchmarks.Trace.ActivityBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 7.59μs 42.9ns 300ns 0.0155 0.00775 0 5.43 KB
master StartStopWithChild netcoreapp3.1 9.66μs 50.7ns 243ns 0.019 0.00476 0 5.62 KB
master StartStopWithChild net472 16μs 58.1ns 225ns 1.03 0.321 0.094 6.08 KB
#5779 StartStopWithChild net6.0 7.57μs 43ns 307ns 0.0145 0.00724 0 5.43 KB
#5779 StartStopWithChild netcoreapp3.1 10.1μs 54ns 291ns 0.0201 0.0101 0 5.62 KB
#5779 StartStopWithChild net472 16.1μs 40.5ns 157ns 1.01 0.288 0.088 6.07 KB
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 473μs 300ns 1.16μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 645μs 241ns 902ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 833μs 599ns 2.32μs 0.419 0 0 3.3 KB
#5779 WriteAndFlushEnrichedTraces net6.0 471μs 104ns 388ns 0 0 0 2.7 KB
#5779 WriteAndFlushEnrichedTraces netcoreapp3.1 627μs 127ns 493ns 0 0 0 2.7 KB
#5779 WriteAndFlushEnrichedTraces net472 840μs 487ns 1.89μs 0.417 0 0 3.3 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 net6.0 173μs 260ns 1.01μs 0.261 0 0 18.45 KB
master SendRequest netcoreapp3.1 192μs 355ns 1.37μs 0.193 0 0 20.61 KB
master SendRequest net472 0.00151ns 0.000154ns 0.000576ns 0 0 0 0 b
#5779 SendRequest net6.0 172μs 219ns 848ns 0.256 0 0 18.45 KB
#5779 SendRequest netcoreapp3.1 193μs 308ns 1.15μs 0.191 0 0 20.61 KB
#5779 SendRequest net472 4.29E‑05ns 4.29E‑05ns 0.000155ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 560μs 238ns 922ns 0.563 0 0 41.69 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 666μs 1.33μs 5.13μs 0.336 0 0 41.76 KB
master WriteAndFlushEnrichedTraces net472 836μs 2.08μs 7.79μs 8.28 2.48 0.414 53.24 KB
#5779 WriteAndFlushEnrichedTraces net6.0 548μs 1.07μs 4.15μs 0.563 0 0 41.75 KB
#5779 WriteAndFlushEnrichedTraces netcoreapp3.1 650μs 426ns 1.65μs 0.324 0 0 41.79 KB
#5779 WriteAndFlushEnrichedTraces net472 826μs 4.04μs 16.6μs 8.08 2.55 0.425 53.22 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 net6.0 1.16μs 0.356ns 1.38ns 0.0144 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.65μs 0.901ns 3.49ns 0.0132 0 0 1.02 KB
master ExecuteNonQuery net472 1.96μs 0.471ns 1.76ns 0.157 0 0 987 B
#5779 ExecuteNonQuery net6.0 1.15μs 0.765ns 2.96ns 0.0145 0 0 1.02 KB
#5779 ExecuteNonQuery netcoreapp3.1 1.65μs 1.46ns 5.65ns 0.0139 0 0 1.02 KB
#5779 ExecuteNonQuery net472 1.91μs 1.52ns 5.48ns 0.156 0 0 987 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 net6.0 1.1μs 0.326ns 1.26ns 0.0138 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.53μs 0.711ns 2.66ns 0.0129 0 0 976 B
master CallElasticsearch net472 2.54μs 0.929ns 3.48ns 0.157 0 0 995 B
master CallElasticsearchAsync net6.0 1.25μs 0.999ns 3.74ns 0.0131 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.63μs 0.691ns 2.68ns 0.0131 0 0 1.02 KB
master CallElasticsearchAsync net472 2.67μs 1.16ns 4.51ns 0.167 0 0 1.05 KB
#5779 CallElasticsearch net6.0 1.12μs 0.517ns 1.93ns 0.0135 0 0 976 B
#5779 CallElasticsearch netcoreapp3.1 1.56μs 0.78ns 2.81ns 0.0133 0 0 976 B
#5779 CallElasticsearch net472 2.58μs 1.81ns 7.03ns 0.158 0.00129 0 995 B
#5779 CallElasticsearchAsync net6.0 1.2μs 0.313ns 1.17ns 0.0133 0 0 952 B
#5779 CallElasticsearchAsync netcoreapp3.1 1.57μs 2.25ns 7.79ns 0.0141 0 0 1.02 KB
#5779 CallElasticsearchAsync net472 2.57μs 3.49ns 13.5ns 0.167 0.00128 0 1.05 KB
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net6.0 1.37μs 0.692ns 2.49ns 0.0131 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.56μs 1ns 3.6ns 0.0126 0 0 952 B
master ExecuteAsync net472 1.83μs 0.835ns 3.12ns 0.145 0 0 915 B
#5779 ExecuteAsync net6.0 1.29μs 0.787ns 3.05ns 0.0135 0 0 952 B
#5779 ExecuteAsync netcoreapp3.1 1.57μs 0.868ns 3.13ns 0.0124 0 0 952 B
#5779 ExecuteAsync net472 1.85μs 2.12ns 8.2ns 0.145 0 0 915 B
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net6.0 4.17μs 1.36ns 5.08ns 0.0311 0 0 2.22 KB
master SendAsync netcoreapp3.1 5.11μs 2.17ns 8.39ns 0.0356 0 0 2.76 KB
master SendAsync net472 7.9μs 1.23ns 4.75ns 0.496 0 0 3.15 KB
#5779 SendAsync net6.0 4.06μs 1.68ns 6.29ns 0.0305 0 0 2.22 KB
#5779 SendAsync netcoreapp3.1 5.16μs 3.4ns 13.2ns 0.0361 0 0 2.76 KB
#5779 SendAsync net472 7.84μs 1.8ns 6.96ns 0.499 0 0 3.15 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 net6.0 1.42μs 0.433ns 1.56ns 0.0228 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.26μs 0.907ns 3.4ns 0.0214 0 0 1.64 KB
master EnrichedLog net472 2.5μs 2.17ns 8.39ns 0.249 0 0 1.57 KB
#5779 EnrichedLog net6.0 1.55μs 0.618ns 2.23ns 0.0226 0 0 1.64 KB
#5779 EnrichedLog netcoreapp3.1 2.22μs 1.05ns 3.94ns 0.0222 0 0 1.64 KB
#5779 EnrichedLog net472 2.61μs 2.23ns 8.65ns 0.249 0 0 1.57 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 net6.0 116μs 240ns 930ns 0.0578 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 120μs 233ns 903ns 0 0 0 4.28 KB
master EnrichedLog net472 149μs 223ns 866ns 0.677 0.226 0 4.46 KB
#5779 EnrichedLog net6.0 114μs 166ns 622ns 0.0577 0 0 4.28 KB
#5779 EnrichedLog netcoreapp3.1 118μs 368ns 1.38μs 0.0584 0 0 4.28 KB
#5779 EnrichedLog net472 150μs 92.7ns 359ns 0.675 0.225 0 4.46 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 net6.0 3.18μs 1.21ns 4.69ns 0.0302 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.11μs 1.88ns 7.27ns 0.0296 0 0 2.2 KB
master EnrichedLog net472 4.98μs 1.39ns 5.4ns 0.319 0 0 2.02 KB
#5779 EnrichedLog net6.0 3.01μs 0.457ns 1.65ns 0.0309 0 0 2.2 KB
#5779 EnrichedLog netcoreapp3.1 4.23μs 1.75ns 6.77ns 0.0294 0 0 2.2 KB
#5779 EnrichedLog net472 4.91μs 12.7ns 49ns 0.32 0 0 2.02 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 net6.0 1.27μs 0.478ns 1.79ns 0.0164 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.73μs 0.663ns 2.48ns 0.0156 0 0 1.14 KB
master SendReceive net472 2.11μs 1.39ns 5.22ns 0.183 0 0 1.16 KB
#5779 SendReceive net6.0 1.3μs 0.571ns 2.21ns 0.0157 0 0 1.14 KB
#5779 SendReceive netcoreapp3.1 1.7μs 0.483ns 1.81ns 0.0156 0 0 1.14 KB
#5779 SendReceive net472 2.04μs 0.802ns 3.11ns 0.184 0.00101 0 1.16 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 net6.0 2.7μs 0.658ns 2.28ns 0.0217 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.78μs 0.902ns 3.49ns 0.0208 0 0 1.65 KB
master EnrichedLog net472 4.27μs 2.28ns 8.54ns 0.323 0 0 2.04 KB
#5779 EnrichedLog net6.0 2.71μs 0.792ns 2.96ns 0.0219 0 0 1.6 KB
#5779 EnrichedLog netcoreapp3.1 3.95μs 1.52ns 5.9ns 0.0219 0 0 1.65 KB
#5779 EnrichedLog net472 4.4μs 2.54ns 9.83ns 0.323 0 0 2.04 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 net6.0 393ns 0.0869ns 0.325ns 0.00799 0 0 576 B
master StartFinishSpan netcoreapp3.1 548ns 0.131ns 0.472ns 0.00775 0 0 576 B
master StartFinishSpan net472 713ns 0.868ns 3.36ns 0.0915 0 0 578 B
master StartFinishScope net6.0 478ns 0.119ns 0.462ns 0.00982 0 0 696 B
master StartFinishScope netcoreapp3.1 698ns 0.676ns 2.44ns 0.00963 0 0 696 B
master StartFinishScope net472 875ns 0.381ns 1.48ns 0.104 0 0 658 B
#5779 StartFinishSpan net6.0 397ns 0.13ns 0.505ns 0.00801 0 0 576 B
#5779 StartFinishSpan netcoreapp3.1 568ns 0.198ns 0.74ns 0.00769 0 0 576 B
#5779 StartFinishSpan net472 695ns 0.36ns 1.4ns 0.0918 0 0 578 B
#5779 StartFinishScope net6.0 474ns 0.127ns 0.494ns 0.00971 0 0 696 B
#5779 StartFinishScope netcoreapp3.1 699ns 0.232ns 0.868ns 0.00928 0 0 696 B
#5779 StartFinishScope net472 937ns 0.207ns 0.801ns 0.104 0 0 658 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 652ns 0.244ns 0.945ns 0.0098 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 864ns 0.517ns 1.93ns 0.00924 0 0 696 B
master RunOnMethodBegin net472 1.06μs 0.552ns 2.14ns 0.104 0 0 658 B
#5779 RunOnMethodBegin net6.0 649ns 0.218ns 0.843ns 0.00981 0 0 696 B
#5779 RunOnMethodBegin netcoreapp3.1 858ns 0.559ns 2.02ns 0.0093 0 0 696 B
#5779 RunOnMethodBegin net472 1.06μs 0.239ns 0.925ns 0.104 0 0 658 B

@andrewlock

andrewlock commented Jul 8, 2024

Copy link
Copy Markdown
Member

Benchmarks Report for appsec 🐌

Benchmarks for #5779 compared to master:

  • All benchmarks have the same speed
  • 2 benchmarks have more allocations

The following thresholds were used for comparing the benchmark speeds:

  • Mann–Whitney U test with statistical test for significance of 5%
  • Only results indicating a difference greater than 10% and 0.3 ns are considered.

Allocation changes below 0.5% are ignored.

Benchmark details

Benchmarks.Trace.Asm.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master AllCycleSimpleBody net6.0 72.4μs 94.5ns 354ns 0.0724 0 0 6.01 KB
master AllCycleSimpleBody netcoreapp3.1 61.8μs 102ns 395ns 0.0931 0 0 6.95 KB
master AllCycleSimpleBody net472 48.5μs 57.1ns 221ns 1.3 0 0 8.34 KB
master AllCycleMoreComplexBody net6.0 78.8μs 93.4ns 362ns 0.117 0 0 9.51 KB
master AllCycleMoreComplexBody netcoreapp3.1 69.9μs 89.1ns 345ns 0.105 0 0 10.36 KB
master AllCycleMoreComplexBody net472 55.8μs 45.6ns 171ns 1.87 0.0279 0 11.85 KB
master ObjectExtractorSimpleBody net6.0 141ns 0.155ns 0.601ns 0.00391 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 202ns 0.162ns 0.606ns 0.00378 0 0 272 B
master ObjectExtractorSimpleBody net472 164ns 0.109ns 0.409ns 0.0446 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 3.13μs 1.55ns 5.78ns 0.0529 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 3.98μs 7.22ns 28ns 0.0516 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 4.11μs 3.75ns 13.5ns 0.601 0.00614 0 3.8 KB
#5779 AllCycleSimpleBody net6.0 73.8μs 82ns 318ns 0.0741 0 0 6.01 KB
#5779 AllCycleSimpleBody netcoreapp3.1 63.1μs 50.1ns 194ns 0.0946 0 0 6.95 KB
#5779 AllCycleSimpleBody net472 49μs 37.8ns 146ns 1.32 0 0 8.34 KB
#5779 AllCycleMoreComplexBody net6.0 77.5μs 101ns 376ns 0.116 0 0 9.51 KB
#5779 AllCycleMoreComplexBody netcoreapp3.1 68.4μs 76.8ns 298ns 0.136 0 0 10.37 KB
#5779 AllCycleMoreComplexBody net472 56.7μs 37.1ns 139ns 1.87 0.0283 0 11.85 KB
#5779 ObjectExtractorSimpleBody net6.0 140ns 0.209ns 0.809ns 0.00391 0 0 280 B
#5779 ObjectExtractorSimpleBody netcoreapp3.1 213ns 0.302ns 1.17ns 0.00374 0 0 272 B
#5779 ObjectExtractorSimpleBody net472 165ns 0.151ns 0.584ns 0.0446 0 0 281 B
#5779 ObjectExtractorMoreComplexBody net6.0 2.97μs 2.39ns 8.61ns 0.0534 0 0 3.78 KB
#5779 ObjectExtractorMoreComplexBody netcoreapp3.1 3.99μs 4.01ns 15.5ns 0.0494 0 0 3.69 KB
#5779 ObjectExtractorMoreComplexBody net472 4.08μs 3.79ns 14.2ns 0.602 0.00612 0 3.8 KB
Benchmarks.Trace.Asm.AppSecEncoderBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EncodeArgs net6.0 39μs 12.8ns 48.1ns 0.451 0 0 32.4 KB
master EncodeArgs netcoreapp3.1 54μs 23.9ns 92.7ns 0.431 0 0 32.4 KB
master EncodeArgs net472 65.6μs 48.7ns 189ns 5.15 0.0652 0 32.5 KB
master EncodeLegacyArgs net6.0 71μs 15.7ns 54.5ns 0 0 0 2.14 KB
master EncodeLegacyArgs netcoreapp3.1 109μs 90.9ns 352ns 0 0 0 2.15 KB
master EncodeLegacyArgs net472 152μs 53.3ns 206ns 0.304 0 0 2.15 KB
#5779 EncodeArgs net6.0 37.4μs 21.6ns 83.6ns 0.463 0 0 32.4 KB
#5779 EncodeArgs netcoreapp3.1 54.3μs 28ns 108ns 0.431 0 0 32.4 KB
#5779 EncodeArgs net472 65.2μs 54.4ns 211ns 5.16 0.0649 0 32.5 KB
#5779 EncodeLegacyArgs net6.0 76.5μs 405ns 2.06μs 0 0 0 2.14 KB
#5779 EncodeLegacyArgs netcoreapp3.1 105μs 230ns 892ns 0 0 0 2.14 KB
#5779 EncodeLegacyArgs net472 151μs 64.2ns 249ns 0.302 0 0 2.15 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 185μs 249ns 965ns 0 0 0 2.42 KB
master RunWafRealisticBenchmark netcoreapp3.1 192μs 210ns 786ns 0 0 0 2.37 KB
master RunWafRealisticBenchmark net472 206μs 49.3ns 191ns 0.309 0 0 2.43 KB
master RunWafRealisticBenchmarkWithAttack net6.0 122μs 110ns 411ns 0 0 0 1.46 KB
master RunWafRealisticBenchmarkWithAttack netcoreapp3.1 129μs 33.6ns 121ns 0 0 0 1.45 KB
master RunWafRealisticBenchmarkWithAttack net472 140μs 36.9ns 138ns 0.209 0 0 1.48 KB
#5779 RunWafRealisticBenchmark net6.0 180μs 105ns 407ns 0 0 0 2.42 KB
#5779 RunWafRealisticBenchmark netcoreapp3.1 194μs 236ns 915ns 0 0 0 2.37 KB
#5779 RunWafRealisticBenchmark net472 207μs 59.3ns 222ns 0.31 0 0 2.43 KB
#5779 RunWafRealisticBenchmarkWithAttack net6.0 122μs 89.7ns 347ns 0 0 0 1.46 KB
#5779 RunWafRealisticBenchmarkWithAttack netcoreapp3.1 128μs 57.7ns 216ns 0 0 0 1.45 KB
#5779 RunWafRealisticBenchmarkWithAttack net472 139μs 118ns 440ns 0.207 0 0 1.48 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #5779

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472 59.14 KB 60.5 KB 1.35 KB 2.29%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 254.48 KB 256.98 KB 2.5 KB 0.98%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark net6.0 58.9μs 660ns 6.57μs 0 0 0 43.44 KB
master StringConcatBenchmark netcoreapp3.1 67.4μs 921ns 9.02μs 0 0 0 42.64 KB
master StringConcatBenchmark net472 37.5μs 70.1ns 262ns 0 0 0 59.14 KB
master StringConcatAspectBenchmark net6.0 302μs 1.58μs 10.1μs 0 0 0 254.48 KB
master StringConcatAspectBenchmark netcoreapp3.1 340μs 1.76μs 11.4μs 0 0 0 264.91 KB
master StringConcatAspectBenchmark net472 303μs 7.78μs 75.1μs 0 0 0 278.53 KB
#5779 StringConcatBenchmark net6.0 53.7μs 293ns 1.74μs 0 0 0 43.44 KB
#5779 StringConcatBenchmark netcoreapp3.1 60μs 688ns 6.74μs 0 0 0 42.64 KB
#5779 StringConcatBenchmark net472 38.9μs 203ns 1.04μs 0 0 0 60.5 KB
#5779 StringConcatAspectBenchmark net6.0 313μs 1.68μs 11.6μs 0 0 0 256.98 KB
#5779 StringConcatAspectBenchmark netcoreapp3.1 348μs 1.86μs 11.6μs 0 0 0 263.6 KB
#5779 StringConcatAspectBenchmark net472 289μs 6.6μs 63μs 0 0 0 278.53 KB

@e-n-0
e-n-0 force-pushed the flavien/asm/meta_struct_triggers branch from fc5a80e to 61584be Compare July 9, 2024 16:00
@e-n-0
e-n-0 force-pushed the flavien/asm/meta_struct_triggers branch from 61584be to 0bfd1fb Compare July 11, 2024 16:39
@github-actions

Copy link
Copy Markdown
Contributor

Snapshots difference summary

The following differences have been observed in committed snapshots. It is meant to help the reviewer.
The diff is simplistic, so please check some files anyway while we improve it.

8 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"rasp-001-001","name":"Path traversal attack","tags":{"category":"vulnerability_trigger","type":"lfi"}},"rule_matches":[{"operator":"lfi_detector","operator_value":"","parameters":[{"address":null,"highlight":["/etc/password"],"key_path":null,"value":null}]}],"span_id": XXX}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"rasp-001-001","name":"Path traversal attack","tags":{"category":"vulnerability_trigger","type":"lfi"}},"rule_matches":[{"operator":"lfi_detector","operator_value":"","parameters":[{"address":null,"highlight":["/etc/password"],"key_path":null,"value":null}]}],"span_id": XXX}]},

12 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"rasp-002-001","name":"Server-side request forgery","tags":{"category":"vulnerability_trigger","type":"ssrf"}},"rule_matches":[{"operator":"ssrf_detector","operator_value":"","parameters":[{"address":null,"highlight":["127.0.0.1"],"key_path":null,"value":null}]}],"span_id": XXX}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"rasp-002-001","name":"Server-side request forgery","tags":{"category":"vulnerability_trigger","type":"ssrf"}},"rule_matches":[{"operator":"ssrf_detector","operator_value":"","parameters":[{"address":null,"highlight":["127.0.0.1"],"key_path":null,"value":null}]}],"span_id": XXX}]},

8 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"rasp-942-100","name":"SQL injection exploit","tags":{"category":"vulnerability_trigger","type":"sql_injection"}},"rule_matches":[{"operator":"sqli_detector","operator_value":"","parameters":[{"address":null,"highlight":["' or '1'='1"],"key_path":null,"value":null}]}],"span_id": XXX}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"rasp-942-100","name":"SQL injection exploit","tags":{"category":"vulnerability_trigger","type":"sql_injection"}},"rule_matches":[{"operator":"sqli_detector","operator_value":"","parameters":[{"address":null,"highlight":["' or '1'='1"],"key_path":null,"value":null}]}],"span_id": XXX}]},

4 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-932-160","name":"Remote Command Execution: Unix Shell Code Found","tags":{"category":"attack_attempt","type":"command_injection"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.body","highlight":["dev/zero"],"key_path":["Property"],"value":"dev/zero"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-932-160","name":"Remote Command Execution: Unix Shell Code Found","tags":{"category":"attack_attempt","type":"command_injection"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.body","highlight":["dev/zero"],"key_path":["Property"],"value":"dev/zero"}]}]}]},

40 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"ublock","name":"Hello","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"match_regex","operator_value":"hello","parameters":[{"address":"server.request.headers.no_cookies","highlight":["hello"],"key_path":["user-agent","0"],"value":"mistake not... hello/v"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"ublock","name":"Hello","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"match_regex","operator_value":"hello","parameters":[{"address":"server.request.headers.no_cookies","highlight":["hello"],"key_path":["user-agent","0"],"value":"mistake not... hello/v"}]}]}]},

10 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"nfd-000-001","name":"Detect common directory discovery scans","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"match_regex","operator_value":"^404$","parameters":[{"address":"server.response.status","highlight":["404"],"key_path":[],"value":"404"}]},{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.uri.raw","highlight":["/login.php"],"key_path":[],"value":"/health/login.php"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"nfd-000-001","name":"Detect common directory discovery scans","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"match_regex","operator_value":"^404$","parameters":[{"address":"server.response.status","highlight":["404"],"key_path":[],"value":"404"}]},{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.uri.raw","highlight":["/login.php"],"key_path":[],"value":"/health/login.php"}]}]}]},

10 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"test-dummy-rule","name":"Dummy rule to test blocking","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.body","highlight":["dummy_rule"],"key_path":["Property2"],"value":"dummy_rule"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"test-dummy-rule","name":"Dummy rule to test blocking","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.body","highlight":["dummy_rule"],"key_path":["Property2"],"value":"dummy_rule"}]}]}]},

20 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"test-dummy-rule","name":"Dummy rule to test blocking","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.body","highlight":["dummy_rule"],"key_path":["Property"],"value":"dummy_rule"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"test-dummy-rule","name":"Dummy rule to test blocking","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.body","highlight":["dummy_rule"],"key_path":["Property"],"value":"dummy_rule"}]}]}]},

60 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-913-120","name":"Known security scanner filename/argument","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.path_params","highlight":["appscan_fingerprint"],"key_path":["id"],"value":"appscan_fingerprint"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-913-120","name":"Known security scanner filename/argument","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.path_params","highlight":["appscan_fingerprint"],"key_path":["id"],"value":"appscan_fingerprint"}]}]}]},

31 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[?\\$(?:(?:s(?:lic|iz)|wher)e|e(?:lemMatch|xists|q)|n(?:o[rt]|in?|e)|l(?:ike|te?)|t(?:ext|ype)|a(?:ll|nd)|jsonSchema|between|regex|x?or|div|mod)\\]?)\\b)","parameters":[{"address":"server.request.query","highlight":["[$slice"],"key_path":["[$slice]"],"value":"[$slice]"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[?\\$(?:(?:s(?:lic|iz)|wher)e|e(?:lemMatch|xists|q)|n(?:o[rt]|in?|e)|l(?:ike|te?)|t(?:ext|ype)|a(?:ll|nd)|jsonSchema|between|regex|x?or|div|mod)\\]?)\\b)","parameters":[{"address":"server.request.query","highlight":["[$slice"],"key_path":["[$slice]"],"value":"[$slice]"}]}]}]},

10 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[?\\$(?:(?:s(?:lic|iz)|wher)e|e(?:lemMatch|xists|q)|n(?:o[rt]|in?|e)|l(?:ike|te?)|t(?:ext|ype)|a(?:ll|nd)|jsonSchema|between|regex|x?or|div|mod)\\]?)\\b)","parameters":[{"address":"server.request.query","highlight":["[$slice"],"key_path":["[$slice]"],"value":"[$slice]"}]}]},{"rule":{"id":"crs-913-120","name":"Known security scanner filename/argument","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.path_params","highlight":["appscan_fingerprint"],"key_path":["id"],"value":"appscan_fingerprint"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[?\\$(?:(?:s(?:lic|iz)|wher)e|e(?:lemMatch|xists|q)|n(?:o[rt]|in?|e)|l(?:ike|te?)|t(?:ext|ype)|a(?:ll|nd)|jsonSchema|between|regex|x?or|div|mod)\\]?)\\b)","parameters":[{"address":"server.request.query","highlight":["[$slice"],"key_path":["[$slice]"],"value":"[$slice]"}]}]},{"rule":{"id":"crs-913-120","name":"Known security scanner filename/argument","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.path_params","highlight":["appscan_fingerprint"],"key_path":["id"],"value":"appscan_fingerprint"}]}]}]},

10 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"tst-037-011","name":"No fun","tags":{"category":"attack_attempt","type":"lfi"}},"rule_matches":[{"operator":"match_regex","operator_value":"fun","parameters":[{"address":"server.request.uri.raw","highlight":["fun"],"key_path":[],"value":"/health?q=fun"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"tst-037-011","name":"No fun","tags":{"category":"attack_attempt","type":"lfi"}},"rule_matches":[{"operator":"match_regex","operator_value":"fun","parameters":[{"address":"server.request.uri.raw","highlight":["fun"],"key_path":[],"value":"/health?q=fun"}]}]}]},

20 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"tst-037-009","name":"Test block on response header","tags":{"category":"attack_attempt","type":"lfi"}},"rule_matches":[{"operator":"match_regex","operator_value":"en-us|krypton","parameters":[{"address":"server.response.headers.no_cookies","highlight":["krypton"],"key_path":["content-language","0"],"value":"krypton"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"tst-037-009","name":"Test block on response header","tags":{"category":"attack_attempt","type":"lfi"}},"rule_matches":[{"operator":"match_regex","operator_value":"en-us|krypton","parameters":[{"address":"server.response.headers.no_cookies","highlight":["krypton"],"key_path":["content-language","0"],"value":"krypton"}]}]}]},

10 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"tst-037-010","name":"No teapot","tags":{"category":"attack_attempt","type":"lfi"}},"rule_matches":[{"operator":"match_regex","operator_value":"418","parameters":[{"address":"server.response.status","highlight":["418"],"key_path":[],"value":"418"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"tst-037-010","name":"No teapot","tags":{"category":"attack_attempt","type":"lfi"}},"rule_matches":[{"operator":"match_regex","operator_value":"418","parameters":[{"address":"server.response.status","highlight":["418"],"key_path":[],"value":"418"}]}]}]},

5 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-913-120","name":"Known security scanner filename/argument","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.path_params","highlight":["appscan_fingerprint"],"key_path":["s"],"value":"appscan_fingerprint"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-913-120","name":"Known security scanner filename/argument","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.path_params","highlight":["appscan_fingerprint"],"key_path":["s"],"value":"appscan_fingerprint"}]}]}]},

4 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"test-dummy-rule-custom-block","name":"Dummy rule to test blocking with a custom action","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.query","highlight":["dummy_custom_action"],"key_path":["arg","0"],"value":"dummy_custom_action"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"test-dummy-rule-custom-block","name":"Dummy rule to test blocking with a custom action","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.query","highlight":["dummy_custom_action"],"key_path":["arg","0"],"value":"dummy_custom_action"}]}]}]},

12 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"test-dummy-rule","name":"Dummy rule to test blocking","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.query","highlight":["dummy_rule"],"key_path":["arg","0"],"value":"dummy_rule"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"test-dummy-rule","name":"Dummy rule to test blocking","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.query","highlight":["dummy_rule"],"key_path":["arg","0"],"value":"dummy_rule"}]}]}]},

1 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"test_custom_rule","name":"Test custom rule","tags":{"category":"attack_attempt","type":"custom_rule"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.query","highlight":["customrule"],"key_path":["arg","0"],"value":"customrule_trigger"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"test_custom_rule","name":"Test custom rule","tags":{"category":"attack_attempt","type":"custom_rule"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.query","highlight":["customrule"],"key_path":["arg","0"],"value":"customrule_trigger"}]}]}]},

9 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"blk-001-001","name":"Block IP Addresses","tags":{"category":"security_response","type":"block_ip"}},"rule_matches":[{"operator":"ip_match","operator_value":"","parameters":[{"address":"http.client_ip","highlight":["86.242.244.246"],"key_path":[],"value":"86.242.244.246"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"blk-001-001","name":"Block IP Addresses","tags":{"category":"security_response","type":"block_ip"}},"rule_matches":[{"operator":"ip_match","operator_value":"","parameters":[{"address":"http.client_ip","highlight":["86.242.244.246"],"key_path":[],"value":"86.242.244.246"}]}]}]},

7 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"blk-001-002","name":"Block User Addresses","tags":{"category":"security_response","type":"block_user"}},"rule_matches":[{"operator":"exact_match","operator_value":"","parameters":[{"address":"usr.id","highlight":["user3"],"key_path":[],"value":"user3"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"blk-001-002","name":"Block User Addresses","tags":{"category":"security_response","type":"block_user"}},"rule_matches":[{"operator":"exact_match","operator_value":"","parameters":[{"address":"usr.id","highlight":["user3"],"key_path":[],"value":"user3"}]}]}]},

1 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.query","highlight":["[$slice]"],"key_path":["[$slice]"],"value":"[$slice]"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.query","highlight":["[$slice]"],"key_path":["[$slice]"],"value":"[$slice]"}]}]}]},

2 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-942-290-new","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.query","highlight":["[$slice]"],"key_path":["[$slice]"],"value":"[$slice]"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-942-290-new","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.query","highlight":["[$slice]"],"key_path":["[$slice]"],"value":"[$slice]"}]}]}]},

55 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.query","highlight":["[$slice]"],"key_path":["arg","0"],"value":"[$slice]"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.query","highlight":["[$slice]"],"key_path":["arg","0"],"value":"[$slice]"}]}]}]},

15 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.query","highlight":["[$slice]"],"key_path":["param","0"],"value":"[$slice]"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.query","highlight":["[$slice]"],"key_path":["param","0"],"value":"[$slice]"}]}]}]},

4 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-932-160","name":"Remote Command Execution: Unix Shell Code Found","tags":{"category":"attack_attempt","type":"command_injection"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.body","highlight":["dev/zero"],"key_path":["model","Dog2"],"value":"dev/zero"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-932-160","name":"Remote Command Execution: Unix Shell Code Found","tags":{"category":"attack_attempt","type":"command_injection"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.body","highlight":["dev/zero"],"key_path":["model","Dog2"],"value":"dev/zero"}]}]}]},

10 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.body","highlight":["[$slice]"],"key_path":["miscModel","DictionaryProperty","a"],"value":"[$slice]"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.body","highlight":["[$slice]"],"key_path":["miscModel","DictionaryProperty","a"],"value":"[$slice]"}]}]}]},

35 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.body","highlight":["[$slice]"],"key_path":["miscModel","Property1"],"value":"[$slice]"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.body","highlight":["[$slice]"],"key_path":["miscModel","Property1"],"value":"[$slice]"}]}]}]},

5 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"nfd-000-001","name":"Detect common directory discovery scans","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"match_regex","operator_value":"^404$","parameters":[{"address":"server.response.status","highlight":["404"],"key_path":[],"value":"404"}]},{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.uri.raw","highlight":["/wp-config"],"key_path":[],"value":"/health/wp-config"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"nfd-000-001","name":"Detect common directory discovery scans","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"match_regex","operator_value":"^404$","parameters":[{"address":"server.response.status","highlight":["404"],"key_path":[],"value":"404"}]},{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.uri.raw","highlight":["/wp-config"],"key_path":[],"value":"/health/wp-config"}]}]}]},

6 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"ua0-600-16x","name":"SQL power injector","tags":{"category":"attack_attempt","type":"attack_tool"}},"rule_matches":[{"operator":"match_regex","operator_value":"sql power injector","parameters":[{"address":"server.request.headers.no_cookies","highlight":["sql power injector"],"key_path":["user-agent","0"],"value":"Mistake Not... (sql power injector)"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"ua0-600-16x","name":"SQL power injector","tags":{"category":"attack_attempt","type":"attack_tool"}},"rule_matches":[{"operator":"match_regex","operator_value":"sql power injector","parameters":[{"address":"server.request.headers.no_cookies","highlight":["sql power injector"],"key_path":["user-agent","0"],"value":"Mistake Not... (sql power injector)"}]}]}]},

4 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-913-120","name":"Known security scanner filename/argument","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.path_params","highlight":["appscan_fingerprint"],"key_path":["pathparam2"],"value":"appscan_fingerprint"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-913-120","name":"Known security scanner filename/argument","tags":{"category":"attack_attempt","type":"security_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.path_params","highlight":["appscan_fingerprint"],"key_path":["pathparam2"],"value":"appscan_fingerprint"}]}]}]},

5 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.query","highlight":["[$slice]"],"key_path":[0,1],"value":"[$slice]"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.query","highlight":["[$slice]"],"key_path":[0,1],"value":"[$slice]"}]}]}]},

10 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.body","highlight":["[$slice]"],"key_path":["ctl00$MainContent$testBox"],"value":"[$slice]"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-942-290","name":"Finds basic MongoDB SQL injection attempts","tags":{"category":"attack_attempt","type":"nosql_injection"}},"rule_matches":[{"operator":"match_regex","operator_value":"(?i:(?:\\[\\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and)\\]))","parameters":[{"address":"server.request.body","highlight":["[$slice]"],"key_path":["ctl00$MainContent$testBox"],"value":"[$slice]"}]}]}]},

3 occurrences of :

-      _dd.appsec.json: {"triggers":[{"rule":{"id":"crs-913-110","name":"Acunetix","tags":{"category":"attack_attempt","type":"commercial_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.headers.no_cookies","highlight":["acunetix-product"],"key_path":["user-agent","0"],"value":"mistake not... acunetix-product"}]}]}]},
+      _dd.appsec.meta-struct.test: {"triggers":[{"rule":{"id":"crs-913-110","name":"Acunetix","tags":{"category":"attack_attempt","type":"commercial_scanner"}},"rule_matches":[{"operator":"phrase_match","operator_value":"","parameters":[{"address":"server.request.headers.no_cookies","highlight":["acunetix-product"],"key_path":["user-agent","0"],"value":"mistake not... acunetix-product"}]}]}]},

@e-n-0
e-n-0 force-pushed the flavien/asm/meta_struct_triggers branch 3 times, most recently from 312e670 to dd3a2cf Compare July 15, 2024 12:29
@e-n-0
e-n-0 force-pushed the flavien/asm/meta_struct_triggers branch from dd3a2cf to 252f1f8 Compare July 15, 2024 15:54
@e-n-0
e-n-0 marked this pull request as ready for review July 15, 2024 16:02
@e-n-0
e-n-0 requested review from a team as code owners July 15, 2024 16:02
Comment thread tracer/src/Datadog.Trace/AppSec/Rasp/MetaStructHelper.cs Outdated
@andrewlock

Copy link
Copy Markdown
Member

Throughput/Crank Report:zap:

Throughput results for AspNetCoreSimpleController comparing the following branches/commits:

Cases where throughput results for the PR are worse than latest master (5% drop or greater), results are shown in red.

Note that these results are based on a single point-in-time result for each branch. For full results, see one of the many, many dashboards!

gantt
    title Throughput Linux x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5779) (11.499M)   : 0, 11498508
    master (11.579M)   : 0, 11579356
    benchmarks/2.9.0 (11.793M)   : 0, 11792634

    section Automatic
    This PR (5779) (7.746M)   : 0, 7745797
    master (7.775M)   : 0, 7774636
    benchmarks/2.9.0 (8.209M)   : 0, 8209122

    section Trace stats
    master (8.206M)   : 0, 8205782

    section Manual
    This PR (5779) (10.030M)   : 0, 10029958
    master (10.090M)   : 0, 10090249

    section Manual + Automatic
    This PR (5779) (7.316M)   : 0, 7315588
    master (7.416M)   : 0, 7415620

    section Version Conflict
    master (6.677M)   : 0, 6676535

Loading
gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5779) (9.629M)   : 0, 9629118

    section Automatic
    This PR (5779) (6.451M)   : 0, 6450673

    section Manual
    This PR (5779) (8.356M)   : 0, 8356047

    section Manual + Automatic
    This PR (5779) (6.273M)   : 0, 6273305

Loading
gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5779) (10.115M)   : 0, 10115417
    master (10.110M)   : 0, 10109641
    benchmarks/2.9.0 (10.296M)   : 0, 10295769

    section Automatic
    This PR (5779) (7.116M)   : 0, 7115999
    master (7.224M)   : 0, 7223553
    benchmarks/2.9.0 (7.267M)   : 0, 7266503

    section Trace stats
    master (7.632M)   : 0, 7631517

    section Manual
    This PR (5779) (8.708M)   : 0, 8707786
    master (8.931M)   : 0, 8930758

    section Manual + Automatic
    This PR (5779) (6.742M)   : 0, 6741748
    master (6.943M)   : 0, 6943118

    section Version Conflict
    master (6.220M)   : 0, 6220018

Loading

@GreenMatan GreenMatan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed Debugger's side of things, looking good

@e-n-0
e-n-0 requested a review from lucaspimentel July 16, 2024 10:50
// Fallback to the _dd.appsec.json tag
if (Security.Instance.IsMetaStructSupported())
{
span.SetMetaStruct(AppsecKey, MetaStructHelper.ObjectToByteArray(new Dictionary<string, List<object>> { { "triggers", _wafSecurityEvents } }));

@lucaspimentel lucaspimentel Jul 16, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not something you want to do in this PR, but maybe in the future we should probably try to move this MessagePack/JSON serialization into the background thread we already use to serialize spans, instead of blocking the web request.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep that's will be even better. It will be part of another PR 😄

Comment thread tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetBase.cs

@dromanol dromanol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job

@e-n-0
e-n-0 merged commit 19a64ac into master Jul 17, 2024
@e-n-0
e-n-0 deleted the flavien/asm/meta_struct_triggers branch July 17, 2024 14:43
@github-actions github-actions Bot added this to the vNext-v2 milestone Jul 17, 2024
e-n-0 added a commit that referenced this pull request Dec 3, 2024
## Summary of changes

Move iast data from the `_dd.iast.json` tag to a messagepack-encoded
data serialized into meta struct.
[RFC Linked to that
change.](https://docs.google.com/document/d/1iWQsOfT6Lg_IFyvQeqry9wVmXOE2Yav0X4MgOTk7mks/)

- Added a new telemetry tag `_dd.iast.metastruct.size.exceeded` to
reflect the exceeded size for meta struct when a truncation occured

## Reason for change

Better performance.

## Implementation details

- Check for meta struct compatibility with the connected agent
- Fallback to json serialization if not supported

## Test coverage

- By default, now the mocked trace agent is set to support meta struct
(cf #5779), so all iast events will be set in meta struct
- To keep all existing snapshots unchanged, meta struct iast events are
set back as json on the same tag into snapshots
- Add a new option in the iast test: "forceMetaStruct". When enabled,
the tag `_dd.iast.json.metastruct.test` is set when iast data from
metastruct is serialized back to json. This is to be sure that meta
struct is used in the test.
- Updated all unit tests of Vulnerability Batch to also use the meta
struct serialization
- New test for the telemetry tag `_dd.iast.metastruct.size.exceeded`

## Other details
<!-- Fixes #{issue} -->

<!-- ⚠️ Note: where possible, please obtain 2 approvals prior to
merging. Unless CODEOWNERS specifies otherwise, for external teams it is
typically best to have one review from a team member, and one review
from apm-dotnet. Trivial changes do not require 2 reviews. -->
veerbia pushed a commit that referenced this pull request Dec 16, 2024
## Summary of changes

Move iast data from the `_dd.iast.json` tag to a messagepack-encoded
data serialized into meta struct.
[RFC Linked to that
change.](https://docs.google.com/document/d/1iWQsOfT6Lg_IFyvQeqry9wVmXOE2Yav0X4MgOTk7mks/)

- Added a new telemetry tag `_dd.iast.metastruct.size.exceeded` to
reflect the exceeded size for meta struct when a truncation occured

## Reason for change

Better performance.

## Implementation details

- Check for meta struct compatibility with the connected agent
- Fallback to json serialization if not supported

## Test coverage

- By default, now the mocked trace agent is set to support meta struct
(cf #5779), so all iast events will be set in meta struct
- To keep all existing snapshots unchanged, meta struct iast events are
set back as json on the same tag into snapshots
- Add a new option in the iast test: "forceMetaStruct". When enabled,
the tag `_dd.iast.json.metastruct.test` is set when iast data from
metastruct is serialized back to json. This is to be sure that meta
struct is used in the test.
- Updated all unit tests of Vulnerability Batch to also use the meta
struct serialization
- New test for the telemetry tag `_dd.iast.metastruct.size.exceeded`

## Other details
<!-- Fixes #{issue} -->

<!-- ⚠️ Note: where possible, please obtain 2 approvals prior to
merging. Unless CODEOWNERS specifies otherwise, for external teams it is
typically best to have one review from a team member, and one review
from apm-dotnet. Trivial changes do not require 2 reviews. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants