Amend security_response_id being release before displaying it#3493
Amend security_response_id being release before displaying it#3493estringana merged 12 commits intomasterfrom
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.81% 61.60% -0.21%
==========================================
Files 142 142
Lines 12923 12975 +52
Branches 1695 1700 +5
==========================================
+ Hits 7988 7993 +5
- Misses 4183 4222 +39
- Partials 752 760 +8
... and 3 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-12-03 15:12:05 Comparing candidate commit 186a308 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.
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.
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.
I don't get this last comment
be24fc8 to
2e9efdd
Compare
…rity-response-id-error-message
Description
This PR fixes two errors related to security_response_id memory managment:
Reviewer checklist