Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(security): accept the execution Pod exclusion in the NP-08 contract
Alfredo Lopez80824f95a2ec
diff --git a/scripts/security/check-np08-mcp-host-networkpolicy.rb b/scripts/security/check-np08-mcp-host-networkpolicy.rbindex 30c6c25f9..fe39a6565 100755--- a/scripts/security/check-np08-mcp-host-networkpolicy.rb+++ b/scripts/security/check-np08-mcp-host-networkpolicy.rb@@ -75,25 +75,110 @@ policy_types_include_egress = lambda do |policy|Array(policy.dig("spec", "policyTypes")).include?("Egress")end-exact_pod_selector = lambda do |policy, expected_labels|+# HCC also labels execution Pods clerum.io/managed-by=host-context-controller.+# NetworkPolicies are additive, so every static Host grant excludes them with+# exactly this expression; any other narrowing of the Host selector fails.+EXECUTION_ROLE_LABEL = "clerum.io/role"+EXECUTION_ROLE_VALUE = "host-execution"+HOST_EXECUTION_EXCLUSION = [+ { "key" => EXECUTION_ROLE_LABEL, "operator" => "NotIn", "values" => [EXECUTION_ROLE_VALUE] },+].freeze+EXPECTED_EXECUTION_SPEC = {+ "podSelector" => {+ "matchLabels" => {+ "clerum.io/managed-by" => "host-context-controller",+ EXECUTION_ROLE_LABEL => EXECUTION_ROLE_VALUE,+ },+ },+ "policyTypes" => ["Ingress", "Egress"],+ "ingress" => [+ {+ "from" => [+ {+ "namespaceSelector" => { "matchLabels" => { "kubernetes.io/metadata.name" => "control-plane" } },+ "podSelector" => { "matchLabels" => { "app" => "host-context-controller" } },+ },+ ],+ "ports" => [{ "port" => 9300, "protocol" => "TCP" }, { "port" => 9301, "protocol" => "TCP" }],+ },+ ],+ "egress" => [],+}.freeze++static_host_pod_selector = lambda do |policy|selector = policy.dig("spec", "podSelector")- selector.is_a?(Hash) && selector.keys.sort == ["matchLabels"] &&- selector["matchLabels"] == expected_labels && Array(selector["matchExpressions"]).empty?+ selector.is_a?(Hash) && selector.keys.sort == ["matchExpressions", "matchLabels"] &&+ selector["matchLabels"] == { "clerum.io/managed-by" => "host-context-controller" } &&+ selector["matchExpressions"] == HOST_EXECUTION_EXCLUSIONenddefault_deny = policies.find { |policy| policy.dig("metadata", "name") == "deny-all-mcp-host" }managed_host_policy = policies.find { |policy| policy.dig("metadata", "name") == "mcp-host" }+static_host_grants = %w[mcp-host allow-dns-egress-mcp-host allow-k8s-api-egress-mcp-host].map do |name|+ policies.find { |policy| policy.dig("metadata", "name") == name }+end+execution_policy = policies.find { |policy| policy.dig("metadata", "name") == "host-execution-private" }context_allow_policies = policies.select do |policy|policy.dig("metadata", "labels", "clerum.io/policy-type") == "context-allow"end+# Any other mcp-host policy that grants traffic must not be able to select an+# execution Pod. Operation and Host UID label values are per Pod, so a selector+# keyed on them is treated as possibly matching; an unknown operator matches.+EXECUTION_STATIC_LABELS = {+ "clerum.io/managed-by" => "host-context-controller",+ EXECUTION_ROLE_LABEL => EXECUTION_ROLE_VALUE,+}.freeze+EXECUTION_DYNAMIC_LABELS = %w[clerum.io/operation clerum.io/host-uid].freeze+selects_execution_pod = lambda do |selector|+ next true unless selector.is_a?(Hash)++ labels_match = (selector["matchLabels"] || {}).all? do |key, value|+ EXECUTION_DYNAMIC_LABELS.include?(key) || EXECUTION_STATIC_LABELS[key] == value+ end+ expressions_match = Array(selector["matchExpressions"]).all? do |expression|+ next true unless expression.is_a?(Hash)++ key = expression["key"]+ values = Array(expression["values"])+ if EXECUTION_DYNAMIC_LABELS.include?(key)+ expression["operator"] != "DoesNotExist"+ else+ present = EXECUTION_STATIC_LABELS.key?(key)+ case expression["operator"]+ when "In" then present && values.include?(EXECUTION_STATIC_LABELS[key])+ when "NotIn" then !present || !values.include?(EXECUTION_STATIC_LABELS[key])+ when "Exists" then present+ when "DoesNotExist" then !present+ else true+ end+ end+ end+ labels_match && expressions_match+end+policy_grants_traffic = lambda do |policy|+ !Array(policy.dig("spec", "ingress")).empty? || !Array(policy.dig("spec", "egress")).empty?+end+execution_grants = policies.select do |policy|+ policy.dig("metadata", "name") != "host-execution-private" &&+ policy_grants_traffic.call(policy) &&+ selects_execution_pod.call(policy.dig("spec", "podSelector"))+end+selector_contract_ok =default_deny.is_a?(Hash) &&default_deny.dig("spec", "podSelector") == {} &&policy_types_include_egress.call(default_deny) &&managed_host_policy.is_a?(Hash) &&- exact_pod_selector.call(managed_host_policy, { "clerum.io/managed-by" => "host-context-controller" }) &&- policy_types_include_egress.call(managed_host_policy) &&+ static_host_grants.all? do |policy|+ policy.is_a?(Hash) && static_host_pod_selector.call(policy) && policy_types_include_egress.call(policy)+ end &&+ execution_policy.is_a?(Hash) &&+ # The API server omits an empty egress list, so a live object and a render+ # compare equal only after restoring it.+ execution_policy["spec"].is_a?(Hash) &&+ execution_policy["spec"].merge("egress" => Array(execution_policy["spec"]["egress"])) == EXPECTED_EXECUTION_SPEC &&+ execution_grants.empty? &&context_allow_policies.all? do |policy|labels = policy.dig("spec", "podSelector", "matchLabels")context = policy.dig("metadata", "labels", "clerum.io/context")@@ -105,9 +190,14 @@ selector_contract_ok =endif host_pods- managed_host_pods = Array(host_pods.fetch("items", [])).select do |pod|+ managed_pods = Array(host_pods.fetch("items", [])).select do |pod|pod.dig("metadata", "labels", "clerum.io/managed-by") == "host-context-controller"end+ execution_pods, managed_host_pods = managed_pods.partition do |pod|+ pod.dig("metadata", "labels", EXECUTION_ROLE_LABEL) == EXECUTION_ROLE_VALUE+ end+ # Every Host pod has an egress grant; every execution Pod is selected by no+ # granting policy other than its private one.selector_contract_ok &&= !managed_host_pods.empty? && managed_host_pods.all? do |pod|labels = pod.dig("metadata", "labels") || {}policies.any? do |policy|@@ -116,6 +206,14 @@ if host_podsselector_matches.call(policy.dig("spec", "podSelector"), labels)endend+ selector_contract_ok &&= execution_pods.all? do |pod|+ labels = pod.dig("metadata", "labels") || {}+ policies.none? do |policy|+ policy.dig("metadata", "name") != "host-execution-private" &&+ policy_grants_traffic.call(policy) &&+ selector_matches.call(policy.dig("spec", "podSelector"), labels)+ end+ endendport_is_numeric = lambda do |port|@@ -257,7 +355,7 @@ egress_contract_ok &&= gfs_contract_okhcc_lane = policy_rules.any? do |_policy, rule|policy = _policypolicy_types_include_egress.call(policy) &&- exact_pod_selector.call(policy, { "clerum.io/managed-by" => "host-context-controller" }) &&+ static_host_pod_selector.call(policy) &&allows_tcp_port.call(rule, 8081) &&Array(rule["to"]).any? do |peer|peer.dig("namespaceSelector", "matchLabels", "kubernetes.io/metadata.name") == "control-plane" &&diff --git a/scripts/tests/test-np08-live-networkpolicy-contract.sh b/scripts/tests/test-np08-live-networkpolicy-contract.shindex 635de7078..58a878167 100755--- a/scripts/tests/test-np08-live-networkpolicy-contract.sh+++ b/scripts/tests/test-np08-live-networkpolicy-contract.sh@@ -20,8 +20,13 @@ RUBYOPT=--disable=gems ruby -ryaml -rjson -e 'assert_result() {local fixture="$1"local expected="$2"+ local pods="${3:-}"local actual- actual="$(RUBYOPT=--disable=gems ruby "$helper" <"${fixture}")"+ if [[ -n "${pods}" ]]; then+ actual="$(RUBYOPT=--disable=gems ruby "$helper" --host-pods "${pods}" <"${fixture}")"+ else+ actual="$(RUBYOPT=--disable=gems ruby "$helper" <"${fixture}")"+ fiif ! ruby -rjson -e 'expected = JSON.parse(ARGV.fetch(0))actual = JSON.parse(STDIN.read)@@ -98,3 +103,69 @@ echo "PASS: live policy helper rejects ineffective Host selectors"missing_egress_type="$(mutate missing-egress-type 'data["items"].find { |d| d["metadata"]["name"] == "mcp-host" }["spec"]["policyTypes"] = ["Ingress"]')"assert_result "${missing_egress_type}" '{"selector_contract_ok":false,"hcc_lane":false}'echo "PASS: live policy helper rejects a Host policy without Egress policy type"++dns_without_exclusion="$(mutate dns-without-exclusion 'data["items"].find { |d| d["metadata"]["name"] == "allow-dns-egress-mcp-host" }["spec"]["podSelector"].delete("matchExpressions")')"+assert_result "${dns_without_exclusion}" '{"selector_contract_ok":false,"hcc_lane":true}'+echo "PASS: live policy helper rejects a DNS grant that execution Pods inherit"++wrong_exclusion="$(mutate wrong-exclusion 'data["items"].find { |d| d["metadata"]["name"] == "mcp-host" }["spec"]["podSelector"]["matchExpressions"].first["operator"] = "In"')"+assert_result "${wrong_exclusion}" '{"selector_contract_ok":false,"hcc_lane":false}'+echo "PASS: live policy helper rejects a Host selector narrowed by anything but the execution exclusion"++execution_egress="$(mutate execution-egress 'data["items"].find { |d| d["metadata"]["name"] == "host-execution-private" }["spec"]["egress"] = [{ "to" => [{ "ipBlock" => { "cidr" => "0.0.0.0/0" } }] }]')"+assert_result "${execution_egress}" '{"selector_contract_ok":false,"hcc_lane":true}'+echo "PASS: live policy helper rejects egress on the execution policy"++execution_live_shape="$(mutate execution-live-shape 'data["items"].find { |d| d["metadata"]["name"] == "host-execution-private" }["spec"].delete("egress")')"+assert_result "${execution_live_shape}" '{"selector_contract_ok":true,"hcc_lane":true}'+echo "PASS: live policy helper accepts the execution policy as the API server returns it"++execution_ingress="$(mutate execution-ingress 'data["items"].find { |d| d["metadata"]["name"] == "host-execution-private" }["spec"]["ingress"].first["from"] = [{ "namespaceSelector" => {} }]')"+assert_result "${execution_ingress}" '{"selector_contract_ok":false,"hcc_lane":true}'+echo "PASS: live policy helper rejects a widened execution ingress"++missing_execution="$(mutate missing-execution 'data["items"].reject! { |d| d["metadata"]["name"] == "host-execution-private" }')"+assert_result "${missing_execution}" '{"selector_contract_ok":false,"hcc_lane":true}'+echo "PASS: live policy helper rejects a missing execution policy"++execution_grant() {+ local name="$1"+ local selector="$2"+ mutate "${name}" "data[\"items\"] << { \"apiVersion\" => \"networking.k8s.io/v1\", \"kind\" => \"NetworkPolicy\", \"metadata\" => { \"name\" => \"fixture-${name}\", \"namespace\" => \"mcp-host\" }, \"spec\" => { \"podSelector\" => ${selector}, \"policyTypes\" => [\"Ingress\"], \"ingress\" => [{ \"from\" => [{ \"namespaceSelector\" => { \"matchLabels\" => { \"kubernetes.io/metadata.name\" => \"mcp-server\" } } }], \"ports\" => [{ \"port\" => 9300, \"protocol\" => \"TCP\" }] }] } }"+}++grant_by_role="$(execution_grant grant-by-role '{ "matchLabels" => { "clerum.io/role" => "host-execution" } }')"+assert_result "${grant_by_role}" '{"selector_contract_ok":false,"hcc_lane":true}'+echo "PASS: live policy helper rejects a grant selecting execution Pods by role"++grant_by_operation="$(execution_grant grant-by-operation '{ "matchExpressions" => [{ "key" => "clerum.io/operation", "operator" => "Exists" }] }')"+assert_result "${grant_by_operation}" '{"selector_contract_ok":false,"hcc_lane":true}'+echo "PASS: live policy helper rejects a grant selecting execution Pods by operation"++grant_elsewhere="$(execution_grant grant-elsewhere '{ "matchLabels" => { "app" => "unrelated" } }')"+assert_result "${grant_elsewhere}" '{"selector_contract_ok":true,"hcc_lane":true}'+echo "PASS: live policy helper accepts a grant that cannot select execution Pods"++host_pod='{ "metadata": { "name": "host-a", "labels": { "clerum.io/managed-by": "host-context-controller", "clerum.io/context": "context-a" } } }'+execution_pod='{ "metadata": { "name": "exec-a", "labels": { "clerum.io/managed-by": "host-context-controller", "clerum.io/role": "host-execution", "clerum.io/operation": "op-1", "clerum.io/host-uid": "uid-1" } } }'+printf '{ "items": [%s, %s] }' "${host_pod}" "${execution_pod}" >"${tmp_dir}/pods-both.json"+printf '{ "items": [%s] }' "${execution_pod}" >"${tmp_dir}/pods-execution-only.json"+printf '{ "items": [%s] }' "${host_pod}" >"${tmp_dir}/pods-host-only.json"++assert_result "${tmp_dir}/valid.json" '{"selector_contract_ok":true,"hcc_lane":true}' "${tmp_dir}/pods-both.json"+echo "PASS: live pod check accepts a Host pod with egress next to an execution Pod without it"++assert_result "${tmp_dir}/valid.json" '{"selector_contract_ok":false}' "${tmp_dir}/pods-execution-only.json"+echo "PASS: live pod check rejects a namespace with no Host pod"++# The GFS lane selects app=mcp-host, a label execution Pods are not created with,+# so only the pod check can see an execution Pod that carries it.+labelled_execution_pod='{ "metadata": { "name": "exec-b", "labels": { "clerum.io/managed-by": "host-context-controller", "clerum.io/role": "host-execution", "app": "mcp-host" } } }'+printf '{ "items": [%s, %s] }' "${host_pod}" "${labelled_execution_pod}" >"${tmp_dir}/pods-labelled-execution.json"+assert_result "${gfs}" '{"selector_contract_ok":true}' "${tmp_dir}/pods-both.json"+assert_result "${gfs}" '{"selector_contract_ok":false}' "${tmp_dir}/pods-labelled-execution.json"+echo "PASS: live pod check rejects an execution Pod selected by a Host grant through its live labels"++no_host_egress="$(mutate no-host-egress 'data["items"].each { |d| d["spec"]["egress"] = [] if %w[mcp-host allow-dns-egress-mcp-host allow-k8s-api-egress-mcp-host].include?(d["metadata"]["name"]) }')"+assert_result "${no_host_egress}" '{"selector_contract_ok":false}' "${tmp_dir}/pods-host-only.json"+echo "PASS: live pod check rejects a Host pod with no egress grant"diff --git a/scripts/tests/test-np08-render-contract-fixtures.sh b/scripts/tests/test-np08-render-contract-fixtures.shindex 5068ddd46..8d8efe2db 100755--- a/scripts/tests/test-np08-render-contract-fixtures.sh+++ b/scripts/tests/test-np08-render-contract-fixtures.sh@@ -185,6 +185,54 @@ when 'host-secret-authenticated-group-grant'},'subjects' => [{ 'kind' => 'Group', 'name' => 'system:authenticated' }],}+when 'dns-without-execution-exclusion', 'k8s-api-wrong-execution-exclusion',+ 'execution-egress', 'execution-ingress-widened'+ name = {+ 'dns-without-execution-exclusion' => 'allow-dns-egress-mcp-host',+ 'k8s-api-wrong-execution-exclusion' => 'allow-k8s-api-egress-mcp-host',+ 'execution-egress' => 'host-execution-private',+ 'execution-ingress-widened' => 'host-execution-private',+ }.fetch(mutation)+ policy = documents.find do |document|+ document['kind'] == 'NetworkPolicy' &&+ document.dig('metadata', 'namespace') == 'mcp-host' &&+ document.dig('metadata', 'name') == name+ end+ abort("fixture source is missing mcp-host NetworkPolicy #{name}") unless policy+ case mutation+ when 'dns-without-execution-exclusion'+ policy['spec']['podSelector'].delete('matchExpressions')+ when 'k8s-api-wrong-execution-exclusion'+ policy['spec']['podSelector']['matchExpressions'][0]['values'] = ['other']+ when 'execution-egress'+ policy['spec']['egress'] = [{+ 'to' => [{ 'namespaceSelector' => { 'matchLabels' => { 'kubernetes.io/metadata.name' => 'kube-system' } } }],+ 'ports' => [{ 'port' => 53, 'protocol' => 'UDP' }],+ }]+ when 'execution-ingress-widened'+ policy['spec']['ingress'][0]['from'] << {+ 'namespaceSelector' => { 'matchLabels' => { 'kubernetes.io/metadata.name' => 'mcp-server' } },+ }+ end+when 'execution-grant-by-role', 'execution-grant-by-operation'+ pod_selector = if mutation == 'execution-grant-by-role'+ { 'matchExpressions' => [{ 'key' => 'clerum.io/role', 'operator' => 'In', 'values' => ['host-execution'] }] }+ else+ { 'matchLabels' => { 'clerum.io/operation' => 'fixture-operation' } }+ end+ documents << {+ 'apiVersion' => 'networking.k8s.io/v1',+ 'kind' => 'NetworkPolicy',+ 'metadata' => { 'name' => "fixture-#{mutation}", 'namespace' => 'mcp-host' },+ 'spec' => {+ 'podSelector' => pod_selector,+ 'policyTypes' => ['Ingress'],+ 'ingress' => [{+ 'from' => [{ 'namespaceSelector' => { 'matchLabels' => { 'kubernetes.io/metadata.name' => 'mcp-server' } } }],+ 'ports' => [{ 'port' => 9300, 'protocol' => 'TCP' }],+ }],+ },+ }elseabort("unknown fixture mutation: #{mutation}")end@@ -282,3 +330,35 @@ assert_rejected \"${host_secret_authenticated_group}" \'mcp-host identities must not receive MCP Secret read grants' \'mcp-host MCP Secret system:authenticated grant'++dns_without_execution_exclusion="${tmpdir}/dns-without-execution-exclusion.yaml"+mutate_render dns-without-execution-exclusion "${dns_without_execution_exclusion}"+assert_rejected \+ "${dns_without_execution_exclusion}" \+ 'allow-dns-egress-mcp-host must select HCC-managed Host pods except execution Pods and enforce Egress' \+ 'DNS egress inherited by execution Pods'++k8s_api_wrong_execution_exclusion="${tmpdir}/k8s-api-wrong-execution-exclusion.yaml"+mutate_render k8s-api-wrong-execution-exclusion "${k8s_api_wrong_execution_exclusion}"+assert_rejected \+ "${k8s_api_wrong_execution_exclusion}" \+ 'allow-k8s-api-egress-mcp-host must select HCC-managed Host pods except execution Pods and enforce Egress' \+ 'k8s API egress exclusion naming another role'++for execution_change in execution-egress execution-ingress-widened; do+ execution_private="${tmpdir}/${execution_change}.yaml"+ mutate_render "${execution_change}" "${execution_private}"+ assert_rejected \+ "${execution_private}" \+ 'host-execution-private must admit only HCC on 9300/9301 and grant no egress' \+ "private execution policy with ${execution_change}"+done++for execution_selector in role operation; do+ execution_grant="${tmpdir}/execution-grant-by-${execution_selector}.yaml"+ mutate_render "execution-grant-by-${execution_selector}" "${execution_grant}"+ assert_rejected \+ "${execution_grant}" \+ "execution Pods must not inherit mcp-host grants: fixture-execution-grant-by-${execution_selector}" \+ "mcp-host grant selecting execution Pods by ${execution_selector}"+donediff --git a/scripts/tests/test-np08-render-contract.sh b/scripts/tests/test-np08-render-contract.shindex a14487509..2cca2f3d2 100755--- a/scripts/tests/test-np08-render-contract.sh+++ b/scripts/tests/test-np08-render-contract.sh@@ -114,18 +114,94 @@ for rendered in "$@"; dopolicy_types_include_egress = lambda do |policy|Array(policy.dig("spec", "policyTypes")).include?("Egress")end- exact_pod_selector = lambda do |policy, expected_labels|+ # HCC also labels execution Pods clerum.io/managed-by=host-context-controller.+ # NetworkPolicies are additive, so every static Host grant must exclude them+ # with exactly this expression; any other narrowing of the Host selector fails.+ host_execution_exclusion = [+ { "key" => "clerum.io/role", "operator" => "NotIn", "values" => ["host-execution"] }+ ]+ static_host_pod_selector = lambda do |policy|selector = policy.dig("spec", "podSelector")- selector.is_a?(Hash) && selector.keys.sort == ["matchLabels"] &&- selector["matchLabels"] == expected_labels && Array(selector["matchExpressions"]).empty?+ selector.is_a?(Hash) && selector.keys.sort == ["matchExpressions", "matchLabels"] &&+ selector["matchLabels"] == { "clerum.io/managed-by" => "host-context-controller" } &&+ selector["matchExpressions"] == host_execution_exclusionenddefault_deny = policies.find { |policy| policy.dig("metadata", "name") == "deny-all-mcp-host" }abort("mcp-host default-deny must select every pod and enforce Egress") unlessdefault_deny && default_deny.dig("spec", "podSelector") == {} && policy_types_include_egress.call(default_deny)managed_host_policy = policies.find { |policy| policy.dig("metadata", "name") == "mcp-host" }abort("mcp-host allow policy must select HCC-managed Host pods and enforce Egress") unless- managed_host_policy && exact_pod_selector.call(managed_host_policy, { "clerum.io/managed-by" => "host-context-controller" }) &&+ managed_host_policy && static_host_pod_selector.call(managed_host_policy) &&policy_types_include_egress.call(managed_host_policy)+ %w[allow-dns-egress-mcp-host allow-k8s-api-egress-mcp-host].each do |name|+ policy = policies.find { |candidate| candidate.dig("metadata", "name") == name }+ abort("#{name} must select HCC-managed Host pods except execution Pods and enforce Egress") unless+ policy && static_host_pod_selector.call(policy) && policy_types_include_egress.call(policy)+ end++ execution_policy = policies.find { |policy| policy.dig("metadata", "name") == "host-execution-private" }+ expected_execution_spec = {+ "podSelector" => {+ "matchLabels" => {+ "clerum.io/managed-by" => "host-context-controller",+ "clerum.io/role" => "host-execution"+ }+ },+ "policyTypes" => ["Ingress", "Egress"],+ "ingress" => [+ {+ "from" => [+ {+ "namespaceSelector" => { "matchLabels" => { "kubernetes.io/metadata.name" => "control-plane" } },+ "podSelector" => { "matchLabels" => { "app" => "host-context-controller" } }+ }+ ],+ "ports" => [{ "port" => 9300, "protocol" => "TCP" }, { "port" => 9301, "protocol" => "TCP" }]+ }+ ],+ "egress" => []+ }+ abort("host-execution-private must admit only HCC on 9300/9301 and grant no egress") unless+ execution_policy && execution_policy["spec"] == expected_execution_spec++ # Any other mcp-host policy that grants traffic must not be able to select an+ # execution Pod. Operation and Host UID label values are per Pod, so a selector+ # keyed on them is treated as possibly matching.+ execution_static_labels = {+ "clerum.io/managed-by" => "host-context-controller",+ "clerum.io/role" => "host-execution"+ }+ execution_dynamic_labels = %w[clerum.io/operation clerum.io/host-uid]+ selects_execution_pod = lambda do |selector|+ next false unless selector.is_a?(Hash)+ labels_match = (selector["matchLabels"] || {}).all? do |key, value|+ execution_dynamic_labels.include?(key) || execution_static_labels[key] == value+ end+ expressions_match = Array(selector["matchExpressions"]).all? do |expression|+ key = expression["key"]+ values = Array(expression["values"])+ if execution_dynamic_labels.include?(key)+ expression["operator"] != "DoesNotExist"+ else+ present = execution_static_labels.key?(key)+ case expression["operator"]+ when "In" then present && values.include?(execution_static_labels[key])+ when "NotIn" then !present || !values.include?(execution_static_labels[key])+ when "Exists" then present+ when "DoesNotExist" then !present+ else abort("mcp-host policy uses an unknown selector operator")+ end+ end+ end+ labels_match && expressions_match+ end+ execution_grants = policies.select do |policy|+ next false if policy.dig("metadata", "name") == "host-execution-private"+ grants = !Array(policy.dig("spec", "ingress")).empty? || !Array(policy.dig("spec", "egress")).empty?+ grants && selects_execution_pod.call(policy.dig("spec", "podSelector"))+ end+ abort("execution Pods must not inherit mcp-host grants: #{execution_grants.map { |policy| policy.dig("metadata", "name") }.join(",")}") unless+ execution_grants.empty?context_allow_policies = policies.select do |policy|policy.dig("metadata", "labels", "clerum.io/policy-type") == "context-allow"end@@ -274,7 +350,7 @@ for rendered in "$@"; dohcc_lane = policies.any? do |policy|next false unless policy_types_include_egress.call(policy) &&- exact_pod_selector.call(policy, { "clerum.io/managed-by" => "host-context-controller" })+ static_host_pod_selector.call(policy)Array(policy.dig("spec", "egress")).any? do |rule|ports = Array(rule["ports"])peers = Array(rule["to"])