Refactor: Fix bugs, improve path handling and UI consistency#2
Open
MohakGrover wants to merge 1 commit intoCodingRanjith:mainfrom
Open
Refactor: Fix bugs, improve path handling and UI consistency#2MohakGrover wants to merge 1 commit intoCodingRanjith:mainfrom
MohakGrover wants to merge 1 commit intoCodingRanjith:mainfrom
Conversation
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.
Overview
This PR introduces a significant refactor to the core logic and entry point of the cybersec tool. The primary goals were to resolve permission issues caused by hardcoded paths, fix UI inconsistencies, prevent potential crashes in long sessions, and improve cross-platform compatibility.
Key Changes & Improvements
Old Behavior: Hardcoded to /home/cybersec.txt and /home/cybersec. This restricted the tool to Linux systems and required root/sudo permissions for basic setup.
New Behavior: Now uses os.path.expanduser("~") to dynamically locate the user's home directory. This allows the tool to run on any OS and avoids permission errors by storing configurations in ~/.cybersec_path.txt and tools in ~/cybersec (by default).
2. Iterative Navigation System (Core Logic)
Old Behavior: The menu system used recursion (show_options calling itself). In deep or long-running navigation, this could lead to a RecursionError (Stack Overflow).
New Behavior: Rewrote the menu system using while True loops. This ensures the tool remains stable regardless of how long the user stays in the menus and simplifies the flow of "Back" navigation.
3. Graceful Dependency Handling
Issue: The tool relied heavily on external binaries like figlet, lolcat, and boxes. If these were missing, the tool would either crash, show command not found errors, or look broken.
Solution: Added a check_dependency utility using shutil.which. The tool now checks for these utilities before attempting to use them and automatically falls back to clean, standard text if they aren't available.
4. UI Bug Fixes & Consistency
Fixed Formatting: Resolved a missing closing bracket ] in the tool collection listing that caused misaligned displays.
Unified Indexing: Previously, some menus used 0-based indexing while others used 1-based. All menus have been unified to 1-based indexing for a consistent user experience.
5. Enhanced Cross-Platform Support
Old Behavior: Immediately quit and opened a browser tab if run on Windows.
New Behavior: Now detects Windows and provides a clear warning that some tools are Linux-specific, but allows the user to explore the menu system and use any platform-agnostic collection tools.
6. Repository Cleanliness
Renamed requirement.txt to requirements.txt to comply with standard Python packaging practices.
Technical Notes
Files touched: core.py, cybersec.py, requirements.txt.
Logic in cybersec.py was reorganized to be more linear and easier to maintain.
Used os.path.join and os.path.abspath for robust file handling across different environments.