[4.x] Don't log HTTP requests to Telescope endpoints #1127
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1126 introduced by #1124
Taylor rightly questioned why the domain check was an OR conditional as that ended up breaking Telescope's behavior using the out-of-the-box config:
With Telescope's default
config('telescope.domain') === null
, the new methodrequestIsToApprovedDomain()
was always returning true. This skipsrequestIsToApprovedUri()
and permits every path to be logged. Telescope database entries are being inserted for /telescope/requests, /telescope/batches, etc. while also ignoringconfig('telescope.only_paths')
.Instead make changes that allow the below config to be used, which the pull request originally intended to fix:
requestIsToApprovedDomain()
must checkconfig('telescope.domain')
contains a value for Telescope route registration. A request is approved for logging when Telescope's domain configuration is empty or its filled value is different from the current request meaning it's an app request (and not a Telescope admin request.)requestIsToApprovedUri()
will ignoreconfig('telescope.path') === null
for custom domains since conditional! $request->is('*')
would ignore all paths and nothing is ever logged.When
requestIsToApprovedDomain()
returnstrue
,config('telescope.only_paths')
must also be checked. So that pull request should have introduced an AND conditional. The fixes in bullet points 1 & 2 allowrequestIsToApprovedDomain() && requestIsToApprovedUri()
to be used.I wouldn't mind adding some integration and/or unit tests for this but any Laravel app code skipped by
! $app->runningInConsole()
(like protected methodhandlingApprovedRequest()
) is untestable with PHPUnit unless the code is restructured to make that mockable.