Fix/latent nameerror bugs#537
Merged
Merged
Conversation
Four undefined-name bugs that would raise NameError at runtime, all in
error/edge paths where they'd mask the real failure:
- wpa.py: subprocess used in two except clauses but never imported
- interface_assignment.py: log_error used in handlers but not imported
- wpa3_tools.py: f-strings used {C}/{W}/{O} as variable interpolation
instead of literal color codes, breaking the tool-status report
- system_check.py: InterfaceManager referenced without import (chipset
detection silently failed)
Also make EvilTwinAttackState a TYPE_CHECKING import so the forward-ref
annotations resolve cleanly.
Test fixes:
- test_cleanup: patch subprocess at its real call site
(wifite.util.process) instead of a dead import in wifite.util.cleanup
- test_wpa3_detection_performance: replace three wall-clock ratio
assertions (intermittently failing, e.g. 1.57x < 2x) with
deterministic behavioural checks of the cache / early-return logic
Plus ruff safe autofixes: remove unused imports (incl. the ambiguous
HcxDumpTool import from hashcat, leaving the hcxdumptool one), drop
placeholder-less f-strings, and remove redundant local re-imports.
All 629 tests pass.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
| import time | ||
| import os | ||
| import re | ||
| import subprocess |
There was a problem hiding this comment.
Pull request overview
This PR focuses on eliminating latent NameError issues caused by unnecessary f-strings (notably around {C}/{W} color tokens), cleaning up unused imports, and introducing a new --kalidroid output mode that makes CLI output readable in Kalidroid’s MiniTerminal (append-only scrollback).
Changes:
- Fixed latent
NameErrorhazards by removing/adjusting f-strings that contained{C},{W}, etc. as literal color tokens. - Added
--kalidroidflag plus aColor.kalidroidrendering path to flatten carriage-return progress redraws into newline-terminated lines and disable clear-line behavior. - Reworked WPA3 “performance” tests to deterministic behavioral tests (cache short-circuiting / early-return) instead of wall-clock timing.
Reviewed changes
Copilot reviewed 52 out of 52 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| wifite/wifite.py | Removes unused imports tied to session/target conversion paths. |
| wifite/util/wpasec_uploader.py | Cleans up constant f-strings / logging call formatting. |
| wifite/util/wpa3_tools.py | Escapes literal color tokens inside f-strings to avoid NameError. |
| wifite/util/tui_logger.py | Removes unused time import. |
| wifite/util/system_check.py | Removes unused typing imports; fixes color-token printing and adds chipset mapping fallback. |
| wifite/util/session.py | Removes unused import; replaces constant f-strings with plain strings. |
| wifite/util/scanner.py | Removes unused imports and narrows logger imports in native scan path. |
| wifite/util/sae_crack.py | Removes unused imports/types and narrows tool imports. |
| wifite/util/retry.py | Removes unused typing imports. |
| wifite/util/process.py | Normalizes a constant f-string to a plain string in an error log call. |
| wifite/util/logger.py | Removes unused time import. |
| wifite/util/interface_manager.py | Removes unused typing imports and redundant tool import; normalizes constant f-strings. |
| wifite/util/interface_exceptions.py | Removes constant f-string to avoid latent formatting/name issues. |
| wifite/util/interface_assignment.py | Adds missing log_error import and removes constant f-strings. |
| wifite/util/dragonblood.py | Removes unused typing import. |
| wifite/util/dragonblood_timing.py | Removes unused typing import. |
| wifite/util/credential_validator.py | Removes unused Color import. |
| wifite/util/color.py | Implements Kalidroid MiniTerminal mode (Color.kalidroid) with throttled flattened progress lines and no-op clear-line behavior. |
| wifite/util/client_monitor.py | Removes unused datetime import. |
| wifite/util/cleanup.py | Removes unused imports (shifts toward Process.run_simple usage). |
| wifite/util/adaptive_deauth.py | Removes unused logger imports. |
| wifite/ui/scanner_view.py | Replaces constant f-strings in header rendering. |
| wifite/ui/components.py | Removes unused Rich imports and replaces constant f-strings. |
| wifite/ui/attack_view.py | Replaces constant f-strings in status/metrics strings. |
| wifite/tools/wlancap2wpasec.py | Removes unused Color import. |
| wifite/tools/hostapd.py | Removes unused typing import. |
| wifite/tools/hashcat.py | Removes redundant inner imports. |
| wifite/tools/airodump.py | Removes redundant inner import (module already imports csv). |
| wifite/native/wps.py | Removes unused imports/types. |
| wifite/native/scanner.py | Removes unused imports/types. |
| wifite/native/pmkid.py | Removes unused imports/types. |
| wifite/native/mac.py | Removes unused os import. |
| wifite/native/interface.py | Removes unused typing import(s). |
| wifite/native/deauth.py | Removes unused imports/types. |
| wifite/native/beacon.py | Removes unused typing import(s). |
| wifite/model/sae_handshake.py | Removes unused re import. |
| wifite/model/result.py | Removes unused glob import. |
| wifite/config/parsers/settings.py | Hooks --kalidroid into configuration parsing and keeps Color.kalidroid in sync. |
| wifite/config/init.py | Adds Configuration.kalidroid flag. |
| wifite/attack/wpa3.py | Removes unused import(s) in WPA3 attack flow. |
| wifite/attack/wpa.py | Cleans unused imports and adjusts local logger imports; adds subprocess import. |
| wifite/attack/wep.py | Removes unused logger imports. |
| wifite/attack/portal/templates.py | Removes unused typing/log imports. |
| wifite/attack/portal/server.py | Removes unused HTTPServer import. |
| wifite/attack/portal/credential_handler.py | Removes unused datetime import. |
| wifite/attack/pmkid.py | Removes unused native result alias and replaces constant f-strings. |
| wifite/attack/eviltwin.py | Removes unused imports and uses TYPE_CHECKING to avoid runtime import cycles. |
| wifite/attack/attack_monitor.py | Removes unused imports. |
| wifite/attack/all.py | Removes unused log_debug import. |
| wifite/args.py | Adds early activation + argparse support for --kalidroid. |
| tests/test_wpa3_detection_performance.py | Replaces timing benchmarks with deterministic cache/early-return behavioral tests. |
| tests/test_cleanup.py | Updates patch targets for subprocess calls (but needs additional patching for Process._resolve_tool). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| self.assertIn('error2', errors) | ||
|
|
||
| @patch('wifite.util.cleanup.subprocess.run') | ||
| @patch('wifite.util.process.subprocess.run') |
| mock_run.assert_called_once() | ||
|
|
||
| @patch('wifite.util.cleanup.subprocess.run') | ||
| @patch('wifite.util.process.subprocess.run') |
| self.assertIsInstance(conflicting, list) | ||
|
|
||
| @patch('wifite.util.cleanup.subprocess.run') | ||
| @patch('wifite.util.process.subprocess.run') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.