Repository navigation
feat: recognise validators declared on project functions - #139
Merged
Merged
Conversation
# Conflicts: # CHANGELOG.md
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 #134 together with #138; this is the validator half.
Problem
healthchecks guards
redirect(redirect_url)(hc/accounts/views.py:115) with_allow_redirect(redirect_url), a function of the same module that accepts relative URLs resolving to a known route. The refutation looks aValidatorup by the callee's symbol, but a call to a function of the same module has none: its target is a known function, loaded as a global. A project therefore had no way to declare its own validator.Change
python.<module>.<qualified name>, asproject_symbolbuilds it). AValidator, or anAuthorizationGuard, declared on that symbol applies in the function's own module, as it already did where the function is imported.enterprise-validators(CoreTrace-Entreprise/coretrace-python-analyzer-plugins#25) will let a project declare them.Verification
pytest: 1068 passed.ruff check src testsandmypyare clean.pytest -m regressionunder Python 3.12: 19 passed, no snapshot changed._allow_redirecton a healthchecks-like module left the open redirect. Both were red for that reason. An undeclared function, or one declared for another module, stays a hotspot.