[ASM] Prevent waf from breaking app if non compatible native library file is loaded by tracer#3251
Conversation
This comment has been minimized.
This comment has been minimized.
d245f37 to
6e14a38
Compare
This comment has been minimized.
This comment has been minimized.
| OSPlatformName.Windows => "ddwaf.dll", | ||
| OSPlatformName.MacOS => $"libddwaf{libVersion}.dylib", | ||
| OSPlatformName.Linux => $"libddwaf{libVersion}.so", | ||
| OSPlatformName.Windows => $"ddwaf{libVersion}.dll", |
There was a problem hiding this comment.
Maybe add an hyphen to separate the version if specified?
There was a problem hiding this comment.
fixed in 596ff97, it was all to avoid the if 😅
b679958 to
596ff97
Compare
This comment has been minimized.
This comment has been minimized.
| { | ||
| "win-x86", "win-x64" | ||
| }; | ||
| readonly string[] WafWindowsArchitectureFolders = { "win-x86", "win-x64" }; |
There was a problem hiding this comment.
Mostly the changes to this file are reformatting?
There was a problem hiding this comment.
yes apart the added function to add an older waf file to the waf unit test's build directory , then ran into some trouble indenting it on Rider 😅
robertpi
left a comment
There was a problem hiding this comment.
LGTM, thanks for the quick solution!
| { | ||
| if (wafNative.ExportErrorHappened) | ||
| { | ||
| Log.Error("Waf couldn't initialize properly because of missing methods in native library, please check the version of libddwaf"); |
There was a problem hiding this comment.
nit: I wonder, can we be more explicit about which version we expect here? Probably not 🤔 I think at the least we should give some specific guidance. e.g. make sure you don't have multiple versions of Datadog.Trace, install the latest, etc
There was a problem hiding this comment.
we cant, unless we build some kinda compatibility matrice of tracer versions / waf versions..
I added more guidance in the comment in 9fe3b5d
| var configObj = GetConfigObj(rulesFile, argCache, encoder); | ||
| if (configObj == null) | ||
| { | ||
| Log.Error("Waf couldn't initialize properly because of an unusable rule file, please check the submitted rulefile"); |
There was a problem hiding this comment.
Same comment here, is there any way to have something actionable for the user in the logs? e.g. check for multiple tracer versions etc etc "if you manually provided a rule file, make sure it's valid for the latest version of the Waf" etc
|
|
||
| internal static InitializationResult Configure(string rulesFile, WafNative wafNative, Encoder encoder, string obfuscationParameterKeyRegex, string obfuscationParameterValueRegex) | ||
| { | ||
| if (wafNative.ExportErrorHappened) |
There was a problem hiding this comment.
Doesn't need to be this PR, but I wonder, can/should we add this to telemetry/configuration log
There was a problem hiding this comment.
It's a good idea, we already have the WAF version in the configuration log, so adding this should be straight forward.
I noticed there's quite a lot of stuff that's in the config log, but not startup telemetry, I guess we could add the missing stuff as "additional values" ?
There was a problem hiding this comment.
I added this error in the startup log if it's true . As we want to have it for next release, I suggest we do a subsequent PR on adding security info to startup telemetry ( ConfigurationTelemetryCollector for me to remember 😅 )
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Benchmarks Report 🐌Benchmarks for #3251 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️Raw results
|
Code Coverage Report 📊✔️ Merging #3251 into master will not change line coverage
View the full report for further details: Datadog.Trace Breakdown ✔️
The following classes have significant coverage changes.
View the full reports for further details: |
Summary of changes
If some export is null then it means we dont have the right underlying waf native file version, so dont init waf.
LibraryLoadercan now load a specific version of the waf provided that the file's name contain it, for the purpose of Unit Tests only.Added in Build.steps the ability to load an older version (arbitrarily 1.4 now) to rename the waf after unzipping
Reason for change
make sure waf's breaking change dont break the app
Implementation details
Depends on DataDog/system-tests#509
Test coverage
Add a unit test with older waf version to test.
Other details