From 546a25d0254dfe75b639f77715ce0b46b0a5e43d Mon Sep 17 00:00:00 2001
From: Shuting Zhao <shutting06@gmail.com>
Date: Mon, 11 Nov 2019 21:06:09 -0800
Subject: [PATCH] add missing file

---
 pkg/engine/validation.go | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/pkg/engine/validation.go b/pkg/engine/validation.go
index 6670fca879..5c629da5ad 100644
--- a/pkg/engine/validation.go
+++ b/pkg/engine/validation.go
@@ -48,6 +48,13 @@ func Validate(policyContext PolicyContext) (response EngineResponse) {
 		if !rule.HasValidate() {
 			continue
 		}
+
+		if !matchAdmissionInfo(rule, policyContext.AdmissionInfo) {
+			glog.V(3).Infof("rule '%s' cannot be applied on %s/%s/%s, admission permission: %v",
+				rule.Name, resource.GetKind(), resource.GetNamespace(), resource.GetName(), policyContext.AdmissionInfo)
+			continue
+		}
+
 		// check if the resource satisfies the filter conditions defined in the rule
 		// TODO: this needs to be extracted, to filter the resource so that we can avoid passing resources that
 		// dont statisfy a policy rule resource description