Skip to content

Commit 4deea58

Browse files
authored
GCP and Azure Falco rule support (#261)
* Add gcp_audiLog and azure_platformlogs as source * fix the dup words * fix test comment * use %[1]s format to remove dup args and run the tests * write working rule to pass the test
1 parent 798aefa commit 4deea58

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

sysdig/resource_sysdig_secure_rule_falco.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func resourceSysdigSecureRuleFalco() *schema.Resource {
5656
Type: schema.TypeString,
5757
Optional: true,
5858
Default: "",
59-
ValidateDiagFunc: validateDiagFunc(validation.StringInSlice([]string{"syscall", "k8s_audit", "aws_cloudtrail"}, false)),
59+
ValidateDiagFunc: validateDiagFunc(validation.StringInSlice([]string{"syscall", "k8s_audit", "aws_cloudtrail", "gcp_auditlog", "azure_platformlogs"}, false)),
6060
},
6161
"append": {
6262
Type: schema.TypeBool,

sysdig/resource_sysdig_secure_rule_falco_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ func TestAccRuleFalco(t *testing.T) {
5050
ImportState: true,
5151
ImportStateVerify: true,
5252
},
53+
{
54+
Config: ruleFalcoGcpAuditlog(rText()),
55+
},
56+
{
57+
Config: ruleFalcoAzureAuditlog(rText()),
58+
},
5359
{
5460
Config: ruleFalcoKubeAudit(rText()),
5561
},
@@ -155,6 +161,34 @@ resource "sysdig_secure_rule_falco" "kube_audit" {
155161
}`, name, name)
156162
}
157163

164+
func ruleFalcoGcpAuditlog(name string) string {
165+
return fmt.Sprintf(`
166+
resource "sysdig_secure_rule_falco" "gcp_audit" {
167+
name = "TERRAFORM TEST %[1]s - GCP Audit"
168+
description = "TERRAFORM TEST %[1]s"
169+
tags = ["gcp"]
170+
171+
condition = "gcp.serviceName=\"compute.googleapis.com\" and gcp.methodName endswith \".compute.instances.setMetadata\""
172+
output = "GCP Audit Event received (%%gcp.serviceName, %%gcp.methodName)"
173+
priority = "debug"
174+
source = "gcp_auditlog"
175+
}`, name)
176+
}
177+
178+
func ruleFalcoAzureAuditlog(name string) string {
179+
return fmt.Sprintf(`
180+
resource "sysdig_secure_rule_falco" "azure_audit" {
181+
name = "TERRAFORM TEST %[1]s - Azure Audit"
182+
description = "TERRAFORM TEST %[1]s"
183+
tags = ["azure"]
184+
185+
condition = "jevt.value[/operationName] = \"DeleteBlob\""
186+
output = "Azure Audit Event received (%%jevt.value[/operationName])"
187+
priority = "debug"
188+
source = "azure_platformlogs"
189+
}`, name)
190+
}
191+
158192
func ruleFalcoTerminalShellWithAppend() string {
159193
return `
160194
resource "sysdig_secure_rule_falco" "terminal_shell_append" {

website/docs/r/secure_rule_falco.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ resource "sysdig_secure_rule_falco" "example" {
2323
condition = "spawned_process and container and shell_procs and proc.tty != 0 and container_entrypoint"
2424
output = "A shell was spawned in a container with an attached terminal (user=%user.name %container.info shell=%proc.name parent=%proc.pname cmdline=%proc.cmdline terminal=%proc.tty container_id=%container.id image=%container.image.repository)"
2525
priority = "notice"
26-
source = "syscall" // syscall or k8s_audit
26+
source = "syscall" // syscall, k8s_audit, aws_cloudtrail, gcp_auditlog or azure_platformlogs
2727
2828
2929
exceptions {
@@ -64,7 +64,7 @@ The following arguments are supported:
6464
* `condition` - (Required) A [Falco condition](https://falco.org/docs/rules/) is simply a Boolean predicate on Sysdig events expressed using the Sysdig [filter syntax](http://www.sysdig.org/wiki/sysdig-user-guide/#filtering) and macro terms.
6565
* `output` - (Optional) Add additional information to each Falco notification's output. Required if append is false.
6666
* `priority` - (Optional) The priority of the Falco rule. It can be: "emergency", "alert", "critical", "error", "warning", "notice", "info" or "debug". By default is "warning".
67-
* `source` - (Optional) The source of the event. It can be either "syscall", "k8s_audit" or "aws_cloudtrail". Required if append is false.
67+
* `source` - (Optional) The source of the event. It can be either "syscall", "k8s_audit", "aws_cloudtrail", "gcp_auditlog", or "azure_platformlogs". Required if append is false.
6868
* `exceptions` - (Optional) The exceptions key is a list of identifier plus list of tuples of filtercheck fields. See below for details.
6969
* `append` - (Optional) This indicates that the rule being created appends the condition to an existing Sysdig-provided rule. By default this is false. Appending to user-created rules is not supported by the API.
7070

@@ -95,4 +95,4 @@ Secure Falco runtime rules can be imported using the ID, e.g.
9595

9696
```
9797
$ terraform import sysdig_secure_rule_falco.example 12345
98-
```
98+
```

0 commit comments

Comments
 (0)