forked from ratify-project/ratify
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add e2e tests for multi-tenancy
- Loading branch information
Showing
11 changed files
with
202 additions
and
101 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
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
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,11 @@ | ||
apiVersion: constraints.gatekeeper.sh/v1beta1 | ||
kind: RatifyVerification | ||
metadata: | ||
name: ratify-constraint | ||
spec: | ||
enforcementAction: deny | ||
match: | ||
kinds: | ||
- apiGroups: [""] | ||
kinds: ["Pod"] | ||
namespaces: ["default", "new-namespace"] |
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,48 @@ | ||
apiVersion: templates.gatekeeper.sh/v1beta1 | ||
kind: ConstraintTemplate | ||
metadata: | ||
name: ratifyverification | ||
spec: | ||
crd: | ||
spec: | ||
names: | ||
kind: RatifyVerification | ||
targets: | ||
- target: admission.k8s.gatekeeper.sh | ||
rego: | | ||
package ratifyverification | ||
# Get data from Ratify | ||
remote_data := response { | ||
images := [img | img = concat("", ["[",input.review.object.metadata.namespace,"]",input.review.object.spec.containers[_].image])] | ||
images_init := [img | img = concat("", ["[",input.review.object.metadata.namespace,"]",input.review.object.spec.initContainers[_].image])] | ||
images_ephemeral := [img | img = concat("", ["[",input.review.object.metadata.namespace,"]",input.review.object.spec.ephemeralContainers[_].image])] | ||
other_images := array.concat(images_init, images_ephemeral) | ||
all_images := array.concat(other_images, images) | ||
response := external_data({"provider": "ratify-provider", "keys": all_images}) | ||
} | ||
# Base Gatekeeper violation | ||
violation[{"msg": msg}] { | ||
general_violation[{"result": msg}] | ||
} | ||
# Check if there are any system errors | ||
general_violation[{"result": result}] { | ||
err := remote_data.system_error | ||
err != "" | ||
result := sprintf("System error calling external data provider: %s", [err]) | ||
} | ||
# Check if there are errors for any of the images | ||
general_violation[{"result": result}] { | ||
count(remote_data.errors) > 0 | ||
result := sprintf("Error validating one or more images: %s", remote_data.errors) | ||
} | ||
# Check if the success criteria is true | ||
general_violation[{"result": result}] { | ||
subject_validation := remote_data.responses[_] | ||
subject_validation[1].isSuccess == false | ||
result := sprintf("Subject failed verification: %s", [subject_validation[0]]) | ||
} |
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
Oops, something went wrong.