A javascript: URL runs its text as code when it is followed
What it finds
<a href="javascript:void(0)">, location.href = "javascript:" + code: a javascript: URL runs its text as code when followed. It is a form of eval, it is blocked by content security policies, and React warns that it will stop rendering such URLs. A button with a click handler does the same without a URL.
Reported are string literals that start with javascript:, ignoring case and leading spaces, given to the JSX attributes href, src, action and formAction, or assigned, alone or at the start of a concatenation, to location or to a member named href, src, action or location. Other strings, as those a sanitizer compares URLs with, are left alone.
From the rule's source, script_url.rs.
Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:script-url" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:script-url] reason="..."tx0 explain tx0/ts:script-url shows the same in the terminal. Found a false positive? Report it.