Feature/waf onboard custom rule group - #1620
Conversation
SerseusWasTaken
left a comment
There was a problem hiding this comment.
look pretty clean, but found an issue during testing:
Using this config:
resource "stackit_alb_waf_custom_rule_group" "custom_rule_group" {
project_id = local.project_id
name = "some-name"
rules = [
{
behavior = {
action = "ACTION_DENY"
log = true
}
conditions = [
{
operator = {
type = "OPERATOR_VALIDATE_UTF8_ENCODING"
value = "dummy"
}
variable = {
type = "VARIABLE_RESPONSE_STATUS"
}
}
]
}
]
}terraform apply runs successfully, but after changing rules[0].behavior.log to false, i got this error:
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to stackit_alb_waf_custom_rule_group.custom_rule_group, provider "provider[\"registry.terraform.io/stackitcloud/stackit\"]" produced an unexpected new value: .rules[0].behavior.log: was cty.False, but now null.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
| "rule_id": "Backend auto-allocated unique rule ID within the valid 1-99999 threshold.", | ||
| "behavior_action": "The protective stance action. ACTION_DENY forces a 403 status response code.", | ||
| "behavior_log": "Determines whether an entry should be generated in the security ledger upon a rule hit.", | ||
| "behavior_log_msg": "Custom notification message string mapped to underlying logdata contexts. Required if log is true.", |
There was a problem hiding this comment.
| "behavior_log_msg": "Custom notification message string mapped to underlying logdata contexts. Required if log is true.", | |
| "behavior_log_msg": "Custom notification message string mapped to underlying logdata contexts. Required if behavior_log is true.", |
| rules := []RuleModel{} | ||
| diags := model.Rules.ElementsAs(ctx, &rules, true) | ||
| if diags.HasError() { | ||
| return nil, fmt.Errorf("converting to rule map: %v", diags.Errors()) |
There was a problem hiding this comment.
Maybe use `core.DiagsToError(diags) here (and at the other instances) instead?
| return nil, fmt.Errorf("converting to rule map: %v", diags.Errors()) | |
| return nil, fmt.Errorf("converting to rule map: %w", core.DiagsToError(diags)) |
| if err != nil || conditions == nil { | ||
| return nil, fmt.Errorf("converting conditions: %w", err) | ||
| } |
There was a problem hiding this comment.
Nitpick: given err == nil but conditions != nil this would result in a unhelpful error message. This is highly unlikely to happen though, so feel free to ignore it
| } | ||
|
|
||
| model.Id = tfutils.BuildInternalTerraformId(model.ProjectId.ValueString(), region, model.Name.ValueString()) | ||
| model.Name = types.StringValue(model.Name.ValueString()) |
There was a problem hiding this comment.
Shouldn't this rather be something like this?
| model.Name = types.StringValue(model.Name.ValueString()) | |
| model.Name = types.StringValue(*customRuleGroup.Name) |
Merging this branch changes the coverage (1 decrease, 1 increase)
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
Description
relates to STACKITTPR-748
Checklist
make fmtexamples/directory)make generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)