run hack/update-netparse-cve.sh

This commit is contained in:
Antonio Ojea
2021-08-20 01:16:14 +02:00
parent e9ddac5d85
commit 0cd75e8fec
159 changed files with 1071 additions and 988 deletions

View File

@@ -38,6 +38,7 @@ import (
compute "google.golang.org/api/compute/v1"
"k8s.io/klog/v2"
netutils "k8s.io/utils/net"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
@@ -332,7 +333,7 @@ func GenerateRSACerts(host string, isCA bool) ([]byte, []byte, error) {
hosts := strings.Split(host, ",")
for _, h := range hosts {
if ip := net.ParseIP(h); ip != nil {
if ip := netutils.ParseIPSloppy(h); ip != nil {
template.IPAddresses = append(template.IPAddresses, ip)
} else {
template.DNSNames = append(template.DNSNames, h)

View File

@@ -48,7 +48,7 @@ import (
e2erc "k8s.io/kubernetes/test/e2e/framework/rc"
testutils "k8s.io/kubernetes/test/utils"
imageutils "k8s.io/kubernetes/test/utils/image"
utilsnet "k8s.io/utils/net"
netutils "k8s.io/utils/net"
)
// NodePortRange should match whatever the default/configured range is
@@ -821,7 +821,7 @@ func testReachabilityOverServiceName(serviceName string, sp v1.ServicePort, exec
func testReachabilityOverClusterIP(clusterIP string, sp v1.ServicePort, execPod *v1.Pod) error {
// If .spec.clusterIP is set to "" or "None" for service, ClusterIP is not created, so reachability can not be tested over clusterIP:servicePort
if net.ParseIP(clusterIP) == nil {
if netutils.ParseIPSloppy(clusterIP) == nil {
return fmt.Errorf("unable to parse ClusterIP: %s", clusterIP)
}
return testEndpointReachability(clusterIP, sp.Port, sp.Protocol, execPod)
@@ -833,7 +833,7 @@ func testReachabilityOverExternalIP(externalIP string, sp v1.ServicePort, execPo
func testReachabilityOverNodePorts(nodes *v1.NodeList, sp v1.ServicePort, pod *v1.Pod, clusterIP string, externalIPs bool) error {
internalAddrs := e2enode.CollectAddresses(nodes, v1.NodeInternalIP)
isClusterIPV4 := utilsnet.IsIPv4String(clusterIP)
isClusterIPV4 := netutils.IsIPv4String(clusterIP)
for _, internalAddr := range internalAddrs {
// If the node's internal address points to localhost, then we are not
@@ -843,7 +843,7 @@ func testReachabilityOverNodePorts(nodes *v1.NodeList, sp v1.ServicePort, pod *v
continue
}
// Check service reachability on the node internalIP which is same family as clusterIP
if isClusterIPV4 != utilsnet.IsIPv4String(internalAddr) {
if isClusterIPV4 != netutils.IsIPv4String(internalAddr) {
framework.Logf("skipping testEndpointReachability() for internal adddress %s as it does not match clusterIP (%s) family", internalAddr, clusterIP)
continue
}
@@ -856,7 +856,7 @@ func testReachabilityOverNodePorts(nodes *v1.NodeList, sp v1.ServicePort, pod *v
if externalIPs {
externalAddrs := e2enode.CollectAddresses(nodes, v1.NodeExternalIP)
for _, externalAddr := range externalAddrs {
if isClusterIPV4 != utilsnet.IsIPv4String(externalAddr) {
if isClusterIPV4 != netutils.IsIPv4String(externalAddr) {
framework.Logf("skipping testEndpointReachability() for external adddress %s as it does not match clusterIP (%s) family", externalAddr, clusterIP)
continue
}
@@ -872,7 +872,7 @@ func testReachabilityOverNodePorts(nodes *v1.NodeList, sp v1.ServicePort, pod *v
// isInvalidOrLocalhostAddress returns `true` if the provided `ip` is either not
// parsable or the loopback address. Otherwise it will return `false`.
func isInvalidOrLocalhostAddress(ip string) bool {
parsedIP := net.ParseIP(ip)
parsedIP := netutils.ParseIPSloppy(ip)
if parsedIP == nil || parsedIP.IsLoopback() {
return true
}

View File

@@ -63,6 +63,7 @@ import (
testutils "k8s.io/kubernetes/test/utils"
imageutils "k8s.io/kubernetes/test/utils/image"
uexec "k8s.io/utils/exec"
netutils "k8s.io/utils/net"
// TODO: Remove the following imports (ref: https://github.com/kubernetes/kubernetes/issues/81245)
e2ekubectl "k8s.io/kubernetes/test/e2e/framework/kubectl"
@@ -1265,7 +1266,7 @@ func getControlPlaneAddresses(c clientset.Interface) ([]string, []string, []stri
if err != nil {
Failf("Failed to parse hostname: %v", err)
}
if net.ParseIP(hostURL.Host) != nil {
if netutils.ParseIPSloppy(hostURL.Host) != nil {
externalIPs = append(externalIPs, hostURL.Host)
} else {
hostnames = append(hostnames, hostURL.Host)