Skip to content
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

Add support for create/update individual ruleset rules #1744

Closed

Conversation

tcinbis
Copy link

@tcinbis tcinbis commented Apr 10, 2024

Description

This PR extends the ruleset.go and adds two new methods CreateRulesetRule and UpdateRulesetRule. The code was only slightly modified from the corresponding ruleset methods. This when merged closes #1211.

Has your change been tested?

The changes have been tested both using automated tests run locally (everything passing) and against a live CF Zone WAF API (not account API). Further, the new methods are also covered by two new tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • This change is using publicly documented in cloudflare/api-schemas
    and relies on stable APIs.

Copy link
Contributor

github-actions bot commented Apr 10, 2024

changelog detected ✅

tcinbis added a commit to tcinbis/cloudflare-go that referenced this pull request Apr 10, 2024
@tcinbis tcinbis force-pushed the tcinbis/feature/rulesetrules branch from d07cb70 to 1ff428b Compare April 10, 2024 19:21
@jacobbednarz
Copy link
Member

thanks for the PR! as v2 is just around the corner, instead of merging this, can you see if ruleset.Rules covers what you're after here?

@tcinbis
Copy link
Author

tcinbis commented Apr 11, 2024

thanks for the hint I will definitely check out v2 now. When you say "around the corner" what are we talking about in terms of time? I know estimates are a tricky but just to get a rough understanding.

@jacobbednarz
Copy link
Member

you can use it today, see #1538

it's just waiting for us to clean up a couple of UX improvements and slap a GA label on it.

@tcinbis
Copy link
Author

tcinbis commented Apr 11, 2024

Okay so I looked into v2 and while it is great, I am afraid that the functionality this PR would introduce is either missing or then I can't find it.

What is the functionality I am looking for?

We need to be able to CRUD individual rules in a WAF ruleset without updating the entire ruleset.
Otherwise, to my understanding we could be running into race conditions in which two individual clients are performing an ruleset update (please correct me if that is wrong).

@jacobbednarz
Copy link
Member

the link i provided above is for managing individual ruleset rules - the same as the PR you've proposed. you can confirm this by looking at the HTTP method and the path called.

as for your issue or concurrency, it exists in a ruleset and rule and neither will mitigate it because the backing service doesn't offer concurrency flags or a locking mechanism. you can still have two HTTP calls to the same resource which will result in a race condition; that is something you'll need to mitigate within your own coordination.

@tcinbis
Copy link
Author

tcinbis commented Apr 12, 2024

Maybe you could point me to the methods that can be used to updating the zone WAF rules, since I only manage to find the methods that use the accounts endpoint, but not he zone endpoints (searching for zones/%s/rulesets does not return any results for me).

Thank you very much!

@jacobbednarz
Copy link
Member

jacobbednarz commented Apr 12, 2024

see ruleset.Rules - if you provide an account identifier, it uses that, otherwise if you provide a zone identifier, it will use that instead.

@jacobbednarz
Copy link
Member

closing as v2 has this functionality today and you can use them alongside one another if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for updating individual rules within Rulesets
2 participants