Repository navigation
feat(verify): check a package the way a site plays it untrusted - #39
Merged
Merged
Conversation
--untrusted plays the package with the element's untrusted, as a site that did not make it does: none of its own code runs, the libraries come only from the pack, and the content is checked against their semantics. What the check removed is measured from the frame, the package's content.json against the parameters the runtime was handed, and reported as warnings by field: markup, attributes and styles by name, fields, list items, values. The runtime's own notes are kept beside them. A package that needs its own copy of a library is refused, and the summary says what to do. --libraries takes a bundle on disk too, served by the verifier itself, so the check runs offline against a pack the caller names. Closes #38 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`/<[a-z][^>]*>/gi` tried each `<` against the rest of the string, so a package whose text ran `<a<a<a…` with no `>` held the verifier for time quadratic in its length (CodeQL js/polynomial-redos). A scan by indexOf matches the same tags and stops once no `>` follows. The new test times out on the old expression. Co-Authored-By: Claude Opus 5.5 <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.
Closes #38
h5p-verify --untrustedplays a package the way a site that did not make it plays it —untrusted, as the H5P plugins treat an upload — and reports what the content check removed from it.Changes
--untrusted(anduntrusted: trueforverifyPackage) sets the element'suntrusted. The report'suntrustedis read back from the element, not copied from the option. Libraries come from--libraries, or the element's ownpack.What the check removed, measured. The runtime's notes cover six kinds of change and none of the markup it strips, so the verifier fetches the package's
content.jsonthrough the frame withX-H5P-Content-Check: semantics(the worker hands it over as written) and compares it with the parameters the boot script left inH5PIntegration.contentChangesreports, by JSON path:A removed empty value is left out, as upstream drops those too. The runtime's notes are kept beside the changes. All of it lands in
report.contentCheckand as warnings, capped at 20 lines with the rest inreport.json.A package that needs its own copy of a library (
missingLibraries.carried) is refused, and the summary says to build against the pack's versions or play it trusted.--libraries <path>: a bundle on disk, served from the verifier's own server, so an untrusted check runs offline against a pack you name. Several sources still work, space separated.Docs: the package README,
docs/verify.md,docs/untrusted.md, theh5p-verifyskill (when to use it and how to read the new warnings), AGENTS.md.Changes are warnings, never failures: the content plays, as it would on the site.
Real output, on the demo's
markup.h5p:Testing
pnpm testinpackages/verify: 11 passed (6 before), andpnpm typecheck. New cases, all against the workspace's own pack on disk, so none needs the network:progressTypeis not an option: passes, reportsmarkup removed: <form>, <input>and"bogus" became "textual", and captures the runtime's note;carried, and the summary's fix; trusted, it passes;contentChangeson its own: markup, removed fields, shortened lists, values, empty values left out.With the line that hands
untrustedto the element disabled, the three untrusted cases fail.Not covered
text rewritten.Release
A minor of
@missing-elements/h5p-verify(0.2.0): a new option and new report fields, nothing removed. No other package changes.🤖 Generated with Claude Code