Skip to main content

deptective

Project description

Deptective

PyPI version Tests Slack Status

What? Deptective automatically determines the native dependencies required to run any arbitrary program or command.

How? Deptective runs the command, observing which nonexistent files it attempts to open. If the command fails, Deptective attempts to install the dependencies that provide the nonexistent files, and runs the command again. If installing a dependency does not change the observable behavior of the command, then Deptective backtracks and tries a different dependency. This process continues until either the command succeeds or there are no more dependencies that could provide a missing file.

Quickstart ๐Ÿš€

$ pip3 install deptective

Running it ๐Ÿƒ

You simply point deptective to any executable, script, or shell command:

$ deptective cat /usr/bin/transmission-gtk
[10:10:44] INFO     Copying source files to the container...                      dependencies.py:546
           INFO     Updating apt sources...                                       dependencies.py:553
[10:10:58] INFO     Installing coreutils into de790cc40abe...                     dependencies.py:575
[10:11:10] INFO     Installing transmission-gtk into 0b26c0931f9f...              dependencies.py:575
๐Ÿ”Ž cat                       โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”              0%   -:--:--   0/2
1 ๐Ÿ’พ transmission-gtk        โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”                             0/?
[10:12:11] INFO     Satisfying dependencies: ๐Ÿ’พ transmission-gtk                           cli.py:304
                    Install with: apt-get install transmission-gtk

Say you download some source code that you need to build with GNU autotools. Simply run

$ deptective ./configure

and Deptective will automatically determine all of the requirements necessary to build the code!

If you know the specific file you are missing and you want to see all of the packages that provide that file, you can use the -s option:

$ deptective -s /usr/bin/transmission-gtk
[10:13:02] INFO     Packages providing /usr/bin/transmission-gtk: transmission-gtk         cli.py:276

By default, Deptective returns the first satisfying set of dependencies it discovers. This is not guaranteed to be the smallest satisfying set of dependencies (i.e., it may include unnecessary dependencies). Deptective can enumerate an arbitrary number of results with the -n argument.

Prerequisites ๐Ÿงฉ

Depective uses Docker to snapshot installation state, avoid polluting the host system with unnecessary dependencies, and investigate dependencies across different distributions.

If running from Linux, Deptective defaults to checking for dependencies on the host's distribution, architecture, and package manager, if possible. If running from a different operating system, Deptective defaults to searching for dependencies on the latest version of Ubuntu using apt. Package managers, operating systems, releases, and architectures can be specified through command line arguments (see deptective --help).

A list of all supported operating systems, releases, and architectures can be enumerated with the deptective --list command.

Caveats and Troubleshooting โš ๏ธ

Log Directory for Debugging ๐Ÿ“Š

Deptective can save logs and runtime artifacts to a specified directory using the --log-dir option. This is especially useful for debugging failed dependency resolution attempts, as it will preserve information about partial results and command outputs.

$ deptective --log-dir ./debug-logs ./configure

If the log directory already exists, you can use the --force option to overwrite it:

$ deptective --log-dir ./debug-logs --force ./configure

If no log directory is specified, Deptective will create a temporary directory and report its location when errors occur.

Host System Paths ๐Ÿ“‚

As mentioned above, Deptective does its analysis within Docker containers. Deptective will automatically copy its current working directory on the host system into /workdir/ inside the container. This means that if the command being inspected references files with absolute paths and/or files that are not in the directory subtree rooted at $PWD, the command will likely fail. There are plans to address this in a later version of Deptective.

Package Index Cache ๐Ÿ“‡

Deptective builds a package index cache mapping file paths to packages that provide them the first time it is run. However, package databases like apt are constantly changing, with vulnerable packages being yanked and new packages added. You can force a rebuild of the package index cache by running deptective --rebuild.

Path Testing Latency โณ

Deptective uses the Docker API to test the existence of files accessed by the target command. On certain Docker configurationsโ€”particularly when macOS is the host OSโ€”, this can be very slow. A different, faster mechanism for testing files will be added in a future release.

Contact ๐Ÿ’ฌ

If you'd like to file a bug report or feature request, please use our issues page. Feel free to contact us or reach out in Empire Hacking for help using or extending Deptective.

License ๐Ÿ“

This utility was developed by Trail of Bits. It is licensed under the GNU Lesser General Public License v3.0. Contact us if you're looking for an exception to the terms.

ยฉ 2025, Trail of Bits.

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

deptective-0.1.0.tar.gz (29.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deptective-0.1.0-py2.py3-none-any.whl (32.4 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: deptective-0.1.0.tar.gz
  • Upload date:
  • Size: 29.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for deptective-0.1.0.tar.gz
Algorithm Hash digest
SHA256 91c9ce94d9ed573ade2403073d46b6ea473ee0f0ac72ba1416db8bcdd8962ed2
MD5 4f997334264b33097de957ee37bd5147
BLAKE2b-256 121d0fec13d9b3eb363fafa33bab4cd0fbd73441987fd9fca0ba397639e4b670

See more details on using hashes here.

Provenance

The following attestation bundles were made for deptective-0.1.0.tar.gz:

Publisher: release.yml on trailofbits/deptective

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deptective-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: deptective-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 32.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for deptective-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d5f692690317a647e3bb8d4656da0e97259579e4ceba551837a4355a0adf865c
MD5 e7bccc4afbcd37884d9fa1d75ac78e73
BLAKE2b-256 0b6f5acb815a5455d9f14418e1e07af78fba471b43c19a705eb5953f6d982c41

See more details on using hashes here.

Provenance

The following attestation bundles were made for deptective-0.1.0-py2.py3-none-any.whl:

Publisher: release.yml on trailofbits/deptective

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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