Skip to content
Back to skills

672 Patterns 23dd814e

ASecurity

```typescript // Deploy Cloudflare Managed Ruleset (default) await client.rulesets.create({ zone_id: 'zone_id', kind: 'zone', phase: 'http_request_firewall_managed', name: 'Cloudflare Managed Ruleset', rules: [ { action: 'execute', action_parameters: { id: 'efb7b8c949ac4650a09736fc376e9aee', // Cloudflare Managed // Or: '4814384a9e5d4991b9815dcfc25d2f1f' for OWASP CRS // Or: 'c2e184081120413c86c3ab7e14069605' for Exposed Credentials },

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added June 1, 2026
developmenttypescriptrustgosqlexpressapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned June 1, 2026

npx -y skills add tools-only/X-Skills --skill 672-patterns_23dd814e --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 672 Patterns 23dd814e?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 672 Patterns 23dd814e
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-672-patterns-23dd814e/badge)](https://www.skillsdirectory.com/skills/tools-only-672-patterns-23dd814e)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Common Patterns

## Deploy Managed Rulesets

```typescript
// Deploy Cloudflare Managed Ruleset (default)
await client.rulesets.create({
  zone_id: 'zone_id',
  kind: 'zone',
  phase: 'http_request_firewall_managed',
  name: 'Cloudflare Managed Ruleset',
  rules: [
    {
      action: 'execute',
      action_parameters: {
        id: 'efb7b8c949ac4650a09736fc376e9aee', // Cloudflare Managed
        // Or: '4814384a9e5d4991b9815dcfc25d2f1f' for OWASP CRS
        // Or: 'c2e184081120413c86c3ab7e14069605' for Exposed Credentials
      },
      expression: 'true', // All requests
      // Or: 'http.request.uri.path starts_with "/api"' for specific paths
      enabled: true,
    },
  ],
})
```

## Override Managed Ruleset

```typescript
await client.rulesets.create({
  zone_id: 'zone_id',
  phase: 'http_request_firewall_managed',
  rules: [
    {
      action: 'execute',
      action_parameters: {
        id: 'efb7b8c949ac4650a09736fc376e9aee',
        overrides: {
          // Override specific rules
          rules: [
            { id: '5de7edfa648c4d6891dc3e7f84534ffa', action: 'log' },
            { id: '75a0060762034b9dad4e883afc121b4c', enabled: false },
          ],
          // Override categories: wordpress, sqli, xss, rce, etc.
          categories: [
            { category: 'wordpress', enabled: false },
            { category: 'sqli', action: 'log' },
          ],
        },
      },
      expression: 'true',
    },
  ],
})
```

## Custom Rules

```typescript
await client.rulesets.create({
  zone_id: 'zone_id',
  kind: 'zone',
  phase: 'http_request_firewall_custom',
  name: 'Custom WAF Rules',
  rules: [
    // Attack score-based
    { action: 'block', expression: 'cf.waf.score gt 50', enabled: true },
    { action: 'challenge', expression: 'cf.waf.score gt 20', enabled: true },

    // Specific attack types
    { action: 'block', expression: 'cf.waf.score.sqli gt 30 or cf.waf.score.xss gt 30', enabled: true },

    // Geographic blocking
    { action: 'block', expression: 'ip.geoip.country in {"CN" "RU"}', enabled: true },
  ],
})
```

## Rate Limiting

```typescript
await client.rulesets.create({
  zone_id: 'zone_id',
  kind: 'zone',
  phase: 'http_ratelimit',
  name: 'Rate Limits',
  rules: [
    // Per-IP global limit
    {
      action: 'block',
      expression: 'true',
      action_parameters: {
        ratelimit: {
          characteristics: ['cf.colo.id', 'ip.src'],
          period: 60,
          requests_per_period: 100,
          mitigation_timeout: 600,
        },
      },
    },

    // Login endpoint (stricter)
    {
      action: 'block',
      expression: 'http.request.uri.path eq "/api/login"',
      action_parameters: {
        ratelimit: {
          characteristics: ['ip.src'],
          period: 60,
          requests_per_period: 5,
          mitigation_timeout: 600,
        },
      },
    },

    // API writes only (using counting_expression)
    {
      action: 'block',
      expression: 'http.request.uri.path starts_with "/api"',
      action_parameters: {
        ratelimit: {
          characteristics: ['cf.colo.id', 'ip.src'],
          period: 60,
          requests_per_period: 50,
          counting_expression: 'http.request.method ne "GET"',
        },
      },
    },
  ],
})
```

## Skip Rules

```typescript
await client.rulesets.create({
  zone_id: 'zone_id',
  kind: 'zone',
  phase: 'http_request_firewall_custom',
  name: 'Skip Rules',
  rules: [
    // Skip static assets (current ruleset only)
    {
      action: 'skip',
      action_parameters: { ruleset: 'current' },
      expression: 'http.request.uri.path matches "\\.(jpg|css|js|woff2?)$"',
    },

    // Skip all WAF phases for trusted IPs
    {
      action: 'skip',
      action_parameters: {
        phases: ['http_request_firewall_managed', 'http_ratelimit'],
      },
      expression: 'ip.src in {192.0.2.0/24}',
    },
  ],
})
```

## Complete Setup Example

Combine all three phases for comprehensive protection:

```typescript
const client = new Cloudflare({ apiToken: process.env.CF_API_TOKEN })
const zoneId = process.env.ZONE_ID

// 1. Custom rules (execute first)
await client.rulesets.create({
  zone_id: zoneId,
  phase: 'http_request_firewall_custom',
  rules: [
    {
      action: 'skip',
      action_parameters: { phases: ['http_request_firewall_managed', 'http_ratelimit'] },
      expression: 'ip.src in {192.0.2.0/24}',
    },
    { action: 'block', expression: 'cf.waf.score gt 50' },
    { action: 'managed_challenge', expression: 'cf.waf.score gt 20' },
  ],
})

// 2. Managed ruleset (execute second)
await client.rulesets.create({
  zone_id: zoneId,
  phase: 'http_request_firewall_managed',
  rules: [
    {
      action: 'execute',
      action_parameters: {
        id: 'efb7b8c949ac4650a09736fc376e9aee',
        overrides: { categories: [{ category: 'wordpress', enabled: false }] },
      },
      expression: 'true',
    },
  ],
})

// 3. Rate limiting (execute third)
await client.rulesets.create({
  zone_id: zoneId,
  phase: 'http_ratelimit',
  rules: [
    {
      action: 'block',
      expression: 'true',
      action_parameters: {
        ratelimit: {
          characteristics: ['cf.colo.id', 'ip.src'],
          period: 60,
          requests_per_period: 100,
          mitigation_timeout: 600,
        },
      },
    },
    {
      action: 'block',
      expression: 'http.request.uri.path eq "/api/login"',
      action_parameters: {
        ratelimit: { characteristics: ['ip.src'], period: 60, requests_per_period: 5, mitigation_timeout: 600 },
      },
    },
  ],
})
```

Files in this skill

  • README.md1 KB
  • skill.md5.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.