Remove `JETPACK__SANDBOX_DOMAIN` check and `_inc/jetpack-server-sandbox.php` from build.
An Automattic development file is being included in the distributed version of the plugin, adding code to the hook requests-requests.before_request.
This code is unnecessary outside of the wp.com development environments and uses a hook unavailable to the rest of us.
It would be great if this code and file could be removed during the build process. Alternatively the file could be included as an mu-plugin on wp.com sandboxes.
Steps to reproduce the issue
- Download Jetpack from wordpress.org.
- Open
/path/to/plugins/jetpack/_inc/jetpack-server-sandbox.php. - Read comment explaining the file is for Automattic employees only.
What I expected
What happened instead
Nice catch, thank you for the report. While we do need to keep the file, it should only be included when needed, and the current check is not enough. I've opened #10140 to solve this issue.
Coming back to this, I can't seem to reproduce the issue anymore, even without my patch; the file is never loaded unless you use the constant.
Did you experience anything different on your end?
I wasn’t seeing it included during execution, my issue is that it’s included in the public build when it could be an mu-plugin on the Jetpack/wp.com development & related environments.
The file targets around 1000 people but sits on 5,000,000+ servers.
The genericons security issue in WordPress 4.2.2 is a good demonstration of why unexecuted code is best left off servers.
Thanks for the feedback!
Just to make sure we're all on the same page, I want to clarify a few points:
uses a hook unavailable to the rest of us
"Hook", in WordPress development, is a word used in a few different ways. If you're talking about the requests-requests.before_request hook, it is available to everyone. If you're talking about the function hooked into that hook, (jetpack_server_sandbox()), then, yes, it's currently only meant for use by developers with access to WordPress.com's infrastructure, but it's there so everyone can see what it does and how it works.
This code is unnecessary outside of the wp.com development environments
The code is there so that Jetpack sites can talk to WordPress.com development environments; it must be on the Jetpack site, not on the WordPress.com side of things.
In addition to development, the code is also occasionally used in support, and we may generalize the code in the future to better serve certain hosts' and partners' hosting environments.
Shipping the code to places that don't need it is obviously a valid concern, but we've decided to keep the file in place for now as we believe the benefits (support, transparency, reduced development complexity, …) outweigh the costs.
We may, of course, change things in the future; thank you very much for your feedback.
Also note that the code is not new; it's a new implementation of some old code, which was removed. The new implementation works better, and is now centralized in one place - the easier to notice, perhaps, but also to ignore for those who don't need it.