Skip to content

feat(verify): check a package the way a site plays it untrusted - #39

Merged
alekswebnet merged 3 commits into
mainfrom
feat/verify-untrusted
Oct 17, 2026
Merged

alekswebnet merged 3 commits into
mainfrom
feat/verify-untrusted

Conversation

@alekswebnet

Copy link
Copy Markdown
Contributor

Closes #38

h5p-verify --untrusted plays 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 (and untrusted: true for verifyPackage) sets the element's untrusted. The report's untrusted is read back from the element, not copied from the option. Libraries come from --libraries, or the element's own pack.

  • 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.json through the frame with X-H5P-Content-Check: semantics (the worker hands it over as written) and compares it with the parameters the boot script left in H5PIntegration. contentChanges reports, by JSON path:

    • tags removed, by name;
    • attributes and style properties removed, counted only on tags that survived, so a form removed whole is one line;
    • fields and list items removed, values changed.

    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.contentCheck and as warnings, capped at 20 lines with the rest in report.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, the h5p-verify skill (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:

pass  markup.h5p  ready in 0.83 s  revision sha256:c4fd49473b30cd97…
  warning: content check: content[1].content.params.text: style removed: position, right, bottom, z-index, max-width, padding, border-radius, box-shadow, font-weight
  warning: content check: content[2].content.params.text: markup removed: <form>, <label> ×2, <input> ×2, <button>
  warning: content check: content[3].content.params.text: attributes removed: style; style removed: display, padding, border-radius, background-color, color, text-decoration

Testing

pnpm test in packages/verify: 11 passed (6 before), and pnpm typecheck. New cases, all against the workspace's own pack on disk, so none needs the network:

  • a quiz whose question holds a form and whose progressType is not an option: passes, reports markup removed: <form>, <input> and "bogus" became "textual", and captures the runtime's note;
  • the quiz as it is, untrusted: passes with no changes and no warnings;
  • the quiz built against a Question Set 1.99: refused untrusted with carried, and the summary's fix; trusted, it passes;
  • a bundle path that does not exist: refused before a browser starts;
  • contentChanges on its own: markup, removed fields, shortened lists, values, empty values left out.

With the line that hands untrusted to the element disabled, the three untrusted cases fail.

Not covered

  • Changes from the content upgrade. It runs before the check and can move fields when the pack is newer than the content; such a change is reported without saying which of the two made it. Markup is always the check's.
  • Fields the check rewrites without removing markup, such as an entity escaped or a URL dropped. They show as 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

alekswebnet and others added 2 commits October 18, 2026 02:07
--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>
Comment thread packages/verify/lib/verify.mjs Fixed
`/<[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>
@alekswebnet
alekswebnet merged commit 58882c5 into main Oct 17, 2026
7 checks passed
@alekswebnet
alekswebnet deleted the feat/verify-untrusted branch October 18, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

h5p-verify: check a package the way a site plays it untrusted

2 participants