diff --git a/service/profile/endpoints/endpoint.go b/service/profile/endpoints/endpoint.go index 2c28aac44..8aa8c5c5c 100644 --- a/service/profile/endpoints/endpoint.go +++ b/service/profile/endpoints/endpoint.go @@ -195,6 +195,9 @@ func (ep *EndpointBase) parsePPP(typedEp Endpoint, fields []string) (Endpoint, e if n16 == 0 { return nil, invalidDefinitionError(fields, "port number cannot be 0") } + if n16 < ep.StartPort { + return nil, invalidDefinitionError(fields, "start port cannot be greater than end port") + } ep.EndPort = n16 } } diff --git a/service/profile/endpoints/endpoint_test.go b/service/profile/endpoints/endpoint_test.go index 1af937e0d..839d55f07 100644 --- a/service/profile/endpoints/endpoint_test.go +++ b/service/profile/endpoints/endpoint_test.go @@ -62,6 +62,19 @@ func TestEndpointParsing(t *testing.T) { // TODO: Test fails: // testParsing(t, "+ 1234") + + // invalid protocol and ports + testParsingFails(t, "+ * TCP/443-80") + testParsingFails(t, "- * UDP/HTTPS-HTTP") +} + +func testParsingFails(t *testing.T, value string) { + t.Helper() + + ep, err := parseEndpoint(value) + if err == nil { + t.Errorf(`parsing "%s" should fail, but returned "%s"`, value, ep.String()) + } } func testParsing(t *testing.T, value string) {