From a89e5a880c4f27c816134a8a898eb90e19917873 Mon Sep 17 00:00:00 2001 From: mr-pmillz <58376398+mr-pmillz@users.noreply.github.com> Date: Sun, 27 Sep 2026 17:50:01 -0400 Subject: [PATCH] Fix default wordlist path under uv run and package fuzz.txt The default -m/-b wordlist path was derived from sys.argv[0], which under `uv run cloud_enum` is the console-script shim in .venv/bin. The default became .venv/bin/enum_tools/fuzz.txt, so the tool exited with "Cannot access brute-force file" even when -m was passed. Resolve it from the module's own __file__ instead. fuzz.txt was also never declared as package data, so clean wheel builds (uv tool install, pip install .) shipped without it. Declare it under [tool.setuptools.package-data]. Add a regression test that runs parse_arguments with argv[0] pointing at a venv shim. Co-Authored-By: Claude Opus 5.5 --- cloud_enum.py | 5 +++-- pyproject.toml | 3 +++ tests/test_cloud_enum.py | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 tests/test_cloud_enum.py diff --git a/cloud_enum.py b/cloud_enum.py index 8746d42..e4340a5 100755 --- a/cloud_enum.py +++ b/cloud_enum.py @@ -34,8 +34,9 @@ def parse_arguments(): desc = "Multi-cloud enumeration utility. All hail OSINT!" parser = argparse.ArgumentParser(description=desc) - # Grab the current dir of the script, for setting some defaults below - script_path = os.path.split(os.path.abspath(sys.argv[0]))[0] + # Grab the install dir of this module, for setting some defaults below. + # Not sys.argv[0]: console-script entry points live in the venv's bin dir. + script_path = os.path.dirname(os.path.abspath(__file__)) kw_group = parser.add_mutually_exclusive_group(required=True) diff --git a/pyproject.toml b/pyproject.toml index 34cd28a..a068023 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,9 @@ dev = [ py-modules = ["cloud_enum"] packages = ["enum_tools"] +[tool.setuptools.package-data] +enum_tools = ["fuzz.txt"] + [build-system] requires = ["setuptools>=61"] build-backend = "setuptools.build_meta" diff --git a/tests/test_cloud_enum.py b/tests/test_cloud_enum.py new file mode 100644 index 0000000..9ec190c --- /dev/null +++ b/tests/test_cloud_enum.py @@ -0,0 +1,18 @@ +import os +import sys + +import cloud_enum + + +def test_default_wordlists_resolve_when_run_as_console_script(monkeypatch): + """ + `uv run cloud_enum` launches the console-script shim in .venv/bin, so the + default wordlists must not be located relative to sys.argv[0]. + """ + shim = os.path.join(os.sep, 'nonexistent', '.venv', 'bin', 'cloud_enum') + monkeypatch.setattr(sys, 'argv', [shim, '-k', 'test']) + + args = cloud_enum.parse_arguments() + + assert os.access(args.mutations, os.R_OK) + assert os.access(args.brute, os.R_OK)