Skip to content
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

[IAST] Lock vulnerabilities list access #6531

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

daniel-romano-DD
Copy link
Contributor

Summary of changes

Lock access to vulnerabilities list in VulnerabilityBatch

Reason for change

A crash has been reported where a vuln is added when serializing the VulnerabilityBatch

Implementation details

Add lock to Vulnerabilities list access

Test coverage

Other details

@daniel-romano-DD daniel-romano-DD requested a review from a team as a code owner January 13, 2025 09:28
@github-actions github-actions bot added the area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) label Jan 13, 2025
var ranges = vulnerability.Evidence?.Ranges;

if (ranges != null)
lock (Vulnerabilities)
Copy link
Member

Choose a reason for hiding this comment

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

It looks like there's lots more potential concurrency issues in this type🤔 For example, there's concurrent access to Sources which similarly could cause issues

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, but they only occur when adding a vulnerability when serializing, so covering both methods should be enough

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@andrewlock
Copy link
Member

andrewlock commented Jan 13, 2025

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 (6531) - mean (69ms)  : 65, 72
     .   : milestone, 69,
    master - mean (69ms)  : 66, 72
     .   : milestone, 69,

    section CallTarget+Inlining+NGEN
    This PR (6531) - mean (980ms)  : 959, 1002
     .   : milestone, 980,
    master - mean (975ms)  : 950, 1001
     .   : milestone, 975,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6531) - mean (107ms)  : 104, 111
     .   : milestone, 107,
    master - mean (108ms)  : 105, 110
     .   : milestone, 108,

    section CallTarget+Inlining+NGEN
    This PR (6531) - mean (678ms)  : 658, 699
     .   : milestone, 678,
    master - mean (679ms)  : 664, 694
     .   : milestone, 679,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6531) - mean (91ms)  : 88, 93
     .   : milestone, 91,
    master - mean (91ms)  : 90, 93
     .   : milestone, 91,

    section CallTarget+Inlining+NGEN
    This PR (6531) - mean (633ms)  : 617, 649
     .   : milestone, 633,
    master - mean (635ms)  : 619, 651
     .   : milestone, 635,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6531) - mean (190ms)  : 185, 195
     .   : milestone, 190,
    master - mean (194ms)  : 189, 198
     .   : milestone, 194,

    section CallTarget+Inlining+NGEN
    This PR (6531) - mean (1,092ms)  : 1057, 1127
     .   : milestone, 1092,
    master - mean (1,094ms)  : 1067, 1122
     .   : milestone, 1094,

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

    section CallTarget+Inlining+NGEN
    This PR (6531) - mean (867ms)  : 837, 897
     .   : milestone, 867,
    master - mean (871ms)  : 849, 892
     .   : milestone, 871,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6531) - mean (264ms)  : 260, 268
     .   : milestone, 264,
    master - mean (267ms)  : 263, 271
     .   : milestone, 267,

    section CallTarget+Inlining+NGEN
    This PR (6531) - mean (843ms)  : 813, 873
     .   : milestone, 843,
    master - mean (855ms)  : 820, 889
     .   : milestone, 855,

Loading

@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Jan 13, 2025

Datadog Report

Branch report: dani/iast/vulnbatch_lock
Commit report: b3fa46e
Test service: dd-trace-dotnet

✅ 0 Failed, 239672 Passed, 1978 Skipped, 18h 38m 10.94s Total Time

@andrewlock
Copy link
Member

andrewlock commented Jan 13, 2025

Benchmarks Report for appsec 🐌

Benchmarks for #6531 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.193
  • 1 benchmarks have fewer 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 204μs 117ns 405ns 2.66 0 0 188.76 KB
master AllCycleSimpleBody netcoreapp3.1 296μs 194ns 725ns 2.65 0 0 196.09 KB
master AllCycleSimpleBody net472 275μs 280ns 1.08μs 35.8 2.05 0 225.79 KB
master AllCycleMoreComplexBody net6.0 215μs 75.6ns 283ns 2.65 0 0 192.26 KB
master AllCycleMoreComplexBody netcoreapp3.1 315μs 174ns 672ns 2.67 0 0 199.51 KB
master AllCycleMoreComplexBody net472 276μs 192ns 745ns 36.3 2.06 0 229.3 KB
master ObjectExtractorSimpleBody net6.0 148ns 0.1ns 0.375ns 0.00396 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 196ns 0.206ns 0.77ns 0.00364 0 0 272 B
master ObjectExtractorSimpleBody net472 165ns 0.198ns 0.741ns 0.0446 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 2.91μs 1.78ns 6.68ns 0.0527 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 3.78μs 3.22ns 12ns 0.0509 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 3.68μs 2.09ns 7.55ns 0.602 0.00552 0 3.8 KB
#6531 AllCycleSimpleBody net6.0 204μs 280ns 1.05μs 2.66 0 0 188.76 KB
#6531 AllCycleSimpleBody netcoreapp3.1 303μs 64.5ns 232ns 2.59 0 0 196.09 KB
#6531 AllCycleSimpleBody net472 274μs 487ns 1.89μs 35.8 1.97 0 225.79 KB
#6531 AllCycleMoreComplexBody net6.0 218μs 118ns 424ns 2.69 0 0 192.26 KB
#6531 AllCycleMoreComplexBody netcoreapp3.1 322μs 126ns 454ns 2.76 0 0 199.51 KB
#6531 AllCycleMoreComplexBody net472 276μs 188ns 728ns 36.4 2.1 0 229.3 KB
#6531 ObjectExtractorSimpleBody net6.0 137ns 0.169ns 0.654ns 0.00392 0 0 280 B
#6531 ObjectExtractorSimpleBody netcoreapp3.1 192ns 0.142ns 0.53ns 0.00378 0 0 272 B
#6531 ObjectExtractorSimpleBody net472 165ns 0.16ns 0.618ns 0.0446 0 0 281 B
#6531 ObjectExtractorMoreComplexBody net6.0 2.85μs 1.6ns 5.76ns 0.053 0 0 3.78 KB
#6531 ObjectExtractorMoreComplexBody netcoreapp3.1 3.83μs 12.1ns 47.1ns 0.0507 0 0 3.69 KB
#6531 ObjectExtractorMoreComplexBody net472 3.75μs 4.18ns 15.1ns 0.603 0.00561 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 37.4μs 21.8ns 78.5ns 0.443 0 0 32.4 KB
master EncodeArgs netcoreapp3.1 53.9μs 29.2ns 113ns 0.43 0 0 32.4 KB
master EncodeArgs net472 65.9μs 56.3ns 211ns 5.14 0.0654 0 32.5 KB
master EncodeLegacyArgs net6.0 78μs 22.2ns 83.1ns 0 0 0 2.14 KB
master EncodeLegacyArgs netcoreapp3.1 109μs 382ns 1.48μs 0 0 0 2.14 KB
master EncodeLegacyArgs net472 153μs 135ns 522ns 0.306 0 0 2.15 KB
#6531 EncodeArgs net6.0 36.7μs 29.5ns 114ns 0.457 0 0 32.4 KB
#6531 EncodeArgs netcoreapp3.1 53.8μs 26.9ns 96.9ns 0.43 0 0 32.4 KB
#6531 EncodeArgs net472 66.8μs 105ns 408ns 5.14 0.0663 0 32.5 KB
#6531 EncodeLegacyArgs net6.0 79.3μs 150ns 581ns 0.0397 0 0 2.14 KB
#6531 EncodeLegacyArgs netcoreapp3.1 105μs 116ns 450ns 0 0 0 2.14 KB
#6531 EncodeLegacyArgs net472 154μs 56ns 209ns 0.309 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 176μs 118ns 458ns 0 0 0 2.44 KB
master RunWafRealisticBenchmark netcoreapp3.1 188μs 128ns 497ns 0 0 0 2.39 KB
master RunWafRealisticBenchmark net472 200μs 80.2ns 311ns 0.299 0 0 2.46 KB
master RunWafRealisticBenchmarkWithAttack net6.0 115μs 36.3ns 136ns 0 0 0 1.47 KB
master RunWafRealisticBenchmarkWithAttack netcoreapp3.1 123μs 212ns 794ns 0 0 0 1.46 KB
master RunWafRealisticBenchmarkWithAttack net472 134μs 54.8ns 212ns 0.2 0 0 1.49 KB
#6531 RunWafRealisticBenchmark net6.0 175μs 115ns 447ns 0 0 0 2.44 KB
#6531 RunWafRealisticBenchmark netcoreapp3.1 189μs 312ns 1.21μs 0 0 0 2.39 KB
#6531 RunWafRealisticBenchmark net472 199μs 61.7ns 231ns 0.297 0 0 2.46 KB
#6531 RunWafRealisticBenchmarkWithAttack net6.0 116μs 40.4ns 157ns 0 0 0 1.47 KB
#6531 RunWafRealisticBenchmarkWithAttack netcoreapp3.1 124μs 175ns 680ns 0 0 0 1.46 KB
#6531 RunWafRealisticBenchmarkWithAttack net472 132μs 42.2ns 152ns 0.198 0 0 1.49 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Faster 🎉 Fewer allocations 🎉

Faster 🎉 in #6531

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net6.0 1.193 61,100.00 51,200.00

Fewer allocations 🎉 in #6531

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 264.02 KB 254.88 KB -9.14 KB -3.46%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark net6.0 59.4μs 518ns 4.75μs 0 0 0 43.44 KB
master StringConcatBenchmark netcoreapp3.1 54μs 236ns 818ns 0 0 0 42.64 KB
master StringConcatBenchmark net472 38.5μs 174ns 651ns 0 0 0 59.07 KB
master StringConcatAspectBenchmark net6.0 308μs 1.36μs 5.11μs 0 0 0 264.02 KB
master StringConcatAspectBenchmark netcoreapp3.1 346μs 1.71μs 7.64μs 0 0 0 255.27 KB
master StringConcatAspectBenchmark net472 282μs 5.75μs 55.4μs 0 0 0 278.53 KB
#6531 StringConcatBenchmark net6.0 51.2μs 257ns 1.06μs 0 0 0 43.44 KB
#6531 StringConcatBenchmark netcoreapp3.1 53.6μs 275ns 1.26μs 0 0 0 42.64 KB
#6531 StringConcatBenchmark net472 37.8μs 171ns 641ns 0 0 0 59.07 KB
#6531 StringConcatAspectBenchmark net6.0 316μs 1.54μs 9.52μs 0 0 0 254.88 KB
#6531 StringConcatAspectBenchmark netcoreapp3.1 348μs 1.59μs 8.4μs 0 0 0 254.4 KB
#6531 StringConcatAspectBenchmark net472 280μs 5.47μs 51.6μs 0 0 0 278.53 KB

@andrewlock
Copy link
Member

Benchmarks Report for tracer 🐌

Benchmarks for #6531 compared to master:

  • 1 benchmarks are slower, with geometric mean 1.118
  • 1 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.ActivityBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 8.29μs 38.2ns 153ns 0.0165 0.00827 0 5.62 KB
master StartStopWithChild netcoreapp3.1 10.1μs 51ns 222ns 0.0147 0.00491 0 5.8 KB
master StartStopWithChild net472 16.4μs 44ns 170ns 1.04 0.299 0.097 6.21 KB
#6531 StartStopWithChild net6.0 7.86μs 42.7ns 260ns 0.0134 0.00447 0 5.61 KB
#6531 StartStopWithChild netcoreapp3.1 10.1μs 51.1ns 217ns 0.0254 0.0102 0 5.8 KB
#6531 StartStopWithChild net472 16.3μs 42.3ns 158ns 1.03 0.291 0.0889 6.21 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 490μs 248ns 927ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 665μs 358ns 1.39μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 858μs 570ns 2.21μs 0.428 0 0 3.3 KB
#6531 WriteAndFlushEnrichedTraces net6.0 480μs 338ns 1.31μs 0 0 0 2.7 KB
#6531 WriteAndFlushEnrichedTraces netcoreapp3.1 659μs 534ns 2.07μs 0 0 0 2.7 KB
#6531 WriteAndFlushEnrichedTraces net472 855μs 551ns 2.06μs 0.428 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 152μs 878ns 7.66μs 0.157 0 0 14.47 KB
master SendRequest netcoreapp3.1 173μs 1.04μs 10.3μs 0.162 0 0 17.27 KB
master SendRequest net472 0.0047ns 0.00128ns 0.00479ns 0 0 0 0 b
#6531 SendRequest net6.0 153μs 935ns 9.16μs 0.141 0 0 14.47 KB
#6531 SendRequest netcoreapp3.1 170μs 1.03μs 10.2μs 0.183 0 0 17.27 KB
#6531 SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #6531

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net6.0 41.43 KB 41.64 KB 209 B 0.50%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 580μs 2.98μs 14.3μs 0.598 0 0 41.43 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 657μs 2.64μs 9.87μs 0.347 0 0 41.79 KB
master WriteAndFlushEnrichedTraces net472 829μs 3.27μs 12.7μs 8.33 2.5 0.417 53.28 KB
#6531 WriteAndFlushEnrichedTraces net6.0 566μs 1.58μs 5.93μs 0.563 0 0 41.64 KB
#6531 WriteAndFlushEnrichedTraces netcoreapp3.1 651μs 2.84μs 12.1μs 0.334 0 0 41.63 KB
#6531 WriteAndFlushEnrichedTraces net472 852μs 4.11μs 15.9μs 8.28 2.48 0.414 53.27 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.3μs 1.56ns 6.04ns 0.0143 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.83μs 4ns 15.5ns 0.0136 0 0 1.02 KB
master ExecuteNonQuery net472 2.12μs 2.29ns 8.88ns 0.157 0.00105 0 987 B
#6531 ExecuteNonQuery net6.0 1.19μs 1.21ns 4.68ns 0.0143 0 0 1.02 KB
#6531 ExecuteNonQuery netcoreapp3.1 1.71μs 1.18ns 4.58ns 0.0136 0 0 1.02 KB
#6531 ExecuteNonQuery net472 2.13μs 1.59ns 5.95ns 0.157 0.00106 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.28μs 0.577ns 2.23ns 0.0134 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.52μs 1.07ns 4.01ns 0.0129 0 0 976 B
master CallElasticsearch net472 2.68μs 2.19ns 8.48ns 0.157 0 0 995 B
master CallElasticsearchAsync net6.0 1.33μs 0.617ns 2.22ns 0.0132 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.64μs 2.92ns 11.3ns 0.0141 0 0 1.02 KB
master CallElasticsearchAsync net472 2.6μs 1.7ns 6.34ns 0.166 0 0 1.05 KB
#6531 CallElasticsearch net6.0 1.19μs 1.4ns 5.22ns 0.0138 0 0 976 B
#6531 CallElasticsearch netcoreapp3.1 1.48μs 4.04ns 15.7ns 0.0132 0 0 976 B
#6531 CallElasticsearch net472 2.53μs 1.83ns 7.09ns 0.157 0 0 995 B
#6531 CallElasticsearchAsync net6.0 1.27μs 0.571ns 2.21ns 0.0133 0 0 952 B
#6531 CallElasticsearchAsync netcoreapp3.1 1.65μs 0.612ns 2.29ns 0.0141 0 0 1.02 KB
#6531 CallElasticsearchAsync net472 2.6μs 1.63ns 6.08ns 0.166 0 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.32μs 1.08ns 4.04ns 0.0133 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.74μs 0.99ns 3.83ns 0.0128 0 0 952 B
master ExecuteAsync net472 1.79μs 0.376ns 1.46ns 0.145 0 0 915 B
#6531 ExecuteAsync net6.0 1.3μs 0.612ns 2.29ns 0.0131 0 0 952 B
#6531 ExecuteAsync netcoreapp3.1 1.58μs 0.709ns 2.75ns 0.0129 0 0 952 B
#6531 ExecuteAsync net472 1.86μs 0.34ns 1.27ns 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.41μs 1.7ns 6.6ns 0.0308 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.24μs 2.83ns 11ns 0.0394 0 0 2.85 KB
master SendAsync net472 7.34μs 1.84ns 7.11ns 0.492 0 0 3.12 KB
#6531 SendAsync net6.0 4.39μs 1.78ns 6.65ns 0.031 0 0 2.31 KB
#6531 SendAsync netcoreapp3.1 5.31μs 1.76ns 6.81ns 0.0373 0 0 2.85 KB
#6531 SendAsync net472 7.43μs 1.49ns 5.56ns 0.495 0 0 3.12 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.46μs 0.863ns 3.34ns 0.0227 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.27μs 1.14ns 4.25ns 0.0216 0 0 1.64 KB
master EnrichedLog net472 2.72μs 1.54ns 5.56ns 0.249 0 0 1.57 KB
#6531 EnrichedLog net6.0 1.5μs 0.849ns 3.18ns 0.023 0 0 1.64 KB
#6531 EnrichedLog netcoreapp3.1 2.34μs 1.35ns 5.05ns 0.0223 0 0 1.64 KB
#6531 EnrichedLog net472 2.71μs 1.12ns 4.2ns 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 121μs 95ns 368ns 0.0602 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 119μs 147ns 530ns 0.0599 0 0 4.28 KB
master EnrichedLog net472 151μs 321ns 1.24μs 0.671 0.224 0 4.46 KB
#6531 EnrichedLog net6.0 117μs 387ns 1.45μs 0.0581 0 0 4.28 KB
#6531 EnrichedLog netcoreapp3.1 122μs 103ns 400ns 0 0 0 4.28 KB
#6531 EnrichedLog net472 151μs 262ns 1.02μs 0.678 0.226 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.11μs 0.716ns 2.77ns 0.0299 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.18μs 2.14ns 8.31ns 0.0292 0 0 2.2 KB
master EnrichedLog net472 5.06μs 1.46ns 5.66ns 0.32 0 0 2.02 KB
#6531 EnrichedLog net6.0 2.91μs 0.784ns 3.04ns 0.0305 0 0 2.2 KB
#6531 EnrichedLog netcoreapp3.1 4.26μs 1.72ns 6.42ns 0.0298 0 0 2.2 KB
#6531 EnrichedLog net472 5.03μs 0.825ns 3.09ns 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.39μs 0.997ns 3.86ns 0.0163 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.76μs 1.22ns 4.4ns 0.0158 0 0 1.14 KB
master SendReceive net472 2.1μs 0.779ns 2.91ns 0.184 0 0 1.16 KB
#6531 SendReceive net6.0 1.26μs 1.52ns 5.87ns 0.0162 0 0 1.14 KB
#6531 SendReceive netcoreapp3.1 1.77μs 1.34ns 5.21ns 0.0151 0 0 1.14 KB
#6531 SendReceive net472 2.07μs 1.4ns 5.41ns 0.183 0 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.79μs 0.541ns 1.95ns 0.0222 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.85μs 1.78ns 6.91ns 0.0212 0 0 1.65 KB
master EnrichedLog net472 4.3μs 2.32ns 8.98ns 0.322 0 0 2.04 KB
#6531 EnrichedLog net6.0 2.81μs 0.881ns 3.3ns 0.0225 0 0 1.6 KB
#6531 EnrichedLog netcoreapp3.1 3.85μs 4.05ns 15.7ns 0.0211 0 0 1.65 KB
#6531 EnrichedLog net472 4.27μs 3.57ns 13.8ns 0.322 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6531

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑netcoreapp3.1 1.118 686.72 767.58

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 403ns 0.294ns 1.14ns 0.0081 0 0 576 B
master StartFinishSpan netcoreapp3.1 569ns 0.401ns 1.5ns 0.00769 0 0 576 B
master StartFinishSpan net472 710ns 0.553ns 2.14ns 0.0917 0 0 578 B
master StartFinishScope net6.0 541ns 0.262ns 1.02ns 0.00972 0 0 696 B
master StartFinishScope netcoreapp3.1 686ns 0.527ns 2.04ns 0.00938 0 0 696 B
master StartFinishScope net472 927ns 0.39ns 1.46ns 0.105 0 0 658 B
#6531 StartFinishSpan net6.0 397ns 0.172ns 0.643ns 0.00801 0 0 576 B
#6531 StartFinishSpan netcoreapp3.1 560ns 0.606ns 2.19ns 0.00782 0 0 576 B
#6531 StartFinishSpan net472 676ns 0.195ns 0.755ns 0.0917 0 0 578 B
#6531 StartFinishScope net6.0 488ns 0.407ns 1.57ns 0.00976 0 0 696 B
#6531 StartFinishScope netcoreapp3.1 768ns 0.458ns 1.77ns 0.00931 0 0 696 B
#6531 StartFinishScope net472 841ns 0.336ns 1.21ns 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 654ns 0.525ns 2.03ns 0.00982 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 873ns 0.651ns 2.52ns 0.00942 0 0 696 B
master RunOnMethodBegin net472 1.12μs 0.706ns 2.73ns 0.104 0 0 658 B
#6531 RunOnMethodBegin net6.0 593ns 0.307ns 1.19ns 0.00978 0 0 696 B
#6531 RunOnMethodBegin netcoreapp3.1 963ns 0.603ns 2.33ns 0.00925 0 0 696 B
#6531 RunOnMethodBegin net472 1.17μs 0.568ns 2.13ns 0.104 0 0 658 B

@daniel-romano-DD daniel-romano-DD force-pushed the dani/iast/vulnbatch_lock branch from 8356b1f to 688f6cf Compare January 14, 2025 10:42
Copy link
Member

@andrewlock andrewlock left a comment

Choose a reason for hiding this comment

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

Ad discussed, I think this type is inherently unsafe as it exposes public, mutable, non-thread-safe properties while also mutating them internally. The type isn't thread safe, yet it is used across threads.

There are probably some small fixes we can do to reduce the risk here, like exposing non-mutable collections at least.

Copy link
Member

@robertpi robertpi left a comment

Choose a reason for hiding this comment

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

This good, but agree with Andrew's comment that there's probably more to do.

Cover the whole json generation

Covered ToMessagePack

Covered the rest of vulnerable methods

Increased safety

Fix test
@daniel-romano-DD daniel-romano-DD force-pushed the dani/iast/vulnbatch_lock branch from fbf9d9c to b3fa46e Compare January 15, 2025 09:32
@daniel-romano-DD daniel-romano-DD merged commit a700b56 into master Jan 15, 2025
125 of 128 checks passed
@daniel-romano-DD daniel-romano-DD deleted the dani/iast/vulnbatch_lock branch January 15, 2025 14:48
@github-actions github-actions bot added this to the vNext-v3 milestone Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:asm-iast area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) type:bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants