Repository navigation
fix: validate forms without unsafe-eval - #30
Merged
Merged
Conversation
Ajv builds its validator with new Function, which the container's CSP refuses, so every form submit failed with "Error compiling schema". The form now validates with @cfworker/json-schema, which reads the schema instead of compiling it. The policy is unchanged. ADR-0001. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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
@cfworker/json-schemathrough a small adapter insrc/lib/forms/validator.ts. It reads the schema instead of compiling it, so it runs under the container's Content Security Policy.@rjsf/validator-ajv8stays installed only because@rjsf/coreimports it for a test helper without declaring it. Nothing insrcuses it.nginx.confis unchanged.Why
Ajv builds its validator with
new Function. The container serves the client withscript-src 'self', which refuses that, so every form submit failed with "Error compiling schema". The Vite dev server sets no policy, which is why this never showed locally.How it was verified
npm test: 100 tests pass, including the existing form view tests that submit bad values and read the messages. Four new tests pin the adapter's error shape.npm run typecheck,npm run lint,npm run knippass.docker compose up --build, pointed it at a dev Experience API, and submitted a PMFBY grievance form under the real CSP. It submitted.🤖 Generated with Claude Code