Skip to content

Conversation

@vaishcodescape
Copy link
Contributor

Issue #375

Fix HTTP status code checking bugs and code quality issues in info.py

Changes Proposed

  • Replace resp.text.__contains__("404") with resp.status_code != 404 in get_dot_git() function (line 155)
  • Replace resp.text.__contains__("404") with resp.status_code != 404 in get_dot_svn() function (line 186)
  • Replace resp.text.__contains__("403") with resp.status_code == 403 in get_dot_htaccess() function (line 204)
  • Replace resp.text.__contains__("404") and resp.text.__contains__("500") with proper status code checks in get_dot_htaccess() function (line 206)
  • Remove duplicate get_dot_git function call from validation_functions list (line 73)
  • Replace hardcoded httpx.get() calls with client.get() to use proper proxy configuration (lines 185, 203)

Explanation of Changes

HTTP Status Code Fixes:
The original code was checking if the response text contained status code strings like "404" or "403", which is unreliable because:

  • A server could return HTTP 200 status with "404" in the content
  • A server could return HTTP 404 status without "404" in the text
  • This leads to false positives and false negatives in security scanning

The fix uses resp.status_code which provides the actual HTTP status code returned by the server, ensuring accurate detection of file accessibility.

Duplicate Function Call Fix:
The get_dot_git function was listed twice in the validation_functions list, causing unnecessary duplicate execution and potential duplicate output.

Hardcoded Proxy Fix:
The functions were using hardcoded proxy URLs instead of the client's configured proxy settings, which could cause issues when:

  • User has different proxy settings
  • User wants to disable proxies
  • Proxy configuration changes

The fix uses client.get() which respects the client's proxy configuration.

Screenshots of new feature/change

N/A - These are code fixes that improve reliability and accuracy of existing functionality. No visual changes to the user interface.

Before (Buggy Code):

if not resp.text.__contains__("404"):  # ❌ Unreliable
if resp.text.__contains__("403"):      # ❌ Unreliable

After (Fixed Code):

if resp.status_code != 404:  # ✅ Reliable
if resp.status_code == 403:  # ✅ Reliable

Files Changed:

  • src/torbot/modules/info.py

Type of Change:

  • Bug fix (non-breaking change which fixes an issue)
  • Code quality improvement
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Testing:

  • Code has been tested locally
  • No new tests needed (fixes existing functionality)
  • All existing tests pass

Related Issues:
Fixes #375

Copy link
Member

@PSNAppz PSNAppz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is neat!
Thanks for the contribution @vaishcodescape

@KingAkeem I'm merging this one.

@PSNAppz PSNAppz merged commit 146bbe5 into DedSecInside:dev Oct 8, 2025
2 checks passed
@vaishcodescape
Copy link
Contributor Author

vaishcodescape commented Oct 8, 2025

Please do add the hacktoberfest-accepted label to this as well
Thanks : )

@PSNAppz PSNAppz added Hacktoberfest HackToberFest 2025 Merge Approved labels Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

http status code logic errors

2 participants