Skip to content

Filters

Ivan Kristianto edited this page Jul 7, 2020 · 1 revision

Filter JSON Object

{
    "id": "6f58318e7fa2477a23112e8118c66f61",
    "expression": "http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\""
    "paused": true,
    "description": "Wordpress login paths",
    "ref": ""
}

See this doc for more details: https://developers.cloudflare.com/firewall/api/cf-filters/json-object/

List Firewall Filters

List of zone firewall filters. See api doc here: https://developers.cloudflare.com/firewall/api/cf-filters/get/

Command: cf filters list <zone>

Options:

Options:
  --version    Show version number                                                                             [boolean]
  --help       Show help                                                                                       [boolean]
  --format     Format the output, value: table, string, json, list                                              [string]
  --separator  Separator value when the output format is string                                  [string] [default: " "]
  --fields     Fields to return                                                      [string] [default: "id,expression"]
  --perPage    Number of zones per page                                                                    [default: 20]
  --page       Page number of paginated results                                                             [default: 1]

Samples:

  • cf filters list example.com
  • cf filters list example.com --fields=id,expression,description,ref

Get details of Firewall Filter

Get detail of a zone firewall filters. See api doc here: https://developers.cloudflare.com/firewall/api/cf-filters/get/

Command: cf filters get <zone> <filterId>

Options:

Options:
  --version    Show version number                                                                             [boolean]
  --help       Show help                                                                                       [boolean]
  --format     Format the output, value: table, string, json, list                                              [string]
  --separator  Separator value when the output format is string                                  [string] [default: " "]
  --fields     Fields to return                                               [string] [default: "id,expression,paused"]

Samples:

  • cf filters get example.com 87da6860ddff43ada0d5a889178293df
  • cf filters get example.com 87da6860ddff43ada0d5a889178293df --fields=id,expression,description,ref

Create a Firewall Filter

Create a firewall filters. See api doc here: https://developers.cloudflare.com/firewall/api/cf-filters/post/

Command: cf filters create <zone> --expressions [expressions]

Options:

Options:
  --version      Show version number                                                                           [boolean]
  --help         Show help                                                                                     [boolean]
  --format       Format the output, value: table, string, json, list                                            [string]
  --separator    Separator value when the output format is string                                [string] [default: " "]
  --expressions  Filter Expression Rule                                                               [array] [required]
  --fields       Fields to return                                 [string] [default: "id,description,expression,paused"]

Samples:

  • cf filters create example.com --expressions {\"expression\":\"ip.src eq 124.123.123.11\"}
  • cf filters create example.com --expressions {\"expression\":\""$(cat ~/path/rules.txt)"\"}

Delete a Firewall Filter

Delete a firewall filters. See api doc here: https://developers.cloudflare.com/firewall/api/cf-filters/delete/

Command: cf filters delete <zone> <filterId>

Options:

Options:
  --version  Show version number                                                                               [boolean]
  --help     Show help                                                                                         [boolean]

Samples:

  • cf filters delete example.com 87da6860ddff43ada0d5a889178293df

Update a Firewall Filter

Update a firewall filters. See api doc here: https://developers.cloudflare.com/firewall/api/cf-filters/put/

Command: cf filters update <zone> <filterId>

Options:

Options:
  --version     Show version number                                                                            [boolean]
  --help        Show help                                                                                      [boolean]
  --format      Format the output, value: table, string, json, list                                             [string]
  --separator   Separator value when the output format is string                                 [string] [default: " "]
  --expression  Filter Expression Rule                                                               [string] [required]
  --paused      Pause filter                                                                  [boolean] [default: false]
  --fields      Fields to return                                              [string] [default: "id,expression,paused"]

Samples:

  • cf filters delete example.com 87da6860ddff43ada0d5a889178293df
  • cf filters update example.com 87da6860ddff43ada0d5a889178293df --paused=false
  • cf filters update example.com 87da6860ddff43ada0d5a889178293df --expressions {\"expression\":\""$(cat ~/path/rules.txt)"\"}