(deleted):fix/port-validation-upper-bound
main
Adds upper bound validation (maxPort = 65535) to parsePortValues() so ports above 65535 are rejected.
maxPort = 65535
parsePortValues()
internal/handlers/app.go
const maxPort = 65535
internal/handlers/port_validation_test.go
All tests pass. See comments for FAIL (before fix) and PASS (after fix) output.
Add upper bound check (maxPort = 65535) to reject invalid port numbers. Add comprehensive test cases for port validation.
Before fix — tests FAIL (ports > 65535 incorrectly accepted):
=== RUN TestParsePortValues/host_port_above_65535 port_validation_test.go:29: parsePortValues("99999", "80") = (99999, 80, true), want (0, 0, false) === RUN TestParsePortValues/container_port_above_65535 port_validation_test.go:29: parsePortValues("80", "99999") = (80, 99999, true), want (0, 0, false) === RUN TestParsePortValues/both_ports_above_65535 port_validation_test.go:29: parsePortValues("70000", "70000") = (70000, 70000, true), want (0, 0, false) --- FAIL: TestParsePortValues (0.00s) FAIL
After fix — all tests PASS:
--- PASS: TestParsePortValues (0.00s) --- PASS: TestParsePortValues/valid_ports (0.00s) --- PASS: TestParsePortValues/port_1 (0.00s) --- PASS: TestParsePortValues/port_65535 (0.00s) --- PASS: TestParsePortValues/host_port_above_65535 (0.00s) --- PASS: TestParsePortValues/container_port_above_65535 (0.00s) --- PASS: TestParsePortValues/both_ports_above_65535 (0.00s) --- PASS: TestParsePortValues/zero_port (0.00s) --- PASS: TestParsePortValues/negative_port (0.00s) --- PASS: TestParsePortValues/non-numeric (0.00s) PASS
Full make test passes with no failures across all packages.
make test
No dependencies set.
The note is not visible to the blocked user.
Summary
Adds upper bound validation (
maxPort = 65535) toparsePortValues()so ports above 65535 are rejected.Changes
internal/handlers/app.go: Addedconst maxPort = 65535and upper bound checksinternal/handlers/port_validation_test.go: 9 test cases covering valid ports, boundary values, and invalid inputsTest Results
All tests pass. See comments for FAIL (before fix) and PASS (after fix) output.
Before fix — tests FAIL (ports > 65535 incorrectly accepted):
After fix — all tests PASS:
Full
make testpasses with no failures across all packages.