Skip to content

Commit 64589e3

Browse files
authored
feat: Make comps optional for falco exceptions (#219)
The comps field can be optional in the API, and is automatically evaluated with a default value when imported in Falco and Cloud Connector.
1 parent c25ced8 commit 64589e3

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

sysdig/resource_sysdig_secure_rule_falco.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func resourceSysdigSecureRuleFalco() *schema.Resource {
7474
},
7575
"comps": {
7676
Type: schema.TypeList,
77-
Required: true,
77+
Optional: true,
7878
Elem: &schema.Schema{Type: schema.TypeString},
7979
},
8080
"values": {
@@ -190,6 +190,8 @@ func fieldOrCompsToStringSlice(fields any) ([]string, error) {
190190
}
191191
case string:
192192
elements = append(elements, t)
193+
case nil:
194+
// do nothing
193195
default:
194196
return nil, fmt.Errorf("unexpected type: %T", t)
195197
}

sysdig/resource_sysdig_secure_rule_falco_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ resource "sysdig_secure_rule_falco" "falco_rule_with_exceptions" {
193193
comps = ["in"]
194194
values = jsonencode(["foo"])
195195
}
196+
exceptions {
197+
name = "only_one_field_without_comps"
198+
fields = ["ka.req.binding.subjects"]
199+
values = jsonencode(["foo"])
200+
}
196201
}
197202
`, name)
198203
}

website/docs/r/secure_rule_falco.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Supported fields for exceptions:
7777

7878
* `name` - (Required) The name of the exception. Only used to provide a handy name, and to potentially link together values in a later rule that has `append = true`.
7979
* `fields` - (Required) Contains one or more fields that will extract a value from the syscall/k8s_audit events.
80-
* `comps` - (Required) Contains comparison operators that align 1-1 with the items in the fields property.
80+
* `comps` - (Optional) Contains comparison operators that align 1-1 with the items in the fields property.
8181
* `values` - (Required) Contains tuples of values. Each item in the tuple should align 1-1 with the corresponding field and comparison operator. Since the value can be a string, a list of strings or a list of a list of strings, the value of this field must be supplied in JSON format. You can use the default `jsonencode` function to provide this value. See the usage example on the top.
8282

8383
## Attributes Reference

0 commit comments

Comments
 (0)