Resolve concatenation in the html-safety check, and empty the baseline - #54
Merged
Conversation
Port of ALEAPP #1045. Every baselined entry in this core turned out to be a false positive rather than an unescaped sink, so the baseline goes to zero. The check did not resolve `+` chains, so an accumulator read as unknown even when every write to it was escaped. It now resolves a concatenation when both sides resolve, with the self-reference terminating through the existing `seen` set. Accumulate-then-emit is how most of these builders work, so this was the single largest source of noise. media_to_html assigned `source` four times and then emitted it. The final write was safe_local_path() and nothing read it earlier, so the function was correct, but a name counts as safe only when every assignment to it is -- this check does not order assignments. The escaped values now bind to their own names, safe_source and safe_filename, which makes the safety local and obvious to a reader as much as to the checker. Also corrects the docstring: a dynamic destination may come from safe_local_path() as well as safe_local_link(). Validated: py_compile clean; lint_changed reports no new warnings; unit tests OK; PluginLoader loads every plugin; the check exits 0 with 0 baselined, and still exits 1 on injected probes -- including an unescaped accumulator concat, which confirms the relaxation above did not blind it to the real thing. Co-Authored-By: Claude Opus 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.
Port of ALEAPP #1045. Every baselined entry in this core turned out to be a false positive rather than an unescaped sink, so the baseline goes to zero.
The checker gap
It did not resolve
+chains at all, so an accumulator read as unknown even when every write to it was escaped:It now resolves a concatenation when both sides resolve, with the self-reference terminating through the existing
seenset. Accumulate-then-emit is how most of these builders work, so this was the single largest source of noise.This does not weaken the check. The regression probe includes an unescaped accumulator concat, and it is still caught.
media_to_htmlsourcewas assigned four times and then emitted. The final write wassafe_local_path()and nothing read it earlier, so the function was correct — but a name counts as safe only when every assignment to it is, because this check does not order assignments.The escaped values now bind to their own names,
safe_sourceandsafe_filename. That makes the safety local and obvious to a reader as much as to the checker, which is the better shape regardless of tooling.Validation
py_compileclean;lint_changedreports no new warningsPluginLoaderloads every plugin🤖 Generated with Claude Code