Repository navigation
feat: give project plugins each module's functions with their span and entry point - #117
Closed
SizzleUnrlsd wants to merge 2 commits into
Closed
SizzleUnrlsd wants to merge 2 commits into
SizzleUnrlsd wants to merge 2 commits into
Conversation
Every function as the call graph names it, with its span and the label of the entry point it is: a Flask route, a Django view registered in another module, a route of an app made by a factory in another module, and the same answer from a module served from the cache. The cache codec tests build CachedModule from the new function records.
…d entry point A finding names its function by its bare name and the project context's call graphs carry no definitions, so a project plugin could not place a finding in the call graph, nor tell a route from a helper. ModuleFunction(name, span, entry_point) records each function as the call graph names it. EntryPointAnalysis decides the entry point with the taint engine's own rule, extracted from parameter_sources as function_entry_point, and is invalidated with the project summaries it reads. The records are cached with the module (format 6) and served by ProjectContext.functions(module). Closes #116
Contributor
Author
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 #116. Stacked on #115 (release 0.4.0): merge #115 first; GitHub then retargets this PR to
main, and its changelog entry sits under a newUnreleasedabove 0.4.0.Why
Needed by the enterprise
exposure-prioritizationplugin (CoreTrace-Entreprise/coretrace-python-analyzer-plugins#4). A project plugin could not place a finding in the call graph: findings carry bare function names (get, notAdmin.get), the context's call graphs are rebuilt from call sites without definitions (no spans), and nothing said which functions are entry points. The engine now provides those facts; the ranking policy stays in the plugin.What
ModuleFunction(name, span, entry_point)incoretrace_python.interprocedural: the call graph's name, the span, the entry point's label (http,argv, ...) orNone.function_entry_point(...)extracted fromparameter_sources(decorator or base matching anEntryPointmodel, or a registration elsewhere);parameter_sourcesnow calls it, behaviour unchanged.EntryPointAnalysis(taint.entry_points) applies it to every function of the module, with the factory instances and registered routes the taint engine uses. It reads the project summaries, so it joins the analysesProjectSummariesUpdatedinvalidates.CachedModule.functionsholds the records (cache format 5 → 6);ProjectContext.functions(module)serves them, falling back to the module's manager likecall_graph()does.Tests
tests/test_project.py: names, spans and labels of a Flask module (<module>,index=http,helper,Admin.get); a Django view registered inurls.pyishttp, an unregistered function is not; the route of an app built bycreate_app()in another module ishttp; a module served from the cache gives the same records. The two cache codec tests buildCachedModulefrom records (the heap one only checks summaries, so it passes none).932 passed; ruff and mypy clean. Plugin guide documents
ctx.functions(module)(and fixesctx.modules()→ctx.modules, a property).