Repository navigation
harden(policy/django): deny the Django startup hooks inside apps/** - #124
Merged
Merged
Conversation
The policy's summary promises that "anything that runs at manage.py startup stays off-limits", and it denies **/conftest.py on exactly that reasoning — code that executes on import has a far larger blast radius than app code. AppConfig.ready() in apps.py, and the signal handlers it imports, run on every boot: every manage.py invocation, every worker, every test session. Both live under apps/**, which is otherwise allowed, so the promise did not hold for the two files that most obviously break it. Adds them to forbidden_paths and declares apps/billing/apps.py in @Policy blocks, so tests/test_policy_registry.py proves the deny through the real evaluate_contract rather than asserting it in a comment.
Signetry Reviewer — 🟡 Needs human reviewA human should decide — the required check is pending. Deterministic gates (the authority)
FindingsNo issues found by the deterministic scanners. MergeA human should review and merge.
|
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.
Follow-up to #123, which I reviewed and merged. The policy is sound; this closes one gap between what it promises and what it enforces.
The gap
django.yaml's summary says "Migrations, production settings and anything that runs at manage.py startup stay off-limits", and it denies**/conftest.pyon exactly that reasoning — code that executes on import has a far larger blast radius than app code.But
AppConfig.ready()inapps.py, and the signal handlers it imports, run on every boot: everymanage.pyinvocation, every worker, every test session. Both live underapps/**, which is otherwise allowed — so the promise did not hold for the two files that most obviously break it.Verified against the real
evaluate_contractbefore the change:and after:
Evidence, not assertion
apps/billing/apps.pyis added to@policy blocks, sotests/test_policy_registry.pyproves the deny through the production evaluator rather than trusting a comment — the registry's own rule.Deliberately left alone
admin.pyandmanagement/commands/**stay admitted. Neither runs at startup, both are ordinary app code an agent should be able to write, and blocking them would be redesigning the contributor's policy rather than closing the gap it named.