Repository navigation
Fix the blank environment page: precompile the config validator for the CSP - #189
Merged
Merged
Conversation
… CSP Ajv's runtime compiler builds functions from strings. The web UI's CSP refuses that, so the environment page threw at load and rendered blank in real browsers. jsdom does not enforce CSP, so every unit test passed. Signed-off-by: review <[email protected]>
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.
What changed
The
shipkeep.ymlvalidator is now compiled at generation time (pnpm gen:config→packages/config-schema/src/gen/validator.ts) instead of at runtime. Ajv's standalone output needs two small helpers, which live invalidator-runtime.ts, so Ajv itself no longer reaches the web bundle.Why
The environment page has been blank in real browsers since #169. That page holds application creation, and everything after it is reached through it.
Ajv's runtime compiler builds functions from strings. The production CSP (
script-src 'self', nounsafe-eval) refuses that, so the module threwEvalErrorwhen loaded and the route rendered nothing. jsdom does not enforce CSP, so every unit test passed, and with CI off the browser suite never ran. A real Chromium run caught it today.Allowing
unsafe-evalwas not considered: the CSP is doing its job, and that would weaken it for the whole UI.How it was tested
csp.spec.ts: refusesFunctionandeval, then loads and validates. It fails on the old code withEvalErrorand passes now, so jsdom can no longer hide this.The same schema now validates on the API through the generated code, which the integration suite exercised before this change only through the old path. The fixtures cover the new path; the suite should be rerun with CI-1.
Security considerations
The CSP is unchanged. The generator refuses output containing
require(,new Functionoreval(.deepEqualanducs2lengthare new hand-written code on validation paths, with their own tests, including lone surrogates.Checklist