Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dataplane)!: disallow using 0.0.0.0 in networking.address for dp #3691

Merged
merged 1 commit into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ The new version still supports annotation, but to have a guarantee that applicat

### Universal

We removed support for old Ingress (`Dataplane#networking.ingress`) from pre 1.2 days.
If you are still using it, please migrate to `ZoneIngress` first (see `Upgrade to 1.2.0` section).
- We removed support for old Ingress (`Dataplane#networking.ingress`) from pre 1.2 days.
If you are still using it, please migrate to `ZoneIngress` first (see `Upgrade to 1.2.0` section).
- You can't use 0.0.0.0 or :: in `networking.address` most of the time using loopback is what people intended.

## Upgrade to `1.4.0`

Expand Down
3 changes: 3 additions & 0 deletions pkg/core/resources/apis/mesh/dataplane_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ func validateAddress(path validators.PathBuilder, address string) validators.Val
err.AddViolationAt(path.Field("address"), "address can't be empty")
return err
}
if address == "0.0.0.0" || address == "::" {
err.AddViolationAt(path.Field("address"), "must not be 0.0.0.0 or ::")
}
if !govalidator.IsIP(address) && !govalidator.IsDNSName(address) {
err.AddViolationAt(path.Field("address"), "address has to be valid IP address or domain name")
}
Expand Down
32 changes: 32 additions & 0 deletions pkg/core/resources/apis/mesh/dataplane_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,38 @@ var _ = Describe("Dataplane", func() {
// and
Expect(actual).To(MatchYAML(given.expected))
},
Entry("networking.address: can't use 0.0.0.0", testCase{
dataplane: `
type: Dataplane
name: dp-1
mesh: default
networking:
address: 0.0.0.0
inbound:
- port: 8080
tags:
kuma.io/service: backend`,
expected: `
violations:
- field: networking.address
message: 'must not be 0.0.0.0 or ::'`,
}),
Entry("networking.address: can't use ::", testCase{
dataplane: `
type: Dataplane
name: dp-1
mesh: default
networking:
address: "::"
inbound:
- port: 8080
tags:
kuma.io/service: backend`,
expected: `
violations:
- field: networking.address
message: 'must not be 0.0.0.0 or ::'`,
}),
Entry("networking: not enough inbound interfaces and no gateway", testCase{
dataplane: `
type: Dataplane
Expand Down