Skip to content

feat: recognise validators declared on project functions - #139

Merged
SizzleUnrlsd merged 3 commits into
mainfrom
feat/project-validators
Sep 25, 2026
Merged

SizzleUnrlsd merged 3 commits into
mainfrom
feat/project-validators

Conversation

@SizzleUnrlsd

Copy link
Copy Markdown
Contributor

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 a Validator up 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

  • Project callees get a symbol. The refutation now names each call to a function of the analysed module by its project symbol (python.<module>.<qualified name>, as project_symbol builds it). A Validator, or an AuthorizationGuard, declared on that symbol applies in the function's own module, as it already did where the function is imported.
  • Nothing changes by itself. The corpus snapshots are unchanged, because no bundled model names a project function. enterprise-validators (CoreTrace-Entreprise/coretrace-python-analyzer-plugins#25) will let a project declare them.
  • Not done: validators still do not apply through summaries, to callers of a function that validates before its sink. No corpus case needs it: line 115 is a direct flow.

Verification

  • pytest: 1068 passed. ruff check src tests and mypy are clean.
  • pytest -m regression under Python 3.12: 19 passed, no snapshot changed.
  • Tests. Before the change, a declared project validator left a hotspot, and a plugin declaring _allow_redirect on 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.
  • Mutation check. Going back to the call graph's symbols alone fails 2 tests.

@SizzleUnrlsd SizzleUnrlsd self-assigned this Sep 24, 2026
@SizzleUnrlsd
SizzleUnrlsd merged commit d0d1ef0 into main Sep 25, 2026
10 checks passed
@SizzleUnrlsd
SizzleUnrlsd deleted the feat/project-validators branch September 25, 2026 00:11
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.

Precision: validators and sanitizers apply through project functions

1 participant