-
Notifications
You must be signed in to change notification settings - Fork 71
Adds account level and workspace level operations for ngwaf rules using json file inputs #1605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
95435c5 to
fabc92c
Compare
…for ngwaf rules using json file inputs
fabc92c to
ca877a2
Compare
| return fmt.Errorf("failed to read json file: %v", err) | ||
| } | ||
|
|
||
| if err := json.Unmarshal(byteValue, input); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I did some testing with a simple rule payload, a rule was created with no issues. However, when I attempted to use a more complex payload that contained several group operators, some nested fields were mapped as null.
I used this arbitrary payload:
{
"type": "request",
"description": "complex_test",
"enabled": true,
"expires_at": "",
"group_operator": "all",
"conditions": [
{
"type": "single",
"field": "ip",
"operator": "equals",
"value": "1.2.3.4"
},
{
"type": "single",
"field": "country",
"operator": "equals",
"value": "AE"
},
{
"type": "group",
"group_operator": "all",
"conditions": [
{
"type": "single",
"field": "ip",
"operator": "equals",
"value": "2.4.5.6"
},
{
"type": "single",
"field": "country",
"operator": "equals",
"value": "AD"
}
]
},
{
"type": "group",
"group_operator": "all",
"conditions": [
{
"type": "single",
"field": "domain",
"operator": "equals",
"value": "test.com"
},
{
"type": "single",
"field": "agent_name",
"operator": "equals",
"value": "test"
}
]
}
],
"actions": [
{
"type": "browser_challenge",
"allow_interactive": true,
"signal": ""
}
],
"request_logging": "none"
}
The following was sent to the API, which resulted in an error.
{
"actions": [
{
"allow_interactive": true,
"signal": "",
"type": "browser_challenge"
}
],
"conditions": [
{
"type": "single",
"field": "ip",
"operator": "equals",
"value": "1.2.3.4"
},
{
"type": "single",
"field": "country",
"operator": "equals",
"value": "AE"
},
{
"type": "single",
"field": null,
"operator": null,
"value": null
},
{
"type": "single",
"field": null,
"operator": null,
"value": null
}
],
"description": "complex_test",
"enabled": true,
"scope": {
"type": "workspace",
"applies_to": ["nBw2ENWfOY1M2dpSwK1l5R"]
},
"type": "request"
}
You can see here that some fields were not parsed correctly. I believe we need to do some custom unmarshaling here to handle the group conditions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to map top level "type": "group", to GroupConditions in go-fastly and top level "type": "single", to Condiitons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah rats, i'll get on that. TY!
Change summary
Add support for NGWAF rule manipulation.
createandupdateare handled by allowing the user to proved a valid json that can be unmarshalled to the matching structure for the given rule level.All Submissions:
New Feature Submissions:
Changes to Core Features: