Skip to main content

Statically analyze sources and extract information about called and exported library functions in Python applications

Project description

A simple tool to gather symbols provided or library calls and attribute usage based on static analysis of sources of Python applications.

Installation

Invectio can be installed from PyPI using:

$ pip3 install invectio
$ invectio --help

Usage

You can use this library as a CLI tool or as a Python module:

invectio whatprovides project-dir/   # To scan all Python files recursively for symbols provided.
invectio whatprovides app.py         # To perform symbols gathering on app.py file.

invectio whatuses project-dir/       # To scan all Python files recursively for symbols used from libraries.
invectio whatprovides app.py         # To perform gather symbols used from libraries on app.py file.
from invectio import gather_library_calls
from invectio import gather_symbols_provided

result: dict = gather_library_usage("project-dir")
result: dict = gather_library_usage("app.py")

result: dict = gather_symbols_provided("project-dir")
result: dict = gather_symbols_provided("app.py")

Limitations

As Python is a dynamic programming language, it’s not possible to obtain all library functions/attributes usage simply by performing static analysis of sources. One can still perfom “crazy” things like:

import tensorflow

getattr(tensorflow, "const" + "ant")("Hello, Invectio")

This library does its best to detect all function/attributes being used inside Python sources, but usage like shown above cannot be detected simply by static analysis of source code.

Development

To create a dev environment, clone the invectio repo and install all the dependencies:

git clone https:://github.com/thoth-station/invectio && cd invectio
pipenv install --dev

To perform checks against unit tests present in the tests/ directory, issue the following command from the root of the git repo:

pipenv run python3 setup.py test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

invectio-0.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

invectio-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file invectio-0.1.0.tar.gz.

File metadata

  • Download URL: invectio-0.1.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8

File hashes

Hashes for invectio-0.1.0.tar.gz
Algorithm Hash digest
SHA256 831b5de477e76fa07ed81b298cddf55b9886c0124217442cae21d8bb90e191ca
MD5 b9c6929b8d8d28c4381c7a24dcdd3b8c
BLAKE2b-256 94c58e03315ef183034161478af04ca8c4a81bd86d6828beae06d9f538755765

See more details on using hashes here.

File details

Details for the file invectio-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: invectio-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8

File hashes

Hashes for invectio-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a720cc25cd8390af8555fd68a36e6a119f45a7870a31b818922342015c9b912
MD5 b7e501abc800f21ab2dc1ba1aea2deda
BLAKE2b-256 7a5700ed9b7f373b614ddf2970aafcfe03ebddc762da7fc65851c2f6a02871db

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page