-
Notifications
You must be signed in to change notification settings - Fork 10.1k
[WAF] Add note about FW rules migration #22213
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,44 +6,130 @@ sidebar: | |
| head: | ||
| - tag: title | ||
| content: Firewall rules JSON object | ||
|
|
||
| --- | ||
|
|
||
| import { Type } from "~/components"; | ||
|
|
||
| ## Firewall rule example JSON response | ||
|
|
||
| A JSON response for the [Firewall Rules API](/api/resources/firewall/subresources/rules/methods/list/) has this structure: | ||
|
|
||
| ```json | ||
| { | ||
| "id": "772bf1026a72c400ea576db1ffa16407", | ||
| "filter": { | ||
| "id": "6f58318e7fa2477a23112e8118c66f61", | ||
| "expression": "http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\"", | ||
| "paused": false, | ||
| "description": "WordPress login paths", | ||
| "ref": "" | ||
| }, | ||
| "action": "challenge", | ||
| "priority": 1000, | ||
| "paused": false, | ||
| "description": "Protect blog login page", | ||
| "ref": "" | ||
| "id": "772bf1026a72c400ea576db1ffa16407", | ||
| "filter": { | ||
| "id": "6f58318e7fa2477a23112e8118c66f61", | ||
| "expression": "http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\"", | ||
| "paused": false, | ||
| "description": "WordPress login paths", | ||
| "ref": "" | ||
| }, | ||
| "action": "challenge", | ||
| "priority": 1000, | ||
| "paused": false, | ||
| "description": "Protect blog login page", | ||
| "ref": "" | ||
| } | ||
| ``` | ||
|
|
||
| This table summarizes the object properties: | ||
|
|
||
|
|
||
| {/* prettier-ignore */} | ||
| <table> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| <thead> | ||
| <tr> | ||
| <th>Name</th> | ||
| <th>Description</th> | ||
| <th>Constraints</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <tr> | ||
| <td> | ||
| <code>id</code><br /> | ||
| <Type text="String" /> | ||
| </td> | ||
| <td>A UUIDv4 identifier generated by Cloudflare.</td> | ||
| <td> | ||
| <p>Unique, read only</p> | ||
| <p>Length: 32 characters</p> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td> | ||
| <code>filter</code><br /> | ||
| <Type text="Object" /> | ||
| </td> | ||
| <td> | ||
| A <a href="/firewall/api/cf-filters/json-object/">Cloudflare Filter object</a> that contains an expression for evaluating this rule. | ||
| </td> | ||
| <td></td> | ||
| </tr> | ||
| <tr> | ||
| <td> | ||
| <code>action</code><br /> | ||
| <Type text="String" /> | ||
| </td> | ||
| <td> | ||
| The action to take when a request satisfies the filter expression for this rule. | ||
| </td> | ||
| <td> | ||
| Refer to <a href="/firewall/cf-firewall-rules/actions/">Firewall rules actions</a> for a list of supported values. | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td> | ||
| <code>priority</code><br /> | ||
| <Type text="Number" /> | ||
| </td> | ||
| <td> | ||
| Determines the order of evaluation for the rule relative to others. Lower values indicate greater priority. Rules without a value are evaluated last. For guidance, refer to <a href="#avoiding-priority-conflicts">Avoiding priority conflicts</a>. | ||
| </td> | ||
| <td> | ||
| <p>Read only</p> | ||
| <p>Maximum length: 32</p> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td> | ||
| <code>paused</code><br /> | ||
| <Type text="Boolean" /> | ||
| </td> | ||
| <td> | ||
| Returns <code>true</code> when the rule is not active. Use <code>ref</code> to enable/disable the rule. | ||
| </td> | ||
| <td> | ||
| Default: <code>false</code> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td> | ||
| <code>description</code><br /> | ||
| <Type text="String" /> | ||
| </td> | ||
| <td>An informative summary of the rule.</td> | ||
| <td>Maximum length: 500 characters</td> | ||
| </tr> | ||
| <tr> | ||
| <td> | ||
| <code>ref</code><br /> | ||
| <Type text="String" /> | ||
| </td> | ||
| <td>A short string for tagging rules.</td> | ||
| <td>Maximum length: 50 characters</td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
|
|
||
| ## Avoiding priority conflicts | ||
|
|
||
| Priority plays a key role in configuring firewall rules. With Cloudflare Filters, it is possible to construct conflicting rules such as: | ||
|
|
||
| * Allow requests from the office IP range, and | ||
| * Block requests with a specific user agent. | ||
| - Allow requests from the office IP range, and | ||
| - Block requests with a specific user agent. | ||
|
|
||
| Requests from the office IP range using the user agent to block would trigger both rules, but we cannot both allow and block the request. To solve this problem, firewall rules follows a strict ordering depending on action and priority. | ||
|
|
||
| Cloudflare prioritizes rules in descending order, such that priority 1 is first and rules with no priority are last. For rules of equal priority, Cloudflare orders them by action according to their [order of precedence](/firewall/cf-firewall-rules/actions/#supported-actions). In the example above, if no priority is set, the rule `allow request from the office IP range` would apply because the *allow* action has a higher precedence than *block*. | ||
| Cloudflare prioritizes rules in descending order, such that priority 1 is first and rules with no priority are last. For rules of equal priority, Cloudflare orders them by action according to their [order of precedence](/firewall/cf-firewall-rules/actions/#supported-actions). In the example above, if no priority is set, the rule `allow request from the office IP range` would apply because the _allow_ action has a higher precedence than _block_. | ||
|
|
||
| To reduce the risk of unintended behavior, it is best to explicitly specify the desired priority for potentially conflicting rules. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Source:
https://github.com/cloudflare/cloudflare-docs/blob/4c3c819ebe3714df1698097135c645429bcbe7cc/content/firewall/api/cf-filters/json-object.md?plain=1