Skip to content

Commit d0b440a

Browse files
author
Ben Lucas
authored
fix(secure-policy): Update falco rule exceptions type to match falco expectations (#233)
* updates types for falco rule exceptions to more closely match how falco structures the exception values. * switch back to using string so we can jsonencode the value. update documentation to provide working example * fix spelling in readme. fix tests. * fix additional unit test
1 parent 3f7fbe8 commit d0b440a

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ $ make test
6363
If you want to execute the **acceptance tests**, you can run `make testacc`.
6464
- Follow [Terraform acceptance test guideliness](https://www.terraform.io/plugin/sdkv2/testing/acceptance-tests)
6565
- Please note that you need a token for Sysdig Monitor and another one for Sysdig Secure, and since the **acceptance tests create real infrastructure**
66-
you should execute them in an environment where you can remove the resorces easily.
66+
you should execute them in an environment where you can remove the resources easily.
6767
- Acceptance tests are launched in Sysdig production environment
6868

6969
```sh

sysdig/resource_sysdig_secure_rule_falco.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,7 @@ func resourceSysdigRuleFalcoFromResourceData(d *schema.ResourceData) (secure.Rul
284284
}
285285

286286
comps := cast.ToStringSlice(exceptionMap["comps"])
287-
if len(comps) == 1 {
288-
newFalcoException.Comps = comps[0]
289-
}
290-
if len(comps) > 1 {
287+
if len(comps) >= 1 {
291288
newFalcoException.Comps = comps
292289
}
293290

@@ -298,10 +295,7 @@ func resourceSysdigRuleFalcoFromResourceData(d *schema.ResourceData) (secure.Rul
298295
}
299296

300297
fields := cast.ToStringSlice(exceptionMap["fields"])
301-
if len(fields) == 1 {
302-
newFalcoException.Fields = fields[0]
303-
}
304-
if len(fields) > 1 {
298+
if len(fields) >= 1 {
305299
newFalcoException.Fields = fields
306300
}
307301

sysdig/resource_sysdig_secure_rule_falco_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ resource "sysdig_secure_rule_falco" "falco_rule_with_exceptions" {
191191
name = "only_one_field"
192192
fields = ["ka.req.binding.subjects"]
193193
comps = ["in"]
194-
values = jsonencode(["foo"])
194+
values = jsonencode([["foo"]])
195195
}
196196
exceptions {
197197
name = "only_one_field_without_comps"
198198
fields = ["ka.req.binding.subjects"]
199-
values = jsonencode(["foo"])
199+
values = jsonencode([["foo"]])
200200
}
201201
}
202202
`, name)
@@ -213,7 +213,7 @@ resource "sysdig_secure_rule_falco" "attach_to_cluster_admin_role_exceptions" {
213213
name = "proc_name"
214214
fields = ["proc.name"]
215215
comps = ["in"]
216-
values = jsonencode(["sh"])
216+
values = jsonencode([["sh"]])
217217
}
218218
}`
219219
}

website/docs/r/secure_rule_falco.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ resource "sysdig_secure_rule_falco" "example" {
3030
name = "proc_names"
3131
fields = ["proc.name"]
3232
comps = ["in"]
33-
values = jsonencode(["python", "python2", "python3"]) # If only one element is provided, do not specify it a list of lists.
33+
values = jsonencode([[["python", "python2", "python3"]]]) # If only one element is provided, it should still needs to be specified as a list of lists.
3434
}
3535
3636
exceptions {

0 commit comments

Comments
 (0)