-
Notifications
You must be signed in to change notification settings - Fork 160
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
AppSec: improve behavior with empty DD_SERVICE/DD_ENV #2888
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## bob/rc-tags #2888 +/- ##
=================================================
- Coverage 78.24% 78.21% -0.03%
Complexity 2526 2526
=================================================
Files 173 173
Lines 18742 18749 +7
Branches 981 988 +7
=================================================
Hits 14664 14664
- Misses 3538 3544 +6
- Partials 540 541 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
|
@@ -78,7 +78,7 @@ DDWAF_LOG_LEVEL spdlog_level_to_ddwaf(spdlog::level::level_enum level) | |||
case spdlog::level::trace: | |||
return DDWAF_LOG_TRACE; | |||
case spdlog::level::debug: | |||
return DDWAF_LOG_DEBUG; | |||
// libddwaf is too verbose at debug level |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this, the trace level with RC has just too much crap, which makes it difficult to analyse anything WAF-specific...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the previous behavior resulted in 90% of the messages being from libddwaf, esp during initialization, with pearls like this:
[2024-10-10 14:01:39.863][debug][181] Parsed rule crs-932-180
[2024-10-10 14:01:39.863][debug][181] Found address server.request.headers.no_cookies
[2024-10-10 14:01:39.863][debug][181] Found address server.request.headers.no_cookies
[2024-10-10 14:01:39.863][debug][181] Found address server.request.headers.no_cookies
[2024-10-10 14:01:39.863][debug][181] Found address server.request.headers.no_cookies
makes it difficult to read the logs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've looked at the code of libddwaf and the only trace messages are about matches, which make them lower-volume, and actually look more important than most debug messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had to demote match logs a while ago because of PII concerns.
Benchmarks [ appsec ]Benchmark execution time: 2024-10-11 18:19:44 Comparing candidate commit c59e00d in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 0 unstable metrics. |
static bool _has_empty_service_or_env() | ||
{ | ||
return zend_string_equals_literal(get_DD_ENV(), "") || | ||
zend_string_equals_literal(get_DD_SERVICE(), ""); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should cache that at rinit, it's possible to change these via ini_set()
too at runtime... Which will then not reflect the truth for you in rshutdown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't I use get_global_DD_ENV()
here for the same effect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved it to startup with get_global
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, get_global is definitely inferior. It will also bypass all perdir changes. Like vhost specific config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just cache the value in a thread-local variable after rinit.
ae6398d
to
8e9b214
Compare
8e9b214
to
c59e00d
Compare
Benchmarks [ tracer ]Benchmark execution time: 2024-10-11 18:13:18 Comparing candidate commit c59e00d in PR branch Found 4 performance improvements and 2 performance regressions! Performance is the same for 172 metrics, 0 unstable metrics. scenario:MessagePackSerializationBench/benchMessagePackSerialization
scenario:PDOBench/benchPDOBaseline
scenario:PDOBench/benchPDOBaseline-opcache
scenario:SamplingRuleMatchingBench/benchRegexMatching2-opcache
scenario:TraceFlushBench/benchFlushTrace
scenario:TraceSerializationBench/benchSerializeTrace
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
* Send git tags via remote config Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com> * Submit root span data when service/env/version ini is changed Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com> * AppSec: improve behavior with empty DD_SERVICE/DD_ENV (#2888) --------- Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com> Co-authored-by: Gustavo Lopes <gustavo.lopes@datadoghq.com>
Description
Reviewer checklist