Skip to content

Commit af49cf9

Browse files
author
Ben Lucas
authored
modify falco rule to remove value property as only values is used. fix so comps and fields are optional. (#241)
1 parent 22ee2aa commit af49cf9

File tree

3 files changed

+6
-29
lines changed

3 files changed

+6
-29
lines changed

sysdig/internal/client/secure/models.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ type Exception struct {
205205
Fields interface{} `json:"fields,omitempty"`
206206
Comps interface{} `json:"comps,omitempty"`
207207
Values interface{} `json:"values,omitempty"`
208-
Value interface{} `json:"value,omitempty"`
209208
}
210209

211210
func (r *Rule) ToJSON() io.Reader {

sysdig/resource_sysdig_secure_rule_falco.go

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ func resourceSysdigSecureRuleFalco() *schema.Resource {
7979
},
8080
"values": {
8181
Type: schema.TypeString,
82-
Optional: true,
83-
},
84-
"value": {
85-
Type: schema.TypeString,
86-
Optional: true,
82+
Required: true,
8783
},
8884
"fields": {
8985
Type: schema.TypeList,
@@ -298,20 +294,9 @@ func resourceSysdigRuleFalcoFromResourceData(d *schema.ResourceData) (secure.Rul
298294
}
299295

300296
values := cast.ToString(exceptionMap["values"])
301-
if values != "" {
302-
err := json.Unmarshal([]byte(values), &newFalcoException.Values)
303-
if err != nil {
304-
return secure.Rule{}, err
305-
}
306-
} else if newFalcoException.Fields != nil && newFalcoException.Comps != nil {
307-
return secure.Rule{}, errors.New("values is required on an exception when fields and comps are set")
308-
}
309-
310-
value := cast.ToString(exceptionMap["value"])
311-
newFalcoException.Value = value
312-
313-
if newFalcoException.Fields == nil && newFalcoException.Comps == nil && value == "" {
314-
return secure.Rule{}, errors.New("value is required on an exception when fields and comps are not set")
297+
err := json.Unmarshal([]byte(values), &newFalcoException.Values)
298+
if err != nil {
299+
return secure.Rule{}, err
315300
}
316301

317302
falcoExceptions = append(falcoExceptions, newFalcoException)

website/docs/r/secure_rule_falco.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ resource "sysdig_secure_rule_falco" "example" {
5151
[["java"], "sdjagent.jar"]
5252
])
5353
}
54-
55-
exceptions {
56-
name = "image_suffix"
57-
value = "secure-inline-scan" # Example of an exception with just a name/value pair
58-
}
5954
}
6055
```
6156

@@ -83,12 +78,10 @@ Supported fields for exceptions:
8378
* `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`.
8479
* `fields` - (Optional) Contains one or more fields that will extract a value from the syscall/k8s_audit events.
8580
* `comps` - (Optional) Contains comparison operators that align 1-1 with the items in the fields property.
86-
* `values` - (Optional) Contains tuples of values. Each item in the tuple should align 1-1 with the corresponding field
81+
* `values` - (Required) Contains tuples of values. Each item in the tuple should align 1-1 with the corresponding field
8782
and comparison operator. Since the value can be a string, a list of strings or a list of a list of strings, the value
8883
of this field must be supplied in JSON format. You can use the default `jsonencode` function to provide this value.
89-
See the usage example on the top. **Required** if `fields` and `comps` are set.
90-
* `value` - (Optional) Contains the single value used when exception is a name/value pair. **Required** if `fields` and
91-
`comps` are not set
84+
See the usage example on the top.
9285

9386
## Attributes Reference
9487

0 commit comments

Comments
 (0)