Skip to content

Commit 5a6c681

Browse files
authored
Enhance IP validation (#256)
This beefs up the validation for the following: IP address (v4 and v6) IP prefix (v4 and v6) Hostname / Port
1 parent d4dcad8 commit 5a6c681

File tree

6 files changed

+705
-229
lines changed

6 files changed

+705
-229
lines changed

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ dependencies {
271271
implementation(enforcedPlatform(libs.cel))
272272
implementation(libs.cel.core)
273273
implementation(libs.guava)
274-
implementation(libs.ipaddress)
275274

276275
buf("build.buf:buf:${libs.versions.buf.get()}:${osdetector.classifier}@exe")
277276

conformance/expected-failures.yaml

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -107,94 +107,6 @@ custom_constraints:
107107
#ERROR: <input>:1:1: expression of type 'int' cannot be range of a comprehension (must be list, map, or dynamic)
108108
# | this.all(e, e == 1)
109109
# | ^
110-
library/is_host_and_port:
111-
- port_required/false/invalid/ipv6_zone-id_too_short
112-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsHostAndPort]:{val:"[::1%]"}
113-
# want: validation error (1 violation)
114-
# 1. constraint_id: "library.is_host_and_port"
115-
# got: valid
116-
- port_required/false/invalid/port_number_sign
117-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsHostAndPort]:{val:"example.com:+0"}
118-
# want: validation error (1 violation)
119-
# 1. constraint_id: "library.is_host_and_port"
120-
# got: valid
121-
- port_required/false/valid/ipv6_embedded_ipv4
122-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsHostAndPort]:{val:"[0:0:0:0:0:ffff:192.1.56.10]"}
123-
# want: valid
124-
# got: validation error (1 violation)
125-
# 1. constraint_id: "library.is_host_and_port"
126-
# message: ""
127-
- port_required/false/valid/ipv6_with_zone-id
128-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsHostAndPort]:{val:"[::1%foo]"}
129-
# want: valid
130-
# got: validation error (1 violation)
131-
# 1. constraint_id: "library.is_host_and_port"
132-
# message: ""
133-
- port_required/false/valid/ipv6_zone-id_any_non_null_character
134-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsHostAndPort]:{val:"[::1%% :x\x1f]"}
135-
# want: valid
136-
# got: validation error (1 violation)
137-
# 1. constraint_id: "library.is_host_and_port"
138-
# message: ""
139-
- port_required/true/invalid/port_number_sign
140-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsHostAndPort]:{val:"example.com:+0" port_required:true}
141-
# want: validation error (1 violation)
142-
# 1. constraint_id: "library.is_host_and_port"
143-
# got: valid
144-
library/is_ip:
145-
- version/omitted/invalid/ipv6_zone-id
146-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsIp]:{val:"::1%"}
147-
# want: validation error (1 violation)
148-
# 1. constraint_id: "library.is_ip"
149-
# got: valid
150-
- version/omitted/valid/ipv6_zone-id
151-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsIp]:{val:"::1%foo"}
152-
# want: valid
153-
# got: validation error (1 violation)
154-
# 1. constraint_id: "library.is_ip"
155-
# message: ""
156-
- version/omitted/valid/ipv6_zone-id_any_non_null_character
157-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsIp]:{val:"::1%% :x\x1f"}
158-
# want: valid
159-
# got: validation error (1 violation)
160-
# 1. constraint_id: "library.is_ip"
161-
# message: ""
162-
library/is_ip_prefix:
163-
- version/omitted/strict/omitted/invalid/ipv4_bad_leading_zero_in_prefix-length
164-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsIpPrefix]:{val:"192.168.1.0/024"}
165-
# want: validation error (1 violation)
166-
# 1. constraint_id: "library.is_ip_prefix"
167-
# got: valid
168-
- version/omitted/strict/omitted/invalid/ipv4_prefix_leading_space
169-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsIpPrefix]:{val:" 127.0.0.1/16"}
170-
# want: validation error (1 violation)
171-
# 1. constraint_id: "library.is_ip_prefix"
172-
# got: valid
173-
- version/omitted/strict/omitted/invalid/ipv4_prefix_trailing_space
174-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsIpPrefix]:{val:"127.0.0.1/16 "}
175-
# want: validation error (1 violation)
176-
# 1. constraint_id: "library.is_ip_prefix"
177-
# got: valid
178-
- version/omitted/strict/omitted/invalid/ipv6_bad_leading_zero_in_prefix-length
179-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsIpPrefix]:{val:"2001:0DB8:ABCD:0012:FFFF:FFFF:FFFF:FFFF/024"}
180-
# want: validation error (1 violation)
181-
# 1. constraint_id: "library.is_ip_prefix"
182-
# got: valid
183-
- version/omitted/strict/omitted/invalid/ipv6_prefix_leading_space
184-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsIpPrefix]:{val:" ::1/64"}
185-
# want: validation error (1 violation)
186-
# 1. constraint_id: "library.is_ip_prefix"
187-
# got: valid
188-
- version/omitted/strict/omitted/invalid/ipv6_prefix_trailing_space
189-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsIpPrefix]:{val:"::1/64 "}
190-
# want: validation error (1 violation)
191-
# 1. constraint_id: "library.is_ip_prefix"
192-
# got: valid
193-
- version/omitted/strict/omitted/invalid/ipv6_zone-id/a
194-
# input: [type.googleapis.com/buf.validate.conformance.cases.IsIpPrefix]:{val:"::1%en1/64"}
195-
# want: validation error (1 violation)
196-
# 1. constraint_id: "library.is_ip_prefix"
197-
# got: valid
198110
library/is_uri:
199111
- invalid/host/c
200112
# input: [type.googleapis.com/buf.validate.conformance.cases.IsUri]:{val:"https://foo@你好.com"}

gradle/libs.versions.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
assertj = "3.27.3"
33
buf = "1.50.1"
44
cel = "0.5.1"
5-
ipaddress = "5.5.1"
65
junit = "5.12.1"
76
maven-publish = "0.31.0"
87
# When updating, make sure to update versions in the following files to match and regenerate code with 'make generate'.
@@ -19,7 +18,6 @@ cel = { module = "org.projectnessie.cel:cel-bom", version.ref = "cel" }
1918
cel-core = { module = "org.projectnessie.cel:cel-core" }
2019
errorprone = { module = "com.google.errorprone:error_prone_core", version = "2.37.0" }
2120
guava = { module = "com.google.guava:guava", version = "33.4.0-jre" }
22-
ipaddress = { module = "com.github.seancfoley:ipaddress", version.ref = "ipaddress" }
2321
junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" }
2422
maven-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "maven-publish" }
2523
nullaway = { module = "com.uber.nullaway:nullaway", version = "0.12.4" }

0 commit comments

Comments
 (0)