question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

edit firewall rules

See original GitHub issue

Hello,

I see that there’s the possibility to interact with firewall rules:

https://github.com/cloudflare/python-cloudflare/blob/b70b5209664dc64ae4f0e5773806aec05b799cbd/CloudFlare/api_v4.py#L172

How would be the equivalent python wrapper code for:

curl -s --request PUT \
  --url https://api.cloudflare.com/client/v4/zones/<zone-id>/firewall/rules \
  --header 'Authorization: Bearer <auth-code>' \
  --header 'Content-Type: application/json' \
  -d '[
      {
        "id": <rule-id>,
        "paused": false,
        "description": "carrier",
        "action": "block",
        "priority": null,
        "filter": {
          "id": <filter-id>,
          "expression": <my-expression>,
          "paused": false,
          "description": ""
        }
      }
    ]'

I was starting with that code but don’t know how to move on:

cf = CloudFlare.CloudFlare(email=<my-email>, key=<my-key>)
waf = cf.zones.firewall.rules.set(<abc>)...

Maybe someone can help me with that? Thanks!

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
net47commented, Nov 24, 2022

Thanks a lot, that did the trick - my expression was faulty.

get WAF rules:

get_rules = cf.zones.firewall.rules.get(zone_id)

set specific WAF rule:

set_rule = = cf.zones.firewall.rules.put(zone_id, data=data)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Create, edit, and delete rules · Cloudflare Firewall Rules docs
Select Edit (wrench icon) located on the right of your rule in the rules list to open the Edit firewall rule panel and...
Read more >
How to Adjust Windows Firewall Rules Across the Network
1. Log in to the domain controller server. · 2. Go to "Administrative Tools" and click "Windows Firewall with Advanced Security." · 3....
Read more >
Create a firewall rule - Deep Security Help Center - Trend Micro
Copy and then modify an existing rule. Right-click the rule in the Firewall Rules list and then click Duplicate. To edit the new...
Read more >
Edit Firewall Rule - API Guide - OnApp Documentation
Create own firewall rules; Destroy own firewall rules; Read own firewall rules; Update own firewall rules. To edit a firewall rule, use the...
Read more >
Best practices for configuring Windows Defender Firewall
Best practices for configuring Windows Defender Firewall · Keep default settings · Understand rule precedence for inbound rules · Create rules for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found