Skip to main content

Python

This article shows you how to analyze your applications written in Python using Qwiet AI by Harness.

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. Depending on your build system, you may need to generate a dependency file before running sl.

Currently, sl supports requirements.txt, poetry.lock, and uv.lock. Use the appropriate command for your package manager to generate the required file:

  • pip: Run pip freeze > requirements.txt from your activated virtual environment.
  • Poetry: Run poetry lock to generate a poetry.lock file.
  • uv: Run uv lock to generate a uv.lock file. If a lock file is not found, sl will attempt to parse the pyproject.toml (if it exists), but providing a uv.lock file is recommended.

Analyzing Jupyter notebooks

To submit a Jupyter notebook for analysis with Qwiet AI by Harness, 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 Qwiet AI by Harness
sl analyze --app ipynb-pythonsrc --pythonsrc .