Docs / Reference / Security
ManagedRuleset
ManagedRuleset deploys a Cloudflare managed ruleset to a zone, as an execute rule in its http_request_firewall_managed phase; the expression selects the requests the ruleset inspects, and "true" selects every request. Cloudflare deploys its Free Managed Ruleset to Free zones by default, but only while the zone has no rules of its own in the phase: as soon as any rule is there, only what the rules deploy runs. To turn a managed ruleset off, keep its ManagedRuleset and set enabled to false.
- API version
- kflare.dev/v1alpha1
- Scope
- Namespaced
- Short name
- cfmanaged
- Token permission
- Zone · Zone WAF · Edit
Example
Every field, with the sample's values. The live lines are the repository's sample, which applies as it is; the commented ones are the other fields, filled from other samples where one sets them. Some exclude each other, so check the rules before you uncomment several.
apiVersion: kflare.dev/v1alpha1
kind: ManagedRuleset
metadata:
name: example-managedruleset
namespace: default
spec:
zoneRef:
name: example-zone
expression: "true"
description: Free Managed Ruleset, the WordPress rules only logging
id: 77454fe2d30c4220b5701f6fdfb893ba
overrides:
categories:
- category: wordpress
action: log
# - category: wordpress
# action: log # one of: block, challenge, js_challenge, managed_challenge, log
# enabled: true
rules:
- id: 7dfd111a6bad4b86bf3522cce6c5792f
enabled: false
# - id: 7dfd111a6bad4b86bf3522cce6c5792f
# enabled: false
# action: block # one of: block, challenge, js_challenge, managed_challenge, log
# action: block # one of: block, challenge, js_challenge, managed_challenge, log
# enabled: true
# enabled: true
# priority: 1Spec
What you set, with the limits the API server enforces.
| Field | Description |
|---|---|
descriptionstring | Description is shown with the rule in the Cloudflare dashboard. Limits: at most 4096 characters |
enabledboolean | Enabled turns the rule on or off without deleting it. Default: |
expressionstringrequired | Expression selects the requests the rule applies to, in Cloudflare's Rules language, for example Limits: 1 to 4096 characters |
idstringrequired | ID is the managed ruleset to deploy. Free plans can deploy the Cloudflare Free Managed Ruleset, 77454fe2d30c4220b5701f6fdfb893ba; higher plans also the Cloudflare Managed Ruleset, efb7b8c949ac4650a09736fc376e9aee, and the OWASP Core Ruleset, 4814384a9e5d4991b9815dcfc25d2f1f. Cloudflare always runs the ruleset's latest version. A zone can deploy a ruleset only once. Limits: matches |
overridesobject | Overrides change what the ruleset's rules do. An override for a rule takes precedence over one for a category the rule is tagged with, which takes precedence over the overrides for the whole ruleset. Rule: must set at least one of action, categories, enabled and rules |
overrides.actionstring | Action replaces the action of every rule of the ruleset. One of: |
overrides.categories[]object | Categories override the rules tagged with a category, such as wordpress or log4j, each listed once. Cloudflare refuses a category none of the ruleset's rules has (20235). Limits: at least 1 item Rule: must set at least 2 of category, action and enabled |
overrides.categories[].actionstring | Action replaces the action of the category's rules. One of: |
overrides.categories[].categorystringrequired | The name of the category to override. Limits: at least 1 character |
overrides.categories[].enabledboolean | Whether to enable execution of rules in the category. |
overrides.enabledboolean | Whether to enable execution of all rules. This option has lower precedence than rule and category overrides. |
overrides.rules[]object | Rules override single rules of the ruleset, by ID, each listed once. Limits: at least 1 item Rule: must set at least 2 of id, action and enabled |
overrides.rules[].actionstring | Action replaces the rule's action. One of: |
overrides.rules[].enabledboolean | Whether to enable execution of the rule. |
overrides.rules[].idstringrequired | The ID of the rule to override. Limits: matches |
priorityinteger | Priority orders the rules kflare manages in a zone and phase: lower runs first, and rules with the same priority run in order of namespace and name. Rules created outside kflare keep their place. Limits: format |
zoneRefobjectrequiredimmutable | ZoneRef references the Zone, in the same namespace, the rule belongs to. Immutable after creation. |
zoneRef.namestring | Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names Default: |
Status
What kflare reports. conditions holds the Ready condition, whose reason says why a resource isn't ready.
| Field | Description |
|---|---|
cloudflareMetadataobject | CloudflareMetadata identifies the rule in Cloudflare. |
cloudflareMetadata.refstring | Ref is the rule's ref, which kflare derives from the resource's kind, namespace and name. kflare finds the rule it manages by its ref. |
cloudflareMetadata.ruleIDstring | RuleID is the rule's Cloudflare ID. |
cloudflareMetadata.rulesetIDstring | RulesetID is the zone's entry point ruleset for the rule's phase. |
cloudflareMetadata.versionstring | Version is the rule's version, which Cloudflare increments whenever the rule changes. |
cloudflareMetadata.zoneIDstring | ZoneID is the Cloudflare zone the rule is in. |
conditions[]object | Conditions represent the latest available observations of the rule's state. |
kubectl get
The columns kubectl get managedrulesets prints.
| Column | Source |
|---|---|
| RULESET | .spec.id |
| PRIORITY | .spec.priority |
| RULE ID | .status.cloudflareMetadata.ruleID |
| READY | .status.conditions[?(@.type=="Ready")].status |
| AGE | .metadata.creationTimestamp |
Samples
From the repository's config/samples, comments included.
# Generated by kflare-gen from generator/generator.yaml. DO NOT EDIT.
#
# ManagedRuleset is the Schema for the managedrulesets API.
# It deploys a Cloudflare managed ruleset to a zone, as an execute rule in
# its http_request_firewall_managed phase; the expression selects the
# requests the ruleset inspects, and "true" selects every request.
# Cloudflare deploys its Free Managed Ruleset to Free zones by default, but
# only while the zone has no rules of its own in the phase: as soon as any
# rule is there, only what the rules deploy runs. To turn a managed ruleset
# off, keep its ManagedRuleset and set enabled to false.
apiVersion: kflare.dev/v1alpha1
kind: ManagedRuleset
metadata:
name: example-managedruleset
namespace: default
spec:
zoneRef:
name: example-zone
expression: "true"
description: Free Managed Ruleset, the WordPress rules only logging
id: 77454fe2d30c4220b5701f6fdfb893ba
overrides:
categories:
- category: wordpress
action: log
rules:
- id: 7dfd111a6bad4b86bf3522cce6c5792f
enabled: false