INTEGRITY Dokumentace

Validace výrazu

Cloudflare Filters API podporuje koncový bod pro ověřování výrazů.

Příklady

Ověření výrazu pomocí query stringu

Požadavek
curl "https://api.cloudflare.com/client/v4/filters/validate-expr?expression=ip.src==34" \
--header "X-Auth-Email: <EMAIL>" \
--header "X-Auth-Key: <API_KEY>"
Odpověď
{
  "result": null,
  "success": false,
  "errors": [
    {
      "message": "Filter parsing error:\n`ip.src==34`\n          ^^ couldn't parse address in network: invalid IP address syntax\n"
    }
  ],
  "messages": null
}

Všimněte si chyby ověření v odpovědi. V tomto příkladu chybu způsobil neplatný formát IP adresy:

Filter parsing error:
`ip.src==34`
          ^^ couldn't parse address in network: invalid IP address syntax

Ověření výrazu pomocí objektu JSON

Požadavek
curl "https://api.cloudflare.com/client/v4/filters/validate-expr" \
--header "X-Auth-Email: <EMAIL>" \
--header "X-Auth-Key: <API_KEY>" \
--header "Content-Type: application/json" \
--data '{
  "expression": "ip.src in {2400:cb00::/32 2405:8100::/2000 2c0f:f248::/32 2a06:98c0::/29}"
}'
Odpověď
{
  "result": null,
  "success": false,
  "errors": [
    {
      "message": "Filter parsing error:\n`ip.src in {2400:cb00::/32 2405:8100::/2000 2c0f:f248::/32 2a06:98c0::/29}`\n                                        ^^^^ number too large to fit in target type while parsing with radix 10\n"
    }
  ],
  "messages": null
}

Všimněte si chyby ověření v odpovědi. V tomto příkladu hodnota masky podsítě /2000, není platná maska IPv6 CIDR:

Filter parsing error:
`ip.src in {2400:cb00::/32 2405:8100::/2000 2c0f:f248::/32 2a06:98c0::/29}`
                                       ^^^^ number too large to fit in target type while parsing with radix 10