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] Remove safe origin ranges #6091

Merged
merged 6 commits into from
Sep 27, 2024

Conversation

daniel-romano-DD
Copy link
Contributor

@daniel-romano-DD daniel-romano-DD commented Sep 26, 2024

Summary of changes

Remove ranges from safe origins from vulnerability evidence

Reason for change

Until now, only ranges marked with a secure mark were removed from evidence, but ranges from safe sources (like database values in non XSS or SQLi injections) were being sent.

SecureMarks are marks added to a range that indicates that it has been sanitized (and thus, secured) for that vulnerability.
In the same manner, there some origins that do not apply to certain vulnerabilities, like database values not applying in injection but XSS and SQLi. So in these cases, those ranges should be removed from the evidence.

Implementation details

Filter ranges by source as well as by secure marks

Test coverage

Unit and integration tests

Other details

@daniel-romano-DD daniel-romano-DD force-pushed the dani/iast/remove_safe_origin_ranges branch from b269cad to fec2738 Compare September 27, 2024 07:44
Copy link
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.

1 occurrences of :

-            "value": "<script language='javascript' type='text/javascript'>alert('Stored XSS attack');</script>",
-            "source": 1
-          },
-          {
-            "value": ":443/api/v1/test/123/?param1=pone&param2=ptwo#fragment1=fone&fragment2=ftwo"
+            "value": "<script language='javascript' type='text/javascript'>alert('Stored XSS attack');</script>:443/api/v1/test/123/?param1=pone&param2=ptwo#fragment1=fone&fragment2=ftwo"

1 occurrences of :

-    },
-    {
-      "origin": "sql.row.value",
-      "name": "Details",
-      "value": "<script language='javascript' type='text/javascript'>alert('Stored XSS attack');</script>"

@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Sep 27, 2024

Datadog Report

Branch report: dani/iast/remove_safe_origin_ranges
Commit report: 7ec617a
Test service: dd-trace-dotnet

✅ 0 Failed, 366220 Passed, 2062 Skipped, 16h 7m 10.51s Total Time

@andrewlock
Copy link
Member

andrewlock commented Sep 27, 2024

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 (6091) - mean (70ms)  : 67, 73
     .   : milestone, 70,
    master - mean (70ms)  : 67, 73
     .   : milestone, 70,

    section CallTarget+Inlining+NGEN
    This PR (6091) - mean (1,106ms)  : 1084, 1127
     .   : milestone, 1106,
    master - mean (1,100ms)  : 1084, 1117
     .   : milestone, 1100,

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

    section CallTarget+Inlining+NGEN
    This PR (6091) - mean (770ms)  : 753, 786
     .   : milestone, 770,
    master - mean (768ms)  : 747, 789
     .   : milestone, 768,

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

    section CallTarget+Inlining+NGEN
    This PR (6091) - mean (724ms)  : 708, 740
     .   : milestone, 724,
    master - mean (730ms)  : 715, 746
     .   : milestone, 730,

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

    section CallTarget+Inlining+NGEN
    This PR (6091) - mean (1,194ms)  : 1173, 1214
     .   : milestone, 1194,
    master - mean (1,198ms)  : 1169, 1227
     .   : milestone, 1198,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6091) - mean (276ms)  : 270, 281
     .   : milestone, 276,
    master - mean (276ms)  : 272, 280
     .   : milestone, 276,

    section CallTarget+Inlining+NGEN
    This PR (6091) - mean (935ms)  : 920, 951
     .   : milestone, 935,
    master - mean (942ms)  : 923, 961
     .   : milestone, 942,

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

    section CallTarget+Inlining+NGEN
    This PR (6091) - mean (925ms)  : 907, 944
     .   : milestone, 925,
    master - mean (926ms)  : 905, 947
     .   : milestone, 926,

Loading

@daniel-romano-DD daniel-romano-DD marked this pull request as ready for review September 27, 2024 08:26
@daniel-romano-DD daniel-romano-DD requested a review from a team as a code owner September 27, 2024 08:26
tracer/src/Datadog.Trace/Iast/Range.cs Show resolved Hide resolved
tracer/src/Datadog.Trace/Iast/IastModule.cs Outdated Show resolved Hide resolved
tracer/src/Datadog.Trace/Iast/IastModule.cs Show resolved Hide resolved
Comment on lines 234 to 246
List<Range> insecureRanges = new List<Range>(ranges.Length);
for (int x = 0; x < ranges.Length; x++)
{
var range = ranges[x];
if (range.IsMarked(safeMarks) || range.IsSafeSource(safeSources))
{
continue;
}

insecureRanges.Add(range);
}

return insecureRanges.ToArray();
Copy link
Member

Choose a reason for hiding this comment

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

If you want to reduce allocations here, you could

  • In the previous for loop, don't break early. Just count the number of unsafe ranges.
  • Instead of using a list, allocate the Range[] with the correct size.

Might actually be easier to follow too, but it's just a nit 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was torn between reducing allocations and not checking twice here...

daniel-romano-DD and others added 2 commits September 27, 2024 10:55
Co-authored-by: Andrew Lock <andrew.lock@datadoghq.com>
Co-authored-by: Andrew Lock <andrew.lock@datadoghq.com>
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.

Thanks!

@@ -10,3 +10,5 @@
#if NETFRAMEWORK || NETSTANDARD2_0
global using Datadog.Trace.VendoredMicrosoftCode.System;
#endif

global using Datadog.Trace.ExtensionMethods;
Copy link
Member

Choose a reason for hiding this comment

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

😈

// This is made in order to avoid unnecessary allocations (most common situation)
return ranges;
}

Copy link
Member

Choose a reason for hiding this comment

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

nit: could also cater to the easy one:

Suggested change
if (insecureCount == 0)
{
return [];
}

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

@@ -206,22 +207,42 @@ internal static Range[] CopyWithMark(Range[] ranges, SecureMarks secureMarks)
return newRanges.ToArray();
}

internal static bool ContainsUnsafeRange(IEnumerable<Range>? ranges)
internal static Range[]? GetUnsafeRanges(Range[] ranges, SecureMarks safeMarks, SourceType[]? safeSources)
Copy link
Member

Choose a reason for hiding this comment

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

I think this always returns non null?

Suggested change
internal static Range[]? GetUnsafeRanges(Range[] ranges, SecureMarks safeMarks, SourceType[]? safeSources)
internal static Range[] GetUnsafeRanges(Range[] ranges, SecureMarks safeMarks, SourceType[]? safeSources)

@andrewlock
Copy link
Member

Benchmarks Report for appsec 🐌

Benchmarks for #6091 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.248
  • 3 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 - Faster 🎉 Same allocations ✔️

Faster 🎉 in #6091

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody‑net472 1.248 4,815.74 3,860.15

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master AllCycleSimpleBody net6.0 72μs 162ns 626ns 0.0719 0 0 6 KB
master AllCycleSimpleBody netcoreapp3.1 61.9μs 95.1ns 368ns 0.0925 0 0 6.95 KB
master AllCycleSimpleBody net472 48.3μs 66.1ns 256ns 1.31 0 0 8.34 KB
master AllCycleMoreComplexBody net6.0 77.8μs 91ns 352ns 0.117 0 0 9.51 KB
master AllCycleMoreComplexBody netcoreapp3.1 69.7μs 76.4ns 286ns 0.104 0 0 10.36 KB
master AllCycleMoreComplexBody net472 55.3μs 49ns 177ns 1.88 0.0276 0 11.85 KB
master ObjectExtractorSimpleBody net6.0 143ns 0.674ns 2.61ns 0.00392 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 205ns 0.187ns 0.726ns 0.00371 0 0 272 B
master ObjectExtractorSimpleBody net472 178ns 0.172ns 0.645ns 0.0446 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 3.09μs 0.961ns 3.72ns 0.0527 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 3.84μs 1.43ns 5.52ns 0.0499 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 4.82μs 1.38ns 5.35ns 0.601 0.00481 0 3.8 KB
#6091 AllCycleSimpleBody net6.0 72μs 127ns 490ns 0.0723 0 0 6 KB
#6091 AllCycleSimpleBody netcoreapp3.1 61.3μs 68ns 254ns 0.0919 0 0 6.95 KB
#6091 AllCycleSimpleBody net472 49μs 100ns 388ns 1.31 0 0 8.34 KB
#6091 AllCycleMoreComplexBody net6.0 76.8μs 54ns 209ns 0.116 0 0 9.51 KB
#6091 AllCycleMoreComplexBody netcoreapp3.1 68.5μs 85.4ns 331ns 0.138 0 0 10.36 KB
#6091 AllCycleMoreComplexBody net472 56.5μs 32.7ns 127ns 1.87 0.0283 0 11.85 KB
#6091 ObjectExtractorSimpleBody net6.0 140ns 0.204ns 0.788ns 0.00397 0 0 280 B
#6091 ObjectExtractorSimpleBody netcoreapp3.1 204ns 0.214ns 0.829ns 0.0037 0 0 272 B
#6091 ObjectExtractorSimpleBody net472 162ns 0.243ns 0.942ns 0.0446 0 0 281 B
#6091 ObjectExtractorMoreComplexBody net6.0 3.04μs 1.91ns 7.14ns 0.0532 0 0 3.78 KB
#6091 ObjectExtractorMoreComplexBody netcoreapp3.1 4μs 2.62ns 10.1ns 0.05 0 0 3.69 KB
#6091 ObjectExtractorMoreComplexBody net472 3.86μs 1.81ns 6.53ns 0.603 0.00578 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μs 23.2ns 89.9ns 0.446 0 0 32.4 KB
master EncodeArgs netcoreapp3.1 53.5μs 9.82ns 35.4ns 0.429 0 0 32.4 KB
master EncodeArgs net472 66μs 31.5ns 122ns 5.16 0.0661 0 32.5 KB
master EncodeLegacyArgs net6.0 76.5μs 73.4ns 275ns 0 0 0 2.14 KB
master EncodeLegacyArgs netcoreapp3.1 108μs 73ns 273ns 0 0 0 2.14 KB
master EncodeLegacyArgs net472 152μs 83.2ns 311ns 0.302 0 0 2.15 KB
#6091 EncodeArgs net6.0 36.8μs 30ns 116ns 0.454 0 0 32.4 KB
#6091 EncodeArgs netcoreapp3.1 54.3μs 24.1ns 86.9ns 0.431 0 0 32.4 KB
#6091 EncodeArgs net472 65.7μs 24.6ns 92.2ns 5.14 0.0655 0 32.5 KB
#6091 EncodeLegacyArgs net6.0 74.6μs 44ns 171ns 0 0 0 2.14 KB
#6091 EncodeLegacyArgs netcoreapp3.1 104μs 98.5ns 382ns 0 0 0 2.15 KB
#6091 EncodeLegacyArgs net472 151μs 88ns 341ns 0.301 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 186μs 132ns 511ns 0 0 0 2.44 KB
master RunWafRealisticBenchmark netcoreapp3.1 195μs 197ns 762ns 0 0 0 2.39 KB
master RunWafRealisticBenchmark net472 208μs 42.7ns 165ns 0.311 0 0 2.46 KB
master RunWafRealisticBenchmarkWithAttack net6.0 122μs 36ns 125ns 0 0 0 1.47 KB
master RunWafRealisticBenchmarkWithAttack netcoreapp3.1 130μs 80.6ns 312ns 0 0 0 1.46 KB
master RunWafRealisticBenchmarkWithAttack net472 139μs 30.9ns 120ns 0.208 0 0 1.49 KB
#6091 RunWafRealisticBenchmark net6.0 185μs 106ns 382ns 0 0 0 2.44 KB
#6091 RunWafRealisticBenchmark netcoreapp3.1 199μs 109ns 406ns 0 0 0 2.39 KB
#6091 RunWafRealisticBenchmark net472 208μs 215ns 834ns 0.31 0 0 2.46 KB
#6091 RunWafRealisticBenchmarkWithAttack net6.0 122μs 40.2ns 156ns 0 0 0 1.47 KB
#6091 RunWafRealisticBenchmarkWithAttack netcoreapp3.1 129μs 101ns 379ns 0 0 0 1.46 KB
#6091 RunWafRealisticBenchmarkWithAttack net472 138μs 38ns 142ns 0.207 0 0 1.49 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ Fewer allocations 🎉

Fewer allocations 🎉 in #6091

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 256.8 KB 253.27 KB -3.53 KB -1.37%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net472 286.72 KB 278.53 KB -8.19 KB -2.86%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 264.59 KB 253.53 KB -11.06 KB -4.18%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark net6.0 51μs 189ns 707ns 0 0 0 43.44 KB
master StringConcatBenchmark netcoreapp3.1 61.1μs 865ns 8.65μs 0 0 0 42.64 KB
master StringConcatBenchmark net472 37μs 79.5ns 297ns 0 0 0 59.07 KB
master StringConcatAspectBenchmark net6.0 321μs 1E+03ns 3.61μs 0 0 0 256.8 KB
master StringConcatAspectBenchmark netcoreapp3.1 343μs 1.94μs 13.4μs 0 0 0 264.59 KB
master StringConcatAspectBenchmark net472 282μs 7.54μs 73.1μs 0 0 0 286.72 KB
#6091 StringConcatBenchmark net6.0 59.6μs 743ns 7.4μs 0 0 0 43.44 KB
#6091 StringConcatBenchmark netcoreapp3.1 52.8μs 253ns 1.16μs 0 0 0 42.64 KB
#6091 StringConcatBenchmark net472 36.8μs 58.2ns 210ns 0 0 0 59.14 KB
#6091 StringConcatAspectBenchmark net6.0 281μs 5.51μs 54.3μs 0 0 0 253.27 KB
#6091 StringConcatAspectBenchmark netcoreapp3.1 335μs 1.61μs 6.65μs 0 0 0 253.53 KB
#6091 StringConcatAspectBenchmark net472 274μs 5.72μs 56.4μs 0 0 0 278.53 KB

@andrewlock
Copy link
Member

Benchmarks Report for tracer 🐌

Benchmarks for #6091 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.131
  • 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.53μs 42.2ns 277ns 0.0151 0.00753 0 5.42 KB
master StartStopWithChild netcoreapp3.1 9.92μs 56.6ns 404ns 0.0191 0.00954 0 5.62 KB
master StartStopWithChild net472 16μs 60.5ns 234ns 1.02 0.294 0.0953 6.06 KB
#6091 StartStopWithChild net6.0 7.54μs 35.7ns 182ns 0.0118 0.00393 0 5.43 KB
#6091 StartStopWithChild netcoreapp3.1 10.1μs 52.9ns 322ns 0.0198 0.00495 0 5.62 KB
#6091 StartStopWithChild net472 15.9μs 39.8ns 149ns 1.02 0.299 0.0945 6.06 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 469μs 485ns 1.88μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 647μs 255ns 988ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 832μs 592ns 2.29μs 0.414 0 0 3.3 KB
#6091 WriteAndFlushEnrichedTraces net6.0 479μs 311ns 1.16μs 0 0 0 2.7 KB
#6091 WriteAndFlushEnrichedTraces netcoreapp3.1 642μs 318ns 1.23μs 0 0 0 2.7 KB
#6091 WriteAndFlushEnrichedTraces net472 835μs 520ns 2.01μ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 188μs 1.03μs 5.94μs 0.179 0 0 18.45 KB
master SendRequest netcoreapp3.1 215μs 1.21μs 8.31μs 0.207 0 0 20.61 KB
master SendRequest net472 0.00165ns 0.000752ns 0.00291ns 0 0 0 0 b
#6091 SendRequest net6.0 194μs 1.08μs 6.8μs 0.186 0 0 18.45 KB
#6091 SendRequest netcoreapp3.1 221μs 1.25μs 8.99μs 0.21 0 0 20.61 KB
#6091 SendRequest net472 0.00159ns 0.000558ns 0.00209ns 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 567μs 1.83μs 6.6μs 0.568 0 0 41.57 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 685μs 3.8μs 24.6μs 0.338 0 0 41.75 KB
master WriteAndFlushEnrichedTraces net472 867μs 3.69μs 14.3μs 8.19 2.59 0.431 53.25 KB
#6091 WriteAndFlushEnrichedTraces net6.0 554μs 2.61μs 11.1μs 0.546 0 0 41.45 KB
#6091 WriteAndFlushEnrichedTraces netcoreapp3.1 678μs 3.32μs 13.3μs 0.332 0 0 41.86 KB
#6091 WriteAndFlushEnrichedTraces net472 869μs 3.29μs 12.3μs 8.22 2.47 0.411 53.29 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.32μs 1.17ns 4.53ns 0.0146 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.75μs 1.47ns 5.71ns 0.0137 0 0 1.02 KB
master ExecuteNonQuery net472 2.11μs 2.72ns 10.5ns 0.156 0 0 987 B
#6091 ExecuteNonQuery net6.0 1.34μs 1.32ns 5.1ns 0.0141 0 0 1.02 KB
#6091 ExecuteNonQuery netcoreapp3.1 1.75μs 1.43ns 5.52ns 0.0133 0 0 1.02 KB
#6091 ExecuteNonQuery net472 2.13μs 1.85ns 6.94ns 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.14μs 0.722ns 2.7ns 0.0137 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.53μs 0.792ns 2.86ns 0.0133 0 0 976 B
master CallElasticsearch net472 2.53μs 1.42ns 5.33ns 0.158 0 0 995 B
master CallElasticsearchAsync net6.0 1.33μs 0.792ns 2.97ns 0.0132 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.64μs 2.77ns 10.3ns 0.0141 0 0 1.02 KB
master CallElasticsearchAsync net472 2.63μs 1.72ns 6.67ns 0.166 0 0 1.05 KB
#6091 CallElasticsearch net6.0 1.19μs 1.13ns 4.37ns 0.014 0 0 976 B
#6091 CallElasticsearch netcoreapp3.1 1.54μs 0.635ns 2.38ns 0.013 0 0 976 B
#6091 CallElasticsearch net472 2.54μs 1.18ns 4.58ns 0.158 0 0 995 B
#6091 CallElasticsearchAsync net6.0 1.28μs 0.862ns 3.23ns 0.0134 0 0 952 B
#6091 CallElasticsearchAsync netcoreapp3.1 1.61μs 0.736ns 2.75ns 0.0139 0 0 1.02 KB
#6091 CallElasticsearchAsync net472 2.57μs 0.741ns 2.77ns 0.167 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.29μs 0.716ns 2.68ns 0.0129 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.69μs 0.385ns 1.39ns 0.0126 0 0 952 B
master ExecuteAsync net472 1.68μs 0.982ns 3.8ns 0.145 0 0 915 B
#6091 ExecuteAsync net6.0 1.24μs 0.839ns 3.25ns 0.0131 0 0 952 B
#6091 ExecuteAsync netcoreapp3.1 1.67μs 0.943ns 3.65ns 0.0127 0 0 952 B
#6091 ExecuteAsync net472 1.71μs 0.226ns 0.784ns 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.12μs 0.931ns 3.48ns 0.0309 0 0 2.22 KB
master SendAsync netcoreapp3.1 5.1μs 1.31ns 5.07ns 0.038 0 0 2.76 KB
master SendAsync net472 7.8μs 2.47ns 9.55ns 0.499 0 0 3.15 KB
#6091 SendAsync net6.0 4.2μs 2.04ns 7.62ns 0.0314 0 0 2.22 KB
#6091 SendAsync netcoreapp3.1 5.11μs 1.64ns 6.37ns 0.0358 0 0 2.76 KB
#6091 SendAsync net472 7.73μs 1.57ns 6.09ns 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.54μs 0.587ns 2.2ns 0.0231 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.21μs 1.02ns 3.69ns 0.0221 0 0 1.64 KB
master EnrichedLog net472 2.56μs 1.08ns 4.19ns 0.249 0 0 1.57 KB
#6091 EnrichedLog net6.0 1.45μs 0.729ns 2.82ns 0.0234 0 0 1.64 KB
#6091 EnrichedLog netcoreapp3.1 2.27μs 1.31ns 4.89ns 0.0227 0 0 1.64 KB
#6091 EnrichedLog net472 2.6μs 0.919ns 3.56ns 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 114μs 119ns 462ns 0.0573 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 118μs 391ns 1.51μs 0.0585 0 0 4.28 KB
master EnrichedLog net472 146μs 144ns 558ns 0.657 0.219 0 4.46 KB
#6091 EnrichedLog net6.0 114μs 174ns 676ns 0.0574 0 0 4.28 KB
#6091 EnrichedLog netcoreapp3.1 118μs 118ns 425ns 0 0 0 4.28 KB
#6091 EnrichedLog net472 145μs 77.6ns 300ns 0.655 0.218 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.21μs 0.952ns 3.56ns 0.0306 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.29μs 2.09ns 7.81ns 0.03 0 0 2.2 KB
master EnrichedLog net472 4.75μs 7.01ns 26.2ns 0.32 0 0 2.02 KB
#6091 EnrichedLog net6.0 3.06μs 1.23ns 4.77ns 0.0305 0 0 2.2 KB
#6091 EnrichedLog netcoreapp3.1 4.2μs 1.35ns 4.67ns 0.0293 0 0 2.2 KB
#6091 EnrichedLog net472 4.78μs 1.8ns 6.99ns 0.319 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.37μs 0.586ns 2.27ns 0.0165 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.77μs 1.1ns 4.26ns 0.0159 0 0 1.14 KB
master SendReceive net472 2.04μs 0.592ns 2.29ns 0.183 0 0 1.16 KB
#6091 SendReceive net6.0 1.37μs 1ns 3.88ns 0.0162 0 0 1.14 KB
#6091 SendReceive netcoreapp3.1 1.78μs 1.23ns 4.6ns 0.015 0 0 1.14 KB
#6091 SendReceive net472 2.06μs 1.67ns 6.25ns 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.86μs 0.852ns 3.19ns 0.0228 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 4.05μs 3.07ns 11.9ns 0.0223 0 0 1.65 KB
master EnrichedLog net472 4.44μs 1.11ns 4.15ns 0.323 0 0 2.04 KB
#6091 EnrichedLog net6.0 2.82μs 2.32ns 8.98ns 0.0227 0 0 1.6 KB
#6091 EnrichedLog netcoreapp3.1 3.99μs 1.54ns 5.77ns 0.0216 0 0 1.65 KB
#6091 EnrichedLog net472 4.38μs 1.74ns 6.52ns 0.322 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #6091

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net6.0 1.131 530.22 468.98

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 393ns 0.255ns 0.987ns 0.00811 0 0 576 B
master StartFinishSpan netcoreapp3.1 595ns 0.253ns 0.981ns 0.00782 0 0 576 B
master StartFinishSpan net472 598ns 0.889ns 3.33ns 0.0918 0 0 578 B
master StartFinishScope net6.0 530ns 0.321ns 1.24ns 0.00962 0 0 696 B
master StartFinishScope netcoreapp3.1 726ns 0.969ns 3.75ns 0.00944 0 0 696 B
master StartFinishScope net472 813ns 0.917ns 3.43ns 0.104 0 0 658 B
#6091 StartFinishSpan net6.0 395ns 0.171ns 0.662ns 0.00802 0 0 576 B
#6091 StartFinishSpan netcoreapp3.1 617ns 1.52ns 5.88ns 0.00797 0 0 576 B
#6091 StartFinishSpan net472 579ns 0.637ns 2.47ns 0.0918 0 0 578 B
#6091 StartFinishScope net6.0 469ns 0.124ns 0.482ns 0.00965 0 0 696 B
#6091 StartFinishScope netcoreapp3.1 691ns 0.59ns 2.21ns 0.00934 0 0 696 B
#6091 StartFinishScope net472 811ns 0.522ns 2.02ns 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 644ns 0.341ns 1.32ns 0.00978 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 1E+03ns 0.987ns 3.82ns 0.00962 0 0 696 B
master RunOnMethodBegin net472 1.12μs 1.29ns 4.99ns 0.104 0 0 658 B
#6091 RunOnMethodBegin net6.0 686ns 0.649ns 2.52ns 0.0099 0 0 696 B
#6091 RunOnMethodBegin netcoreapp3.1 926ns 0.371ns 1.39ns 0.00927 0 0 696 B
#6091 RunOnMethodBegin net472 1.16μs 0.385ns 1.49ns 0.104 0 0 658 B

@andrewlock
Copy link
Member

Throughput/Crank Report ⚡

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 (6091) (11.095M)   : 0, 11094821
    master (10.927M)   : 0, 10927139
    benchmarks/2.9.0 (11.081M)   : 0, 11080577

    section Automatic
    This PR (6091) (7.362M)   : 0, 7362087
    master (7.322M)   : 0, 7322055
    benchmarks/2.9.0 (7.732M)   : 0, 7732233

    section Trace stats
    master (7.600M)   : 0, 7600325

    section Manual
    master (10.941M)   : 0, 10940627

    section Manual + Automatic
    This PR (6091) (6.826M)   : 0, 6825741
    master (6.568M)   : 0, 6568140

    section DD_TRACE_ENABLED=0
    master (10.242M)   : 0, 10242149

Loading
gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (6091) (9.639M)   : 0, 9639389
    master (9.577M)   : 0, 9577232
    benchmarks/2.9.0 (9.798M)   : 0, 9798067

    section Automatic
    This PR (6091) (6.588M)   : 0, 6587913
    master (6.625M)   : 0, 6625219

    section Trace stats
    master (6.872M)   : 0, 6872290

    section Manual
    master (9.590M)   : 0, 9589966

    section Manual + Automatic
    This PR (6091) (6.035M)   : 0, 6034508
    master (6.216M)   : 0, 6216360

    section DD_TRACE_ENABLED=0
    master (8.849M)   : 0, 8848858

Loading
gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (6091) (10.014M)   : 0, 10013687
    master (10.054M)   : 0, 10053618
    benchmarks/2.9.0 (10.067M)   : 0, 10067315

    section Automatic
    This PR (6091) (6.603M)   : 0, 6602733
    master (6.652M)   : 0, 6652460
    benchmarks/2.9.0 (7.552M)   : 0, 7552193

    section Trace stats
    master (7.361M)   : 0, 7361092

    section Manual
    master (9.980M)   : 0, 9980178

    section Manual + Automatic
    This PR (6091) (6.071M)   : 0, 6070667
    master (6.131M)   : 0, 6130507

    section DD_TRACE_ENABLED=0
    master (9.497M)   : 0, 9496505

Loading

@daniel-romano-DD daniel-romano-DD merged commit 62451bc into master Sep 27, 2024
73 of 75 checks passed
@daniel-romano-DD daniel-romano-DD deleted the dani/iast/remove_safe_origin_ranges branch September 27, 2024 11:47
@github-actions github-actions bot added this to the vNext-v3 milestone Sep 27, 2024
nhulston pushed a commit that referenced this pull request Sep 27, 2024
## Summary of changes
Remove ranges from safe origins from vulnerability evidence

## Reason for change
Until now, only ranges marked with a secure mark were removed from
evidence, but ranges from safe sources (like database values in non XSS
or SQLi injections) were being sent.

SecureMarks are marks added to a range that indicates that it has been
sanitized (and thus, secured) for that vulnerability.
In the same manner, there some origins that do not apply to certain
vulnerabilities, like database values not applying in injection but XSS
and SQLi. So in these cases, those ranges should be removed from the
evidence.

## Implementation details
Filter ranges by source as well as by secure marks

## Test coverage
Unit and integration tests

## 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. -->

---------

Co-authored-by: Andrew Lock <andrew.lock@datadoghq.com>
@andrewlock andrewlock added the type:enhancement Improvement to an existing feature label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:asm-iast type:enhancement Improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants