Coder Social home page Coder Social logo

Modify WAF rules about python-cloudflare HOT 4 CLOSED

cloudflare avatar cloudflare commented on August 17, 2024
Modify WAF rules

from python-cloudflare.

Comments (4)

mahtin avatar mahtin commented on August 17, 2024

@Sarga - oh; this is actually a complete oversight of the core code within the _raw library call.

def _raw(self, method, headers,
         api_call_part1, api_call_part2=None, api_call_part3=None,
         identifier1=None, identifier2=None,
         params=None, data=None):
    ...
    url = (self.base_url + '/'
           + api_call_part1 + '/'
           + identifier1 + '/'
           + api_call_part2 + '/'
           + identifier2)
    ...

As you can see, there's no ability to handle a third identifier within an API call. This is an oversight that was introduced with the new API waf calls.

It's only affects the following API calls (which is the ones you are using):

 GET   /zones/:zone_identifier/firewall/waf/packages/:package_identifier/groups/:identifier
 PATCH /zones/:zone_identifier/firewall/waf/packages/:package_identifier/groups/:identifier
 GET   /zones/:zone_identifier/firewall/waf/packages/:package_identifier/rules/:identifier
 PATCH /zones/:zone_identifier/firewall/waf/packages/:package_identifier/rules/:identifier

Code will have to be written, both in cli4 and the core libraries. Maybe later today.

from python-cloudflare.

mahtin avatar mahtin commented on August 17, 2024

@Sarga - the code is now there. It's in the 1.4.8 release (and pushed to pip). The cli4 command works along with the python api code. The third identifier is passed via the api call just like the first two.

$ cli4 --get /zones/:example.com/firewall/waf/packages/:1e334934fd7ae32ad705667f8c1057aa/rules/:100008C
{
    "allowed_modes": [
        "default", 
        "disable", 
        "simulate", 
        "block", 
        "challenge"
    ], 
    "default_mode": "block", 
    "description": "Block SQLi sleep probing", 
    "group": {
        "id": "f90712123fb02287348dd34c0a282bb9", 
        "name": "Cloudflare Specials"
    }, 
    "id": "100008C", 
    "mode": "default", 
    "package_id": "1e334934fd7ae32ad705667f8c1057aa", 
    "priority": "22"
}
$

Please confirm on your side and then you can close this issue.

from python-cloudflare.

Sarga avatar Sarga commented on August 17, 2024

cli4 --get /zones/:example/firewall/waf/packages/:1e334934fd7ae32ad705667f8c1057aa/rules/:100008C - works well

cli4 --get /zones/:example.com/firewall/waf/packages/:1e334934fd7ae32ad705667f8c1057aa/rules/:100047WP - :NOT CODED YET 3

@mahtin check it please.

Also could you please add http2 / pseudo ipv4 settings?
#25

from python-cloudflare.

mahtin avatar mahtin commented on August 17, 2024

Yup - typo on my part. I matched [A-F] vs. [A-Z] (I just had a hexadecimal moment). This is now pushed to git and pip (as version 1.4.10).

$ cli4 --get /zones/:example.com/firewall/waf/packages/:1e334934fd7ae32ad705667f8c1057aa/rules/:100047WP 
{
    "allowed_modes": [
        "default", 
        "disable", 
        "simulate", 
        "block", 
        "challenge"
    ], 
    "default_mode": "disable", 
    "description": "Block WordPress User-Agent completely (Pingback attack)", 
    "group": {
        "id": "f90712123fb02287348dd34c0a282bb9", 
        "name": "Cloudflare Specials"
    }, 
    "id": "100047WP", 
    "mode": "default", 
    "package_id": "1e334934fd7ae32ad705667f8c1057aa", 
    "priority": "97"
}
$

Sorry for the extra cycle. Glad you are using the Python libs.

from python-cloudflare.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.