Repository navigation
Description
The problem
Since 0.7.0, the render-time checks security_csp and security_javascript report a javascript: URL that an SVG <animate> or <set> (elements that change another attribute while the page is open) writes into a link, such as <set attributeName="href" to="javascript:...">, the same way they report href="javascript:..." (changelog, security page).
citry check and the editor apply the same rule to the attributes a template writes, so a problem shows before a page renders. They check each attribute on its own, so they cannot see that a to value belongs to an animation of href. A template that writes this outside a <c-raw> block passes both. Only a page render with the check turned on reports it.
Like the other strict CSP problems, the template rule runs when security_csp is "warn" or "strict" and your app is loaded. citry check --static does not load the app, so it reports none of them. Setting only security_javascript does not turn the template rule on.
What we want
citry check and the editor report this element in a template, with the same wording and the same rule as the page check. The rule stays in one function that both call, with no second copy to keep in step.
Plan before code
csp_attribute_problem(tag, name, raw_value) in output_policy.rs judges one attribute. The animation rule needs the element's other attributes (attributeName), or a flag the caller works out first. That changes a function that Python can call (a PyO3 signature; PyO3 is the library that exposes Rust functions to Python), so it needs a written plan before code (CLAUDE.md, Mechanism 2, and the cross-binding audit in Mechanism 4): prior art, the chosen design, one or two alternatives, and what result would show the design is wrong.
Everything that moves with it:
- the Rust function and its cases (
ATTRIBUTE_CASES); - the PyO3 wrapper in
crates/citry_core_py/src/html_transform.rsand itsAGENTS.md; - the
_rust.pyistub and thecitry_core.html_transformwrapper; test_html_transformer.py;- the caller in
_markup_lint.py; - the strict CSP section of the template-linting page, and the changelog of
citryandcitry-core.
Error modes to settle
attributeNameset by ac-binding (so unknown when the template is read): not reported by the template rule. The page check still reports the rendered result.- A Vue
:attributeNameor:to: neither the template rule nor the page check sees what Vue builds in the browser. The security page already says so. - A
to,from,byorvaluesthat holds extension syntax is known only after the extension runs: skip it, as the lint does for ajavascript:value that holds extension syntax. - Letter case and spellings (
HREF,xlink:href) follow the page check. valuesis a list separated by;: each item is judged, as in the page check.
Done when
- A written plan is reviewed, with the list above filled in.
-
citry checkand the editor report<set attributeName="href" to="javascript:...">and the<animate>forms, and do not report an animation of another attribute. - The Rust, Python and editor tests cover each case in "Error modes to settle".
Activity