When Pysa developers are working on a rule, they often look at a function in code such as:
def foo(arg):
pass
If they want to write a model for that function, they need to figure out the fully qualified name for that function, so that they can write a model like this:
It would be really convenient if they could just right click on the function itself, and auto-generate the model. Ideally, if a user right clicked on foo and chose "Generate Pysa Model", this would be placed on their clipboard:
def module.file.foo(arg): ...
They could then paste that in some .pysa file, and add their TaintSource/TaintSink annotations.
In there you can see module.Class.__init__ is the fully qualified name of the function I was looking for. You'll need to extract that. It might be worth modifying pyre query to have a more specific API you can query so you don't have to do the extraction within the plugin itself.
Create a Pysa model using the fully qualified function name
When Pysa developers are working on a rule, they often look at a function in code such as:
If they want to write a model for that function, they need to figure out the fully qualified name for that function, so that they can write a model like this:
It would be really convenient if they could just right click on the function itself, and auto-generate the model. Ideally, if a user right clicked on
foo
and chose "Generate Pysa Model", this would be placed on their clipboard:They could then paste that in some
.pysa
file, and add theirTaintSource
/TaintSink
annotations.To implement this you'll probably need to:
pyre query "types('module/file.py')" | jq
will give something like this:module.Class.__init__
is the fully qualified name of the function I was looking for. You'll need to extract that. It might be worth modifyingpyre query
to have a more specific API you can query so you don't have to do the extraction within the plugin itself.showInformationMessage
here: https://code.visualstudio.com/api/references/vscode-api