Add asset proxy for all included webroot assets#112
Merged
alexander-zierhut merged 3 commits intozubzet:mainfrom Apr 21, 2026
Merged
Add asset proxy for all included webroot assets#112alexander-zierhut merged 3 commits intozubzet:mainfrom
alexander-zierhut merged 3 commits intozubzet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a framework-level asset proxy endpoint for serving bundled “IncludedComponents” static assets, updates the default layout essentials to load JS/CSS via that proxy, and removes duplicated vendored webroot assets from the e2e fixture.
Changes:
- Add
/_zubzet/asset-proxy/{assetPath}route and anAssetProxyservice to serve framework assets fromsrc/IncludedComponents/assets. - Update layout essentials to reference assets through the new asset proxy URL scheme.
- Include framework route files automatically and refactor booter settings access into a reusable trait; add MIME type detection dependency.
Reviewed changes
Copilot reviewed 16 out of 36 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e/webroot/assets/js/popper.min.js | Remove vendored test webroot JS (now served via framework asset proxy). |
| tests/e2e/webroot/assets/js/jquery.csv.js | Remove vendored test webroot JS (now served via framework asset proxy). |
| tests/e2e/webroot/assets/js/bs-custom-file-input.js | Remove vendored test webroot JS (now served via framework asset proxy). |
| tests/e2e/webroot/assets/js/bootstrap.min.js | Remove vendored test webroot JS (now served via framework asset proxy). |
| tests/e2e/webroot/assets/js/Z.js | Remove vendored test webroot JS (now served via framework asset proxy). |
| tests/e2e/webroot/assets/css/webfonts/fa-solid-900.woff2 | Remove vendored test webroot font (now served via framework asset proxy). |
| tests/e2e/webroot/assets/css/webfonts/fa-solid-900.woff | Remove vendored test webroot font (now served via framework asset proxy). |
| tests/e2e/webroot/assets/css/webfonts/fa-solid-900.ttf | Remove vendored test webroot font (now served via framework asset proxy). |
| tests/e2e/webroot/assets/css/webfonts/fa-solid-900.eot | Remove vendored test webroot font (now served via framework asset proxy). |
| tests/e2e/webroot/assets/css/webfonts/fa-regular-400.woff2 | Remove vendored test webroot font (now served via framework asset proxy). |
| tests/e2e/webroot/assets/css/webfonts/fa-regular-400.woff | Remove vendored test webroot font (now served via framework asset proxy). |
| tests/e2e/webroot/assets/css/webfonts/fa-regular-400.ttf | Remove vendored test webroot font (now served via framework asset proxy). |
| tests/e2e/webroot/assets/css/webfonts/fa-regular-400.eot | Remove vendored test webroot font (now served via framework asset proxy). |
| tests/e2e/webroot/assets/css/webfonts/fa-brands-400.woff2 | Remove vendored test webroot font (now served via framework asset proxy). |
| tests/e2e/webroot/assets/css/webfonts/fa-brands-400.woff | Remove vendored test webroot font (now served via framework asset proxy). |
| tests/e2e/webroot/assets/css/webfonts/fa-brands-400.ttf | Remove vendored test webroot font (now served via framework asset proxy). |
| tests/e2e/webroot/assets/css/webfonts/fa-brands-400.eot | Remove vendored test webroot font (now served via framework asset proxy). |
| tests/e2e/webroot/assets/css/font-awesome/v4-shims.min.css | Remove vendored test webroot CSS (now served via framework asset proxy). |
| tests/e2e/webroot/assets/css/font-awesome/fontawesome.min.css | Remove vendored test webroot CSS (now served via framework asset proxy). |
| tests/e2e/webroot/assets/css/font-awesome/brands.min.css | Remove vendored test webroot CSS (now served via framework asset proxy). |
| src/ZubZet.php | Instantiate/register the asset proxy and add booter-settings trait usage. |
| src/Support/GlobalReferences.php | Update config() helper to use booter instance settings retrieval. |
| src/Routing/Router.php | Include both user route files and framework-provided IncludedComponents route files. |
| src/Resources/AssetProxy.php | New service to resolve and stream assets from configured webroot sources. |
| src/Message/RequestResponseHandler.php | Replace in-class booter settings accessor with shared trait. |
| src/IncludedComponents/views/layout/layout_essentials.php | Switch default JS/CSS URLs to go through /_zubzet/asset-proxy/.... |
| src/IncludedComponents/routes/DefaultRoutes.php | New default route group exposing the asset proxy endpoint. |
| src/Core/CanRetrieveBooterSettings.php | New trait centralizing getBooterSettings() logic. |
| composer.lock | Lockfile updates for new dependency and platform metadata changes. |
| composer.json | Add league/mime-type-detection dependency used by the asset proxy. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Apr 19, 2026
Signed-off-by: zierhut.alex <alex@zierhut-it.de>
937865e to
57bf522
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds an asset proxy so framework-included webroot assets (CSS, JS) are served directly from
framework_root/IncludedComponents/assets/instead of having to be copied into each project's webroot. Projects register additional sources viazubzet()->assetProxy->registerWebRootSource($path).Includes PR #133 (merged in): adds
$res->json()as a first-class Response helper — sends raw JSON withContent-Type: application/json, appliesJSON_THROW_ON_ERROR, and does not exit. Used by the AssetProxy e2e controller for cleanliness.Security hardening
Review on the initial commit surfaced several unsafe paths in
AssetProxy::serve(). All are now guarded and covered by e2e regressions:realpath()resolution +str_starts_with($resolved, $source . DIRECTORY_SEPARATOR)boundary check. Catches literal../, URL-encoded%2e%2e%2f, sibling-prefix (webroot_security.txtnext towebroot/), and symlink escapes."",".","./"thatrealpath()collapses to the source directory itself are rejected by the boundary check (the resolved path equals the source without the trailing separator).is_file()check beforereadfile()so a directory path doesn't crash; returns 404.realpath()rejects null bytes natively; the fatal bubbles up and the masked extension trick (file.txt\0.png) cannot expose the real file.FinfoMimeTypeDetectorreturnsnullfor empty or unclassified files; falls back toapplication/octet-streaminstead of emitting a malformed header.Tests
tests/e2e/tests/cypress/e2e/core/asset-proxy.cy.js— 14 cases covering both the production route (/_zubzet/asset-proxy/...) and an isolatedAssetProxyControllerthat drives controlled inputs (null bytes, empty paths, symlinks) which the URL layer can't carry cleanly. Fixtures live intests/e2e/webroot/assets/andtests/e2e/webroot_security.txt(the sentinel used to detect content leakage).Test plan
/_zubzet/asset-proxy/js/Z.jsreturns 200 withContent-Type: application/javascript./_zubzet/asset-proxy/css/bootstrap.min.cssreturns 200 withtext/css./_zubzet/asset-proxy/../../../../webroot_security.txtand the URL-encoded equivalent do not leak the sentinel./_zubzet/asset-proxy//etc/passwddoes not expose host files.application/octet-stream.././inputs do not dump the source directory.Merge order
Add $res->json() method for JSON responses #133 —(merged)$res->json()helper into this branchmain