Skip to content

Commit 88e39ae

Browse files
authored
Allow multicast and broadcast IPs in test documents (#830)
1 parent 4e17739 commit 88e39ae

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

internal/fields/validate.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,13 @@ func (v *Validator) isAllowedIPValue(s string) bool {
451451
}
452452
}
453453

454-
if ip.IsUnspecified() || ip.IsPrivate() || ip.IsLoopback() || ip.IsLinkLocalUnicast() || ip.IsLinkLocalMulticast() {
454+
if ip.IsUnspecified() ||
455+
ip.IsPrivate() ||
456+
ip.IsLoopback() ||
457+
ip.IsLinkLocalUnicast() ||
458+
ip.IsLinkLocalMulticast() ||
459+
ip.IsMulticast() ||
460+
ip.Equal(net.IPv4bcast) {
455461
return true
456462
}
457463

internal/fields/validate_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,34 @@ func Test_parseElementValue(t *testing.T) {
215215
Type: "ip",
216216
},
217217
},
218+
{
219+
key: "unspecified ipv4",
220+
value: "0.0.0.0",
221+
definition: FieldDefinition{
222+
Type: "ip",
223+
},
224+
},
225+
{
226+
key: "ipv4 broadcast address",
227+
value: "255.255.255.255",
228+
definition: FieldDefinition{
229+
Type: "ip",
230+
},
231+
},
232+
{
233+
key: "ipv6 min multicast",
234+
value: "ff00::",
235+
definition: FieldDefinition{
236+
Type: "ip",
237+
},
238+
},
239+
{
240+
key: "ipv6 max multicast",
241+
value: "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
242+
definition: FieldDefinition{
243+
Type: "ip",
244+
},
245+
},
218246
{
219247
key: "abbreviated ipv6 in allowed list with leading 0",
220248
value: "2a02:cf40:0add:0::1",

0 commit comments

Comments
 (0)