-
Notifications
You must be signed in to change notification settings - Fork 167
Amend security_response_id being release before displaying it #3493
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
base: master
Are you sure you want to change the base?
Amend security_response_id being release before displaying it #3493
Conversation
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (74.20%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #3493 +/- ##
==========================================
- Coverage 61.83% 61.71% -0.13%
==========================================
Files 142 142
Lines 12923 12975 +52
Branches 1695 1700 +5
==========================================
+ Hits 7991 8007 +16
- Misses 4178 4210 +32
- Partials 754 758 +4
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Benchmarks [ appsec ]Benchmark execution time: 2025-11-28 17:32:42 Comparing candidate commit 1947c09 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 0 unstable metrics. |
c332291 to
c837f84
Compare
Benchmarks [ tracer ]Benchmark execution time: 2025-11-28 18:02:10 Comparing candidate commit 1947c09 in PR branch Found 1 performance improvements and 6 performance regressions! Performance is the same for 185 metrics, 2 unstable metrics. scenario:PHPRedisBench/benchRedisOverhead
scenario:SamplingRuleMatchingBench/benchRegexMatching1
scenario:SamplingRuleMatchingBench/benchRegexMatching2
scenario:SamplingRuleMatchingBench/benchRegexMatching3
scenario:SamplingRuleMatchingBench/benchRegexMatching4
scenario:SpanBench/benchOpenTelemetryAPI
scenario:TraceSerializationBench/benchSerializeTrace
|
1f57085 to
07be196
Compare
b64885f to
7de55c1
Compare
| va_copy(args2, args); | ||
| php_verror(NULL, "", E_COMPILE_WARNING, format, args2); | ||
| va_end(args2); | ||
| _php_verror(E_COMPILE_WARNING, "%s", msg); |
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.
same
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 can't as on this case, the same msg is used for the next _php_verror
| dd_request_abort_redirect(); | ||
| } | ||
|
|
||
| dd_request_abort_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.
you're calling on the top as well. I don't think the call on top is correct, because the abort functions need block_parameters. This also makes _reset_globals() too early.
So maybe after this block:
if (_enabled_user_req) {
if (_cur_req_span) {
mlog_g(dd_log_info,
"Finishing user request whose corresponding "
"span is presumably still unclosed on rshutdown");
_do_request_finish_user_req(true, _superglob_equiv, 0, NULL, NULL);
_reset_globals();
}
} else {
_do_request_finish_php(ignore_verdict);
// _rest_globals already called
}
// ADDED:
_block_parameters_free()OTOH this will not be reached if we call _emit_error from _do_request_finish_php... so I guess sth like:
--- a/appsec/src/extension/request_abort.c
+++ b/appsec/src/extension/request_abort.c
@@ -375,11 +375,13 @@ void dd_request_abort_redirect(void)
? ZSTR_VAL(_block_parameters->security_response_id)
: "");
} else {
+ __auto_type *block_parameters = _block_parameters;
+ _block_parameters = NULL;
_emit_error("Datadog blocked the request and attempted a redirection "
"to %s. No action required. Security Response ID: %s",
- ZSTR_VAL(_block_parameters->redirection_location),
- _block_parameters->security_response_id
- ? ZSTR_VAL(_block_parameters->security_response_id)
+ ZSTR_VAL(block_parameters->redirection_location),
+ block_parameters->security_response_id
+ ? ZSTR_VAL(block_parameters->security_response_id)
: "");
}
}
@@ -462,10 +464,12 @@ void _request_abort_static_page(int response_code, int type)
? ZSTR_VAL(_block_parameters->security_response_id)
: "");
} else {
+ __auto_type *block_parameters = _block_parameters;
+ _block_parameters = NULL;
_emit_error("Datadog blocked the request and presented a static error "
"page. No action required. Security Response ID: %s",
- _block_parameters->security_response_id
- ? ZSTR_VAL(_block_parameters->security_response_id)
+ block_parameters->security_response_id
+ ? ZSTR_VAL(block_parameters->security_response_id)
: "");
}
}
@@ -552,12 +556,14 @@ static bool _abort_prelude(void)
? ZSTR_VAL(_block_parameters->security_response_id)
: "");
} else {
+ __auto_type *block_parameters = _block_parameters;
+ _block_parameters = NULL;
_emit_error(
"Datadog blocked the request, but the response has already "
"been partially committed. No action required. Security "
"Response ID: %s",
- _block_parameters->security_response_id
- ? ZSTR_VAL(_block_parameters->security_response_id)
+ block_parameters->security_response_id
+ ? ZSTR_VAL(block_parameters->security_response_id)
: "");
}
return false;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 don't get this last comment
be24fc8 to
2e9efdd
Compare
Description
This PR fixes two errors related to security_response_id memory managment:
Reviewer checklist