Pysa¶
The Python Static Analyzer Pysa performs taint analysis to identify potential security problems. Pysa traces data streams from their origin to their endpoint and identifies vulnerable code.
Configuration¶
Pysa uses two file types for configuration:
a
taint.configfile in JSON format, in whichsources,sinks,featuresandrulesare defined.{ "comment": "UserControlled, Test, Demo sources are predefined. Same for Demo, Test and RemoteCodeExecution sinks", "sources": [], "sinks": [], "features": [], "rules": [] }
files with the extension
.pysain a directory configured withtaint_models_pathin your.pyre_configurationfile.
You can find practical examples in the Pyre repository.
Use¶
Pyre can be called, for example with
$ $ uv run pyre analyze --save-results-to ./
The --save-results-to option stores detailed results in
./taint-output.json.
Pysa postprocessor¶
Installation¶
$ uv add fb-sapp
Use¶
Parsing the JSON file, for example with
$ uv run sapp --database-name sapp.db analyze ./taint-output.json
The results are stored in the local SQLite file
sapp.db.Exploring the problems with
$ uv run sapp --database-name sapp.db explore
This starts an IPython interface connected to the SQLite database:
issueslists all issues
issue 1selects the first issue
traceshows the data flow from
sourcetosinknjumps to the next call
listshows the source code of the call
jump 1jumps to the first call and shows the source code
Further commands can be found in the SAPP Command-Line Interface.