Skip to content
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

Validation of User Input for Port and URL (Lines 138, 139) #396

Open
nitish-yaddala opened this issue Nov 6, 2024 · 0 comments
Open

Validation of User Input for Port and URL (Lines 138, 139) #396

nitish-yaddala opened this issue Nov 6, 2024 · 0 comments

Comments

@nitish-yaddala
Copy link

https://github.com/jofpin/trape/blob/6baae245691997742a51979767254d7da580eadd/core/trape.py#L138C4-L138C37

Potential Issue: User inputs for the port and URL fields are currently not validated, which could lead to errors or potential security risks.

Suggestion: Add validation checks for port ranges and URL format. This ensures input safety and reduces the likelihood of invalid configurations.

Code Suggestion:

try:
    port = int(options.port)
    if port < 1 or port > 65535:
        raise ValueError("Port out of range")
except ValueError as e:
    print(f"Invalid port: {e}")
    sys.exit(1)

if not options.url.startswith(('http://', 'https://')):
    print("Invalid URL format. URL must start with 'http://' or 'https://'")
    sys.exit(1)
    

Explanation: This input validation strengthens security and ensures the application receives expected input formats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant