-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(k8spsphostnetworkingports): CEL fixes for hostNetwork variable and
message My updates to the suite.yaml file yielded an expected failure due to an incorrect CEL expression: ``` unexpected number of violations: got 1 violations but want none: got messages [failed expression: (has(request.operation) && request.operation == "UPDATE") || (!has(variables.params.hostNetwork) || !variables.params.hostNetwork ? (has(variables.anyObject.spec.hostNetwork) && !variables.anyObject.spec.hostNetwork) : true)] ``` By contrast, a run of `gator verify -v . --enable-k8s-native-validation=false` yielded a fully passing suite.yaml. This expression was actually failing due to its `messageExpression`, as non-primitive types cannot be combined with strings as in some interpreted languages (like rego). Unfortunately the compiler does not indicate that the messageExpression is the source of the problem. Once the message was fixed, I resolved the incorrect violation expression to fix the bug in the handling of params.hostNetwork. Signed-off-by: juliankatz <[email protected]>
- Loading branch information
1 parent
5153330
commit 132fd8e
Showing
9 changed files
with
78 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,3 @@ spec: | |
kinds: ["Pod"] | ||
parameters: | ||
hostNetwork: false | ||
exemptImages: | ||
- "nginx" |
13 changes: 13 additions & 0 deletions
13
...etwork-ports/samples/psp-host-network-ports/constraint_port_range_block_host_network.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: constraints.gatekeeper.sh/v1beta1 | ||
kind: K8sPSPHostNetworkingPorts | ||
metadata: | ||
name: psp-host-network-ports | ||
spec: | ||
match: | ||
kinds: | ||
- apiGroups: [""] | ||
kinds: ["Pod"] | ||
parameters: | ||
hostNetwork: false | ||
min: 80 | ||
max: 9000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
...ost-network-ports/samples/psp-host-network-ports/example_no_ports_host_network_false.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx-host-network-false | ||
spec: | ||
hostNetwork: false | ||
containers: | ||
- name: nginx | ||
image: nginx |
9 changes: 9 additions & 0 deletions
9
...host-network-ports/samples/psp-host-network-ports/example_no_ports_host_network_true.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx-host-network-true | ||
spec: | ||
hostNetwork: true | ||
containers: | ||
- name: nginx | ||
image: nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters