Skip to content

Commit

Permalink
Add some more example policies
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin-decker committed Aug 17, 2023
1 parent 65f066a commit 449059c
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 0 deletions.
15 changes: 15 additions & 0 deletions policy/gcp/cloud-sql-connect.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package cloud_sql_connect

violation[{"msg": msg, "details": {"project": project, "actor": actor, "instance": instance}}] {
input.protoPayload.methodName == "cloudsql.instances.connect"

project = input.resource.labels.project_id
project == "example"

instance = input.resource.labels.database_id

actor = input.protoPayload.authenticationInfo.principalEmail
actor != "[email protected]"

msg = "unexpected connection to cloudsql instance"
}
11 changes: 11 additions & 0 deletions policy/gcp/firewall_rule_created.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package firewall_rule_created

violation[{"msg": msg, "details": {"project": project, "actor": actor, "name": name}}] {
input.protoPayload.request["@type"] == "type.googleapis.com/compute.firewalls.insert"

project = input.resource.labels.project_id
name = input.protoPayload.request.name
actor = input.protoPayload.authenticationInfo.principalEmail

msg = "firewall rule created"
}
12 changes: 12 additions & 0 deletions policy/gcp/gke-rbac-deny.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package gke_rbac_deny

violation[{"msg": msg, "details": {"cluster": cluster, "actor": actor, "method": method}}] {
input.labels["authorization.k8s.io/decision"] == "deny"

project = input.resource.labels.project_id
actor = input.protoPayload.authenticationInfo.principalEmail
cluster = input.resource.labels.cluster_name
method = input.protoPayload.methodName

msg = "GKE RBAC deny"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions policy/gcp/service_account_keys.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package service_account_keys

violation[{"msg": msg, "details": {"actor": actor, "service_account": svcAcct}}] {
input.protoPayload.methodName == "google.iam.admin.v1.CreateServiceAccountKey"

svcAcct = input.resource.labels.email_id
actor = input.protoPayload.authenticationInfo.principalEmail

msg = "service account key created"
}
File renamed without changes.

0 comments on commit 449059c

Please sign in to comment.