mirror of
https://github.com/trustedsec/hate_crack.git
synced 2026-07-28 14:47:22 -07:00
Revert ancestor asset lookup
This commit is contained in:
@@ -113,7 +113,6 @@ hate_crack
|
||||
|
||||
The tool will automatically search for these assets in:
|
||||
- Directory specified by `hcatPath` in `config.json` when it points to the hate_crack checkout that contains the assets
|
||||
- Ancestors of the installed package directory (e.g., the uv tool root that still contains the original `hashcat-utils`/`princeprocessor` directories)
|
||||
- Current working directory and parent directory
|
||||
- `~/hate_crack`, `~/hate-crack`, or `~/.hate_crack`
|
||||
|
||||
@@ -123,7 +122,7 @@ cd /path/to/hate_crack
|
||||
hate_crack <hash_file> <hash_type>
|
||||
```
|
||||
|
||||
If assets live somewhere else, make sure `config.json` uses that directory for `"hcatPath"` before running.
|
||||
To keep `uv tool install .` happy, point `hcatPath` in `config.json` at the directory that contains `config.json`, `hashcat-utils/`, and `princeprocessor/` before running the installed command.
|
||||
|
||||
**Note:** The `hcatPath` in `config.json` is for the hashcat binary location (optional if hashcat is in PATH), not for hate_crack assets.
|
||||
|
||||
|
||||
@@ -81,20 +81,6 @@ def _has_hate_crack_assets(path):
|
||||
)
|
||||
|
||||
|
||||
def _find_assets_in_ancestors(start_path):
|
||||
current = os.path.abspath(start_path)
|
||||
seen = set()
|
||||
while current not in seen:
|
||||
if _has_hate_crack_assets(current):
|
||||
return current
|
||||
seen.add(current)
|
||||
parent = os.path.abspath(os.path.join(current, os.pardir))
|
||||
if parent == current:
|
||||
break
|
||||
current = parent
|
||||
return None
|
||||
|
||||
|
||||
def _resolve_hate_path(package_path, config_dict=None):
|
||||
# Try to use hcatPath from config.json if it's set and contains assets
|
||||
if config_dict and config_dict.get('hcatPath'):
|
||||
@@ -102,11 +88,6 @@ def _resolve_hate_path(package_path, config_dict=None):
|
||||
if _has_hate_crack_assets(assets_path):
|
||||
return assets_path
|
||||
|
||||
# When installed via uv, the assets live above the package directory in the tool root.
|
||||
ancestor_assets = _find_assets_in_ancestors(package_path)
|
||||
if ancestor_assets:
|
||||
return ancestor_assets
|
||||
|
||||
# Check current working directory and parent (look for repo directory)
|
||||
cwd = os.getcwd()
|
||||
for candidate in [cwd, os.path.abspath(os.path.join(cwd, os.pardir))]:
|
||||
|
||||
@@ -103,18 +103,3 @@ def test_readme_documents_correct_usage():
|
||||
# Should NOT suggest putting hashcat-utils in hashcat directory
|
||||
# (This is a documentation test to prevent confusing users)
|
||||
|
||||
|
||||
def test_resolve_hate_path_prefers_package_ancestors(tmp_path):
|
||||
"""Ensure package installs discover assets by walking up to the tool root."""
|
||||
from hate_crack.main import _resolve_hate_path
|
||||
|
||||
assets_root = tmp_path / "hate_crack_root"
|
||||
assets_root.mkdir()
|
||||
(assets_root / "hashcat-utils").mkdir()
|
||||
(assets_root / "config.json.example").write_text("{}")
|
||||
|
||||
package_path = assets_root / "lib" / "python3.14" / "site-packages" / "hate_crack"
|
||||
package_path.mkdir(parents=True)
|
||||
|
||||
resolved = _resolve_hate_path(str(package_path), config_dict={})
|
||||
assert resolved == str(assets_root)
|
||||
|
||||
Reference in New Issue
Block a user