instrumenta / instrumenta/kubeval

'kubeval --strict' fails to report duplicate cidr field

Open
#273 4 comments 1 reaction 0 assignees View on GitHub
schema
Dominant language
Go
Stars
3.2k
Forks
227
PR merge metrics
No merged PRs in 30d

Description

From https://github.com/kubernetes/kubernetes/issues/100213

Policy:

```
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: backend
namespace: default
spec:
podSelector:
matchLabels:
run: backend
policyTypes:
- Egress
- Ingress
egress:
- to:
- ipBlock:
cidr: 8.8.4.4/32
cidr: 1.1.1.1/32
ports:
- protocol: TCP
port: 53
```

Running kubeval:

```
kubeval --strict policy.yaml
PASS - policy.yaml contains a valid NetworkPolicy (default.backend)
```

Expected result: kubeval should report an invalid policy, since it contains multiple cidr blocks -- although [CIDR is a string field](https://github.com/kubernetes/kubernetes/blob/9657dd77a3563ffc7dbd061d51f34f714b1f8d5c/staging/src/k8s.io/api/networking/v1/types.go#L167).

I noticed [yaml.UnmarshalStrict](https://pkg.go.dev/sigs.k8s.io/yaml#UnmarshalStrict) does report this problem:

```
error converting YAML to JSON: yaml: unmarshal errors:
line 17: key "cidr" already set in map
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.