-
Notifications
You must be signed in to change notification settings - Fork 191
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
handle host detector with custom error handler and open_basedir #1454
handle host detector with custom error handler and open_basedir #1454
Conversation
if open_basedir is configured such that files that it tries to open are denied with a php warning, and a custom error handler is installed which converts warnings to exceptions, an unhandled exception occurs. add a test for this, and some try/catch/ignore blocks around the code that can trigger this.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1454 +/- ##
============================================
- Coverage 73.26% 73.25% -0.01%
+ Complexity 2685 2683 -2
============================================
Files 387 387
Lines 8009 8014 +5
============================================
+ Hits 5868 5871 +3
- Misses 2141 2143 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 4 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
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.
IMO we should disable the error handler instead.
set_error_handler(static fn() => true);
try {
if (($content = file_get_contents($file)) !== false) {
return trim($content);
}
} finally {
restore_error_handler();
}
src/SDK/Resource/Detectors/Host.php
Outdated
set_error_handler(static fn () => true); | ||
|
||
try { | ||
if (is_file($file) && is_readable($file)) { |
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.
These checks are no longer needed.
8cd59c1
to
86deb4e
Compare
tests/Integration/SDK/Resource/Detectors/test_host_detector_with_open_basedir.phpt
Outdated
Show resolved
Hide resolved
…th_open_basedir.phpt Co-authored-by: Tobias Bachert <[email protected]>
if
open_basedir
is configured such that files that the host detector tries to open are denied with a php warning, and a custom error handler is installed which converts warnings to exceptions, an unhandled exception occurs.add a test for this, and some try/catch/ignore blocks around the code that can trigger this.
Closes: #1450
Replace: #1451