Plugin surface check: from X import Y is recorded as X, so the surface is refused and allowances admit whole packages #606
Labels
No labels
accessibility
authentication
breaking change
bug
documentation
enhancement
interface
internationalisation
observability
performance
security
tier
1
tier
2
tier
3
tier/4
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Postulo/postulo#606
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found on 2026-09-29 in a read-only review of postulo at
95348908d, runningpostulo.plugins.testingagainst a small package of import spellings.Checked again on 2026-10-01 against
mainat0a5cad587: still present.imports_inrecordsnode.modulefor everyfrom X import Yand neverX.Y. Two things follow.from postulo.plugins import api, which is the spelling the core's own tests use, is reported as reaching past the surface, aspostulo.plugins. And in the other direction an allowance is coarser than it reads:from postulo.core import site, modelsis recorded aspostulo.corealone, so an entry allowingpostulo.core"forsite" lets every other module ofpostulo.corethrough unreported.plugins/testing.py:74-90(imports_in:names = [module]for anImportFrom);plugins/testing.py:107-114(reaching_past_the_surface); the coarse allowances already in use attests/test_plugin_surface.py:51-108(REACHING_PAST:email,own_mail,smtpandpostal_ruleseach allowpostulo.corefor one or two named modules).from postulo.plugins import apiandfrom postulo import pluginsgivesreaching_past_the_surface(...) == ['postulo', 'postulo.plugins']. A second file withfrom postulo.core import site, modelsandfrom postulo.plugins import base, registry, checked withallowed={"postulo.core": "site"}, reports neithermodelsnorbasenorregistryby name: onlypostulo.plugins, and nothing at all formodels.tests/test_surface.pyin postulo-apprise, -dav, -helloworld, -imap and -paperless). An author who imports the surface the way the core's tests do gets a false failure; one who silences it by allowingpostulo.pluginshas allowedpostulo.plugins.base,registryandinstallingtoo. The core's ownREACHING_PASTentries document one module each and admit the whole package.ImportFrom, recordf"{module}.{alias.name}"for each imported name (keepingmoduleitself only forimport *), and treat a name as within an allowance when it equals the allowance or starts with it plus a dot. Thenfrom postulo.plugins import apiisSURFACE,from postulo.core import siteispostulo.core.site, and theREACHING_PASTentries can name the module they mean (postulo.core.site,postulo.core.mail_auth,postulo.core.phones).Done when
tests/test_plugin_surface.pyhas a test thatfrom postulo.plugins import apipassesassert_imports_only_the_surface, and one thatfrom postulo.core import site, modelswithallowed={"postulo.core.site": "…"}reportspostulo.core.models.