-
Notifications
You must be signed in to change notification settings - Fork 1
π‘οΈ Sentinel: [HIGH] Fix DNS Rebinding / SSRF Vulnerability #106
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import unittest | ||
Check warningCode scanning / Pylintpython3 (reported by Codacy) Missing module docstring Warning test
Missing module docstring
Check warningCode scanning / Pylint (reported by Codacy) Missing module docstring Warning test
Missing module docstring
|
||
| from unittest.mock import patch | ||
| import socket | ||
| import logging | ||
| import sys | ||
| import os | ||
|
|
||
| # Add parent directory to path so we can import main | ||
| sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | ||
|
|
||
| # Configure logging to avoid polluting output | ||
| logging.basicConfig(level=logging.CRITICAL) | ||
|
|
||
| import main | ||
Check warningCode scanning / Pylintpython3 (reported by Codacy) Import "import main" should be placed at the top of the module Warning test
Import "import main" should be placed at the top of the module
Check warningCode scanning / Prospector (reported by Codacy) Reimport 'main' (imported line 9) (reimported) Warning test
Reimport 'main' (imported line 9) (reimported)
Check warningCode scanning / Pylint (reported by Codacy) Import "import main" should be placed at the top of the module Warning test
Import "import main" should be placed at the top of the module
|
||
|
|
||
| class TestSecurity(unittest.TestCase): | ||
Check warningCode scanning / Pylintpython3 (reported by Codacy) Missing class docstring Warning test
Missing class docstring
Check warningCode scanning / Pylint (reported by Codacy) Missing class docstring Warning test
Missing class docstring
|
||
| def test_validate_folder_url_prevents_dns_rebinding(self): | ||
| """ | ||
| Verify that the implementation prevents domains that resolve to private IPs. | ||
| """ | ||
| suspicious_url = "https://internal.example.com/list.json" | ||
|
|
||
| # Mock socket.getaddrinfo to return 127.0.0.1 | ||
| with patch("socket.getaddrinfo") as mock_dns: | ||
| mock_dns.return_value = [ | ||
| (socket.AF_INET, socket.SOCK_STREAM, 6, '', ('127.0.0.1', 443)) | ||
| ] | ||
|
|
||
| result = main.validate_folder_url(suspicious_url) | ||
|
|
||
| # Should be False (Secure) | ||
| self.assertFalse(result, "validate_folder_url should return False for domains resolving to private IPs") | ||
Check warningCode scanning / Pylintpython3 (reported by Codacy) Line too long (116/100) Warning test
Line too long (116/100)
Check warningCode scanning / Pylint (reported by Codacy) Line too long (116/100) Warning test
Line too long (116/100)
|
||
|
|
||
| if __name__ == "__main__": | ||
Check warningCode scanning / Prospector (reported by Codacy) expected 2 blank lines after class or function definition, found 1 (E305) Warning test
expected 2 blank lines after class or function definition, found 1 (E305)
|
||
| unittest.main() | ||
Check notice
Code scanning / Remark-lint (reported by Codacy)
Warn when references to undefined definitions are found. Note