Skip to content

Commit

Permalink
fix: Solve nil pointer dereference in falco rules (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
tembleking authored Dec 19, 2022
1 parent 8fd2d4d commit bc0efd6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sysdig/resource_sysdig_secure_rule_falco.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ func resourceSysdigRuleFalcoRead(ctx context.Context, d *schema.ResourceData, me
}

rule, err := client.GetRuleByID(ctx, id)

if err != nil {
d.SetId("")
}
Expand All @@ -140,7 +139,9 @@ func resourceSysdigRuleFalcoRead(ctx context.Context, d *schema.ResourceData, me
}

updateResourceDataForRule(d, rule)
_ = d.Set("condition", rule.Details.Condition.Condition)
if rule.Details.Condition != nil {
_ = d.Set("condition", rule.Details.Condition.Condition)
}
_ = d.Set("output", rule.Details.Output)
_ = d.Set("priority", strings.ToLower(rule.Details.Priority))
_ = d.Set("source", rule.Details.Source)
Expand All @@ -157,6 +158,9 @@ func resourceSysdigRuleFalcoRead(ctx context.Context, d *schema.ResourceData, me
func updateResourceDataExceptions(d *schema.ResourceData, ruleExceptions []*secure.Exception) error {
exceptions := make([]any, 0, len(ruleExceptions))
for _, exception := range ruleExceptions {
if exception == nil {
return fmt.Errorf("exception is nil")
}
valuesData, err := json.Marshal(exception.Values)
if err != nil {
return fmt.Errorf("error marshalling exception values '%+v': %s", exception.Values, err)
Expand Down

0 comments on commit bc0efd6

Please sign in to comment.