trustedsec / trustedsec/hate_crack
main.py's sys.path.insert block looks vestigial too, and its comment is wrong
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.9k
- Forks
- 284
- Avg merge
- 21m
- Merged PRs (30d)
- 14
Description
Follow-up to #298, deliberately left out of that change's scope.
#298 removed the __path__ shim from hate_crack/main.py. The sys.path.insert block immediately above it is a separate question that the same investigation raised but did not settle:
# Ensure project root is on sys.path so package imports work when loaded via spec.
_root_dir = os.path.dirname(os.path.realpath(__file__))
if _root_dir not in sys.path:
sys.path.insert(0, _root_dir)
The comment is factually wrong. os.path.dirname(os.path.realpath(__file__)) for hate_crack/main.py is the package directory, not the project root. Inserting it enables flat import api-style imports, which is not what the comment describes and not what the file does.
It may be unnecessary. Every import in main.py is either stdlib or an absolute hate_crack.X import; there are no flat or relative imports. The HashcatRosetta import does its own independent sys.path.insert(0, ROSETTA_DIR) and does not depend on this block.
Why it wasn't removed with the shim. It has a larger blast radius than the __path__ removal. Putting a directory on sys.path affects resolution for everything imported afterwards in the process, not just this module, so removing it wants its own verification pass rather than riding along on an unrelated fix.
What would close this
- Remove the block and run the full suite, plus the opt-in installed-path check that #298 used:
HATE_CRACK_RUN_E2E=1 HATE_CRACK_SKIP_INIT=1 uv run pytest tests/test_help_before_build.py tests/test_e2e_local_install.py. That suite genuinely runs and covers the by-path and installed load paths. - If it still passes, remove it.
- If it breaks, keep it and fix the comment to say what it actually does and which import chain needs it, so the next person does not re-derive this.
Either way the wrong comment should not survive.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the sys.path.insert block in hate_crack/main.py and verify the import paths it affects. Remove it, then run the full suite and HATE_CRACK_RUN_E2E=1 HATE_CRACK_SKIP_INIT=1 uv run pytest tests/test_help_before_build.py tests/test_e2e_local_install.py. Done means the checks pass without the block; if they fail, retain it and correct its comment to describe its actual purpose.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100