-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add php://input
and $_FILES
to trace metadata
#95
base: master
Are you sure you want to change the base?
Conversation
This isn't free to read the data, both in terms of memory and time usage, so I'm not sure it makes sense for us to add for all requests. (Also, I seem to recall that |
Yep:
There's no way to check the type of form submission reliably that I can find. So this could be limited to just POST, PUT, PATCH, DELETE requests. Should we include |
Sorry, typo, that should have said:
That is, the stream is exhausted once it's read from. I can't see any info on whether that's still the case though.
HTTP only allows request bodies on POST, PUT, and PATCH; GET, HEAD, and DELETE can't have them. |
Well I was close. Also kinda wild regarding |
Quick test - created a file <?php
$input1 = file_get_contents( 'php://input' );
var_dump( 'once', $input1 );
$input2 = file_get_contents( 'php://input' );
var_dump( 'twice', $input2 ); Run
Output:
|
Yeah, it was an exhaustible stream so you had to cache the data; it's why the REST API code reads it once and stores it. I think it depends on which SAPI you're using though. In any case: I think this needs to be behind some kind of flag, because otherwise there's potentially a lot of data being read in, parsed, and pushed out to X-Ray. |
See #94 |
php://input
to trace metadataphp://input
and $_FILES
to trace metadata
Truncation isn't a straight solution to that, because you still have the overhead of reading data in and parsing it. Say, for example, I do Even with regular sized JSON data that can be generated from page builders/etc, reading the whole data into memory will use up a decent chunk of memory, plus has the overhead of then truncating if necessary and pushing off to X-Ray. I can see this having an appreciable impact on request times, and causing errors. (This is one of the reasons that eg Apache access logs don't include HTTP bodies as well.) Also, the data sanitisation will need adapting for any of this, given that it otherwise will include the data we're sanitising elsewhere. I see the utility of why you'd want to add this, but without being flagged behind (say) an opt-in header I don't think we can enable it by default. |
Well, we can close this one then. I was going off a throwaway comment on #80 that we should add this while I had the repo open. The most crucial things for me right now are the truncation and being able to redact data on the initial progress. |
Ok think we can check the stream length on |
Ah smart |
This lets us report on REST API body payloads as well as regular form data.