Skip to main content

Python

This article shows you how to analyze your applications written in Python using preZero.

Requirements

See Prerequisites for more information.

Analyzing your Python application

sl analyze --app <name> --pythonsrc [<path>]
ParameterDescription
--app <name>The name of the application to be analyzed
--pythonsrcThe flag identifying the application as written in Python
<path>The path to the Python application to be analyzed

Additional parameters

The analysis accepts additional parameters after a double hyphen --.

Additional parameterDescription
--ignore-pathsIgnores the specified paths from the analysis. Accepts both absolute and relative file paths; relative file paths are interpreted in relation to the directory provided as part of sl analyze...
--ignore-dir-namesExcludes all files where the relative path (from directory provided in sl analyze) contains at least one of names specified here

Such parameters, if valid, are passed directly to the Python analyzer.

Sample usage of additional parameters

To ignore a specific path from the analysis:

sl analyze --app <name> --pythonsrc [<path>] -- --ignore-paths [<path>]

SCA

To identify open-source vulnerabilities, Qwiet preZero automatically searches for build manifests in the project path you provided when running sl analyze. However, depending on your build system you may need to run an additional step before invoking sl - specifically, sl supports requirements.txt and poetry.lock files. You can generate the former e.g. with pip freeze > requirements.txt - from your activated venv. And poetry lock generates the latter.

Analyzing Jupyter notebooks

To submit a Jupyter notebook for analysis with preZero, you must first convert all of your .ipynb files to .py files:

# convert the notebooks (*.ipynb) into Python files (*.py)
jupyter nbconvert --to python *.ipynb

# analyze the Python files with preZero
sl analyze --app ipynb-pythonsrc --pythonsrc .