Skip to content

Commit 0a4c979

Browse files
authored
feat(webhook-datasource) - customize sink filter (#32)
1 parent 4ea84ca commit 0a4c979

File tree

6 files changed

+11
-2
lines changed

6 files changed

+11
-2
lines changed

modules/services/webhook-datasource/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ No modules.
7373
| <a name="input_external_id"></a> [external\_id](#input\_external\_id) | (Required) Random string generated unique to a customer | `string` | n/a | yes |
7474
| <a name="input_suffix"></a> [suffix](#input\_suffix) | (Optional) Suffix to uniquely identify resources during multiple installs. If not provided, random value is autogenerated | `string` | `null` | no |
7575
| <a name="input_audit_log_config"></a> [audit\_log\_config](#input\_audit\_log\_config) | List of services and their audit log configurations to be ingested. Default is to ingest all logs. | <pre>list(object({<br> service = string,<br> log_config = list(object({<br> log_type = string,<br> exempted_members = optional(list(string))<br> }))<br> }))</pre> | <pre>[<br> {<br> "log_config": [<br> {<br> "log_type": "ADMIN_READ"<br> },<br> {<br> "log_type": "DATA_READ"<br> },<br> {<br> "log_type": "DATA_WRITE"<br> }<br> ],<br> "service": "allServices"<br> }<br>]</pre> | no |
76+
| <a name="ingestion_sink_filter"></a> [ingestion\_sink\_filter](#input\_ingestion\_sink\_filter) | Filter the Sink is set up with. Ingests AuditLogs by default. | `string` | `protoPayload.@type = "type.googleapis.com/google.cloud.audit.AuditLog"` | no |
7677
| <a name="input_exclude_logs_filter"></a> [exclude\_logs\_filter](#input\_exclude\_logs\_filter) | Filter to exclude logs from ingestion. Default is to ingest all google.cloud.audit.AuditLog logs. with no exclusions. | <pre>list(object({<br> name = string,<br> description = optional(string),<br> filter = string,<br> disabled = optional(bool)<br> }))</pre> | `[]` | no |
7778

7879
## Outputs

modules/services/webhook-datasource/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ resource "google_logging_project_sink" "ingestion_sink" {
8383
# NOTE: The target destination is a PubSub topic
8484
destination = "pubsub.googleapis.com/projects/${var.project_id}/topics/${google_pubsub_topic.ingestion_topic.name}"
8585

86-
filter = "protoPayload.@type = \"type.googleapis.com/google.cloud.audit.AuditLog\""
86+
filter = var.ingestion_sink_filter
8787

8888
# Dynamic block to exclude logs from ingestion
8989
dynamic "exclusions" {

modules/services/webhook-datasource/organizational.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ resource "google_logging_organization_sink" "ingestion_sink" {
3939

4040
# NOTE: The target destination is a PubSub topic
4141
destination = "pubsub.googleapis.com/projects/${var.project_id}/topics/${google_pubsub_topic.ingestion_topic.name}"
42-
filter = "protoPayload.@type = \"type.googleapis.com/google.cloud.audit.AuditLog\""
42+
filter = var.ingestion_sink_filter
4343

4444
# Dynamic block to exclude logs from ingestion
4545
dynamic "exclusions" {

modules/services/webhook-datasource/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ variable "audit_log_config" {
9696
]
9797
}
9898

99+
variable "ingestion_sink_filter" {
100+
type = string
101+
description = "Filter the Sink is set up with. Ingests AuditLogs by default."
102+
default = "protoPayload.@type = \"type.googleapis.com/google.cloud.audit.AuditLog\""
103+
}
104+
99105
variable "exclude_logs_filter" {
100106
description = "Filter to exclude logs from ingestion. Default is to ingest all google.cloud.audit.AuditLog logs. with no exclusions."
101107
type = list(object({

test/examples/secure_threat_detection/organization/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module "organization-threat-detection" {
1010
is_organizational = true
1111
organization_domain = "mytestorg.com"
1212
external_id = "external_id"
13+
ingestion_sink_filter = "protoPayload.@type = \"type.googleapis.com/google.cloud.audit.AuditLog\" (protoPayload.methodName!~ \"\\.(get|list)$\" OR protoPayload.serviceName != (\"k8s.io\" and \"storage.googleapis.com\"))"
1314
audit_log_config = [
1415
{
1516
service = "cloudsql.googleapis.com"

test/examples/secure_threat_detection/single/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module "single-project-threat-detection" {
88
project_id = "mytestproject"
99
push_endpoint = "test_sysdig_secure_cloudingestion_endpoint"
1010
external_id = "external_id"
11+
ingestion_sink_filter = "protoPayload.@type = \"type.googleapis.com/google.cloud.audit.AuditLog\" (protoPayload.methodName!~ \"\\.(get|list)$\" OR protoPayload.serviceName != (\"k8s.io\" and \"storage.googleapis.com\"))"
1112
audit_log_config = [
1213
{
1314
service = "cloudsql.googleapis.com"

0 commit comments

Comments
 (0)