-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add three new cybersecurity tools and update index #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit introduces three new command-line cybersecurity tools to the repository, in response to the user's request to integrate tools for account access, data access, and hacking.
1. **Account Pwned Checker:**
- A tool to check if an email address has been part of a known data breach using the 'Have I Been Pwned?' API.
- Includes the main script, a checker module, a requirements file, and a detailed README.
2. **Sensitive Data Scanner:**
- A tool to recursively scan a local directory for sensitive data patterns like API keys, private keys, and credit card numbers.
- Includes the main script, a scanner module with regex patterns, and a README.
3. **Port Scanner:**
- A multi-threaded TCP port scanner to discover open ports on a target host.
- Includes the main script, a scanner module, and a README with a legal disclaimer.
Additionally, the root `index.html` file has been overwritten with a new, clean landing page that serves as a central directory for all tools in the repository, including the newly added ones. This replaces the previous default React template.
Reviewer's GuideThis PR integrates three new Python-based CLI cybersecurity tools (Account Pwned Checker, Sensitive Data Scanner, and Port Scanner), each implemented with clear module separation, argument parsing, and accompanying documentation, and replaces the default React template in index.html with a custom landing page listing all repository tools. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Vulnerable Libraries (1)
More info on how to fix Vulnerable Libraries in Python. 👉 Go to the dashboard for detailed results. 📥 Happy? Share your feedback with us. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
Blocking issues:
- Identified a Private Key, which may compromise cryptographic security and sensitive data encryption. (link)
General comments:
- In port_scanner_main.py the port parsing logic only uses the min and max values for scanning, so comma-separated or discrete port lists end up scanning the entire range instead of the exact ports specified—consider scanning exactly the user-provided ports.
- The HIBP checker returns None for both a 'not found' result and for API errors, so the CLI can’t differentiate between no breaches and request failures—consider returning distinct error indicators or exceptions for error cases.
- scan_file in the sensitive data scanner silently ignores all exceptions which may hide file read issues or permission errors—consider logging or otherwise surfacing errors to aid debugging.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In port_scanner_main.py the port parsing logic only uses the min and max values for scanning, so comma-separated or discrete port lists end up scanning the entire range instead of the exact ports specified—consider scanning exactly the user-provided ports.
- The HIBP checker returns None for both a 'not found' result and for API errors, so the CLI can’t differentiate between no breaches and request failures—consider returning distinct error indicators or exceptions for error cases.
- scan_file in the sensitive data scanner silently ignores all exceptions which may hide file read issues or permission errors—consider logging or otherwise surfacing errors to aid debugging.
## Individual Comments
### Comment 1
<location> `port_scanner/scanner.py:21` </location>
<code_context>
+ try:
+ s.connect((host, port))
+ return True
+ except (socket.timeout, ConnectionRefusedError, socket.gaierror, OSError):
+ return False
+ finally:
</code_context>
<issue_to_address>
Catching OSError may mask unexpected socket errors.
Handle only the specific exceptions relevant to connection failures to prevent masking unrelated errors.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
try:
s.connect((host, port))
return True
except (socket.timeout, ConnectionRefusedError, socket.gaierror, OSError):
return False
finally:
s.close()
=======
try:
s.connect((host, port))
return True
except (socket.timeout, ConnectionRefusedError, socket.gaierror):
return False
finally:
s.close()
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `port_scanner_main.py:34` </location>
<code_context>
+
+ print(f"Scanning host {target_host} for open ports...")
+
+ # In this implementation, we will pass the start and end of the main range.
+ # A more complex implementation would handle disjointed lists of ports.
+ start_port = min(ports_to_scan)
+ end_port = max(ports_to_scan)
</code_context>
<issue_to_address>
Disjointed port lists are not handled accurately.
Currently, specifying ports like '80,443' results in scanning all ports between 80 and 443. Please update the logic to scan only the explicitly listed ports.
</issue_to_address>
## Security Issues
### Issue 1
<location> `sensitive_data_scanner/scanner.py:10` </location>
<issue_to_address>
**security (private-key):** Identified a Private Key, which may compromise cryptographic security and sensitive data encryption.
*Source: gitleaks*
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| try: | ||
| s.connect((host, port)) | ||
| return True | ||
| except (socket.timeout, ConnectionRefusedError, socket.gaierror, OSError): | ||
| return False | ||
| finally: | ||
| s.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): Catching OSError may mask unexpected socket errors.
Handle only the specific exceptions relevant to connection failures to prevent masking unrelated errors.
| try: | |
| s.connect((host, port)) | |
| return True | |
| except (socket.timeout, ConnectionRefusedError, socket.gaierror, OSError): | |
| return False | |
| finally: | |
| s.close() | |
| try: | |
| s.connect((host, port)) | |
| return True | |
| except (socket.timeout, ConnectionRefusedError, socket.gaierror): | |
| return False | |
| finally: | |
| s.close() |
| # In this implementation, we will pass the start and end of the main range. | ||
| # A more complex implementation would handle disjointed lists of ports. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Disjointed port lists are not handled accurately.
Currently, specifying ports like '80,443' results in scanning all ports between 80 and 443. Please update the logic to scan only the explicitly listed ports.
| "RSA Private Key": re.compile(r"-----BEGIN RSA PRIVATE KEY-----"), | ||
| "SSH Private Key": re.compile(r"-----BEGIN OPENSSH PRIVATE KEY-----"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
security (private-key): Identified a Private Key, which may compromise cryptographic security and sensitive data encryption.
Source: gitleaks
| try: | ||
| s.connect((host, port)) | ||
| return True | ||
| except (socket.timeout, ConnectionRefusedError, socket.gaierror, OSError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Remove redundant exceptions from an except clause (remove-redundant-exception)
| except (socket.timeout, ConnectionRefusedError, socket.gaierror, OSError): | |
| except (socket.timeout, socket.gaierror, OSError): |
| open_ports = scanner.scan_ports(target_host, start_port, end_port, max_workers=num_threads) | ||
|
|
||
| if not open_ports: | ||
| print("\n--- No Open Ports Found ---") | ||
| print(f"No open ports were found in the specified range on {target_host}.") | ||
| else: | ||
| print("\n--- Open Ports Found! ---") | ||
| for port in open_ports: | ||
| print(f" [+] Port {port} is open") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): We've found these issues:
- Use named expression to simplify assignment and conditional (
use-named-expression) - Swap if/else branches (
swap-if-else-branches)
| breaches = checker.check_pwned(args.email) | ||
|
|
||
| if breaches: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Use named expression to simplify assignment and conditional (use-named-expression)
| breaches = checker.check_pwned(args.email) | |
| if breaches: | |
| if breaches := checker.check_pwned(args.email): |
| matches = regex.findall(content) | ||
| if matches: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Use named expression to simplify assignment and conditional (use-named-expression)
| matches = regex.findall(content) | |
| if matches: | |
| if matches := regex.findall(content): |
| file_findings = scan_file(filepath) | ||
| if file_findings: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Use named expression to simplify assignment and conditional (use-named-expression)
| file_findings = scan_file(filepath) | |
| if file_findings: | |
| if file_findings := scan_file(filepath): |
This commit introduces three new command-line cybersecurity tools to the repository, in response to the user's request to integrate tools for account access, data access, and hacking.
Account Pwned Checker:
Sensitive Data Scanner:
Port Scanner:
Additionally, the root
index.htmlfile has been overwritten with a new, clean landing page that serves as a central directory for all tools in the repository, including the newly added ones. This replaces the previous default React template.Summary by Sourcery
Introduce three new command-line cybersecurity tools and overhaul the repository’s landing page to list and link to all available tools
New Features:
Enhancements:
Documentation: