Skip to content

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

@nitish-yaddala

Description

@nitish-yaddala

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions