我们要禁用oc get/describe
forsecrets
以防止令牌登录
当前政策禁止创建、更新、删除但不禁止查看机密
package admission
import data.k8s.matches
# Deny all user for doing secret ops except policyadmin
deny[query] {
matches[[resource]]
not "policyadmin" == resource.userInfo.username
"Secret" == resource.kind.kind
msg := sprintf("Custom Unauthorized user: %v", [resource.userInfo.username])
query = {
"id": "policy-admin-for-secret-only",
"resource": {
"kind": kind,
"namespace": namespace,
"name": name
},
"resolution": {
"message": msg
},
}
}
资源对象中的数据只是:
{\"kind\": {\"group\": \"\", \"kind\": \"Secret\", \"version\": \"v1\"}, \"name\": \"s5-token-n6v6q\", \"namespace\": \"demo\", \"operation\": \"DELETE\", \"resource\": {\"group\": \"\ ",\"资源\":\"秘密\",\"版本\":\"v1\"},\"uid\":\"748cdab2-1c1d-11ea-8b11-080027f8814d\",\"用户信息\": {\"groups\": [\"system:cluster-admins\", \"system:masters\", \"system:authenticated\"], \"username\": \"system:admin\ "}
https://github.com/raffaelespazzoli/openshift-opa/blob/master/examples/authorization-webhooks/unreadable_secrets.rego中的示例使用了resource.spec对象,但我认为它在我的input/AdmissionReview
对象中不可用?
我在用
- 迷你换档 1.24
- openshift v3.9.0+2e78773-56
- Kubernetes v1.9.1+a0ce1bc657
- etcd 3.2.16