Skip to content

Commit

Permalink
Add regex check for gateway IP
Browse files Browse the repository at this point in the history
  • Loading branch information
dvavili committed Mar 25, 2016
1 parent 9ac4bb6 commit 12422da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions contivModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,11 @@ func ValidateNetwork(obj *Network) error {
return errors.New("encap string invalid format")
}

gatewayMatch := regexp.MustCompile("^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})?$")
if gatewayMatch.MatchString(obj.Gateway) == false {
return errors.New("gateway string invalid format")
}

if len(obj.NetworkName) > 64 {
return errors.New("networkName string too long")
}
Expand Down
1 change: 1 addition & 0 deletions network.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
},
"gateway": {
"type": "string",
"format": "^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\\\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})?$",
"title": "Gateway",
"showSummary": true
}
Expand Down

0 comments on commit 12422da

Please sign in to comment.