All Products
Search
Document Center

Edge Security Acceleration:BatchCreateDcdnWafRules

Last Updated:Jun 10, 2026

Membuat aturan mitigasi Web Application Firewall (WAF).

Deskripsi operasi

Catatan

The call frequency for this operation is limited to 20 calls per second for each user.

Coba sekarang

Coba API ini di OpenAPI Explorer tanpa perlu penandatanganan manual. Panggilan yang berhasil akan secara otomatis menghasilkan contoh kode SDK sesuai dengan parameter Anda. Unduh kode tersebut dengan kredensial bawaan yang aman untuk penggunaan lokal.

Test

RAM authorization

Tabel berikut menjelaskan otorisasi yang diperlukan untuk memanggil API ini. Anda dapat menentukannya dalam kebijakan Resource Access Management (RAM). Kolom pada tabel dijelaskan sebagai berikut:

  • Action: Aksi yang dapat digunakan dalam elemen Action pada pernyataan kebijakan izin RAM untuk memberikan izin guna melakukan operasi tersebut.

  • API: API yang dapat Anda panggil untuk melakukan aksi tersebut.

  • Access level: Tingkat akses yang telah ditentukan untuk setiap API. Nilai yang valid: create, list, get, update, dan delete.

  • Resource type: Jenis resource yang mendukung otorisasi untuk melakukan aksi tersebut. Ini menunjukkan apakah aksi tersebut mendukung izin tingkat resource. Resource yang ditentukan harus kompatibel dengan aksi tersebut. Jika tidak, kebijakan tersebut tidak akan berlaku.

    • Untuk API dengan izin tingkat resource, jenis resource yang diperlukan ditandai dengan tanda bintang (*). Tentukan Nama Sumber Daya Alibaba Cloud (ARN) yang sesuai dalam elemen Resource pada kebijakan.

    • Untuk API tanpa izin tingkat resource, ditampilkan sebagai All Resources. Gunakan tanda bintang (*) dalam elemen Resource pada kebijakan.

  • Condition key: Kunci kondisi yang didefinisikan oleh layanan. Kunci ini memungkinkan kontrol granular, berlaku baik hanya untuk aksi maupun untuk aksi yang terkait dengan resource tertentu. Selain kunci kondisi spesifik layanan, Alibaba Cloud menyediakan serangkaian common condition keys yang berlaku di semua layanan yang didukung RAM.

  • Dependent action: Aksi dependen yang diperlukan untuk menjalankan aksi tersebut. Untuk menyelesaikan aksi tersebut, pengguna RAM atau role RAM harus memiliki izin untuk melakukan semua aksi dependen.

Action

Access level

Resource type

Condition key

Dependent action

dcdn:BatchCreateDcdnWafRules

create

*All Resource

*

None None

Parameter permintaan

Parameter

Type

Required

Description

Example

PolicyId

integer

Yes

ID kebijakan mitigasi.

1000001

RuleConfigs

string

Yes

Konfigurasi aturan mitigasi.

[{"name":"example","action":"monitor","conditions":[{"key":"URL","opValue":"match-one","values":"1,2,3,4,5"},{"key":"Header","opValue":"contain-one","subKey":"example_subkey","values":"6,7,8,9,10"}],"ratelimit":{"target":"header","interval":10,"threshold":5,"ttl":1800,"subKey":"example_subkey","status":{"code":"502","count":5}},"ccStatus":"on","effect":"rule","status":"on"}]

Deskripsi RuleConfigs

  • RuleConfigs adalah larik objek. Setiap objek mewakili sebuah aturan.

  • Format RuleConfigs bervariasi berdasarkan tipe kebijakan mitigasi yang terkait dengan PolicyId.

Skenario 1: WAF (waf_group)

ParameterTipeWajibContohDeskripsi
statusStringTidakonStatus aturan. Nilai valid: on dan off. Nilai default adalah on.
actionStringYablockTindakan aturan. Nilai valid: block dan monitor.
wafGroupIdsStringTidak1012ID grup aturan WAF. Nilai default adalah 1012. Pisahkan beberapa ID dengan koma (,).

Contoh konfigurasi waf_group:

// Kebijakan WAF hanya mendukung satu aturan.
[
  {
    "status": "on",
    "action": "block"
  }
]
```.

### Skenario 2: Aturan kustom (custom\_acl)

| Nama       | Tipe      | Wajib | Contoh                                                                                    | Deskripsi                                                                                                                                                                       |
| ---------- | --------- | ----- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name       | string    | Ya    | acl\_1                                                                                    | Nama aturan. Nama dapat berisi huruf kecil, huruf besar, digit (0 sampai 9), dan garis bawah (\_). Panjang nama maksimum 64 karakter.                                            |
| status     | string    | Tidak | on                                                                                        | Nilai valid: on dan off. Nilai default adalah on.                                                                                                                               |
| conditions | Condition | Ya    | \[ {"key": "URI", "subKey": "","opValue": "contain", "values": "/login.php" }]            | Kondisi yang memicu aturan. Untuk informasi lebih lanjut tentang parameter, lihat **Tabel 1. Parameter Condition**.                                                              |
| ccStatus   | string    | Ya    | off                                                                                       | Apakah akan mengaktifkan pembatasan kecepatan. Nilai valid: on dan off.                                                                                                          |
| rateLimit  | RateLimit | Tidak | { "target": "Header", "subKey": "User-Agent", "interval": 5, "threshold": 2, "ttl": 1800} | Aturan pembatasan kecepatan. Parameter ini wajib jika ccStatus diatur ke on. Untuk informasi lebih lanjut tentang parameter, lihat **Tabel 2. Parameter RateLimit**.             |
| effect     | string    | Tidak | service                                                                                   | Cakupan daftar hitam pembatasan kecepatan. Parameter ini wajib jika ccStatus diatur ke on. Nilai valid: rule (aturan saat ini) dan service (global).                              |
| action     | string    | Ya    | deny                                                                                      | Tindakan aturan. Nilai valid: deny, js (JavaScript Challenge), dan monitor.                                                                                                      |

Tabel 1. Parameter Condition

| Nama    | Tipe   | Wajib | Contoh                 | Deskripsi                                                                                                                          |
| ------- | ------ | ----- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| Key     | string | Ya    | Query String Parameter | Field yang dicocokkan. Untuk informasi lebih lanjut, lihat [DescribeDcdnWafFilterInfo](~~423285~~).                                 |
| subKey  | string | Tidak | action                 | Subfield yang dicocokkan. Untuk informasi lebih lanjut, lihat [DescribeDcdnWafFilterInfo](~~423285~~).                              |
| opValue | String | Ya    | eq                     | Operator logika. Untuk informasi lebih lanjut, lihat [DescribeDcdnWafFilterInfo](~~423285~~).                                       |
| values  | String | Tidak | js                     | Konten yang dicocokkan. Pisahkan beberapa nilai dengan koma (,). Untuk informasi lebih lanjut, lihat [DescribeDcdnWafFilterInfo](~~423285~~). |

Tabel 2. Parameter RateLimit

| Nama      | Tipe            | Wajib | Contoh                       | Deskripsi                                                                                                                                                                                                                                                                                                                            |
| --------- | --------------- | ----- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| target    | string          | Ya    | Header                       | Field yang digunakan untuk statistik pembatasan kecepatan. Nilai valid: IP (permintaan dari alamat IP yang sama), Header (permintaan yang berisi header tertentu), Query String Parameter (permintaan yang berisi parameter tertentu), Cookie Name (permintaan yang berisi cookie tertentu), dan Session (permintaan dari sesi yang sama). |
| subKey    | string          | Tidak | User-Agent                   | Subfield dari field statistik. Parameter ini wajib jika target diatur ke Header, Query String Parameter, atau Cookie Name.                                                                                                                                                                                                            |
| Interval  | Integer         | Ya    | 5                            | Periode statistik. Nilai valid: 5 sampai 1800. Unit: detik.                                                                                                                                                                                                                                                                           |
| threshold | Integer         | Ya    | 2                            | Ambang batas statistik. Nilai valid: 2 sampai 50000. Unit: kali.                                                                                                                                                                                                                                                                      |
| ttl       | Integer         | Ya    | 1800                         | Periode batas waktu untuk daftar hitam. Nilai valid: 60 sampai 86400. Unit: detik.                                                                                                                                                                                                                                                    |
| status    | RateLimitStatus | Tidak | {"code": "404", "ratio": 10} | Statistik kode respons. Untuk informasi lebih lanjut tentang parameter, lihat **Tabel 3. Parameter RateLimitStatus**.                                                                                                                                                                                                                  |

Tabel 3. Parameter RateLimitStatus

| Nama  | Tipe    | Wajib | Contoh | Deskripsi                                                                                                                  |
| ----- | ------- | ----- | ------ | -------------------------------------------------------------------------------------------------------------------------- |
| code  | string  | Ya    | 404    | Kode status HTTP.                                                                                                          |
| ratio | Integer | Tidak | 10     | Persentase permintaan yang memicu aturan. Nilai valid: 1 sampai 100. Anda dapat menentukan parameter ini atau count.        |
| count | Integer | Tidak | 10     | Jumlah permintaan yang memicu aturan. Nilai valid: 2 sampai 50000. Anda dapat menentukan parameter ini atau ratio.          |

Contoh konfigurasi custom\_acl dalam format berikut:

[ // Kontrol akses { "name": "acl_1", "status": "off", "conditions": [ { "key": "Query String Parameter", "subKey": "action", "opValue": "eq", "values": "js" } ], "ccStatus": "off", "action": "js" }, // Pembatasan kecepatan { "name": "cc_1", "status": "on", "conditions": [ { "key": "URI", "subKey": "", "opValue": "contain", "values": "/login.php" }, { "key": "IP", "subKey": "", "opValue": "ip-contain", "values": "192.168.0.1/24" } ], "ccStatus": "on", "ratelimit": { "target": "Header", "subKey": "User-Agent", "interval": 5, "threshold": 2, "ttl": 1800, "status": { "code": "404", "ratio": 10 } }, "effect": "service", "action": "deny" } ]

### Skenario 3: Daftar putih (whitelist)

| Nama         | Tipe      | Wajib | Contoh                                                                                       | Deskripsi                                                                                                                                                                                                          |
| ------------ | --------- | ----- | -------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name         | string    | Ya    | on                                                                                           | Nama aturan. Nama dapat berisi huruf kecil, huruf besar, digit (0 sampai 9), dan garis bawah (\_). Panjang nama maksimum 64 karakter.                                                                              |
| status       | string    | Tidak | on                                                                                           | Status aturan. Nilai valid: on (default) dan off.                                                                                                                                                                  |
| conditions   | Condition | Ya    | \[{ "key": "Http-Method","subKey": "","opValue": "match-one", "values": "GET,POST,DELETE" }] | Kondisi yang memicu aturan. Untuk informasi lebih lanjut tentang parameter, lihat **Tabel 1. Parameter Condition**.                                                                                                |
| tags         | String    | Ya    | \[ "waf\_group", "custom\_acl"]                                                              | Daftar tipe kebijakan mitigasi.                                                                                                                                                                                    |
| regularTypes | String    | Tidak | \[ \[ "sqli", "xss","code\_exec", "crlf", "lfilei", "rfilei", "webshell","vvip", "other"]    | Tipe aturan ekspresi reguler. Parameter ini tersedia jika waf\_group ditentukan untuk tags. Nilai valid: "sqli", "xss", "code\_exec", "crlf", "lfilei", "rfilei", "webshell", "vvip", dan "other".                  |
| regularRules | String    | Tidak | \[ "100001", "100002", "100003"]                                                             | Aturan ekspresi reguler. Parameter ini tersedia jika waf\_group ditentukan untuk tags. Anda dapat menentukan parameter ini atau regularTypes. Nilai berupa daftar angka enam digit dalam format string.            |

Contoh konfigurasi whitelist:

[ // Lewati semua skenario { "name": "wl_all", "status": "on", "conditions": [ { "key": "Http-Method", "subKey": "", "opValue": "match-one", "values": "GET,POST,DELETE" } ], "tags": [ "waf_group", "custom_acl", "ip_blacklist", "region_block" ] }, // Lewati ID aturan tertentu untuk waf_group { "name": "wl_waf_id", "status": "off", "conditions": [ { "key": "Cookie Name", "subKey": "cdn-sec", "opValue": "prefix-match", "values": "a7sdsa9dsa8d8sa" }, { "key": "Referer", "subKey": "", "opValue": "none", "values": "" } ], "tags": [ "waf_group" ], "regularRules": [ "100001", "100002", "100003" ] }, { // Lewati tipe aturan tertentu untuk waf_group "name": "wl_waf_type", "status": "on", "conditions": [ { "key": "Query String", "subKey": "", "opValue": "exists", "values": "" } ], "tags": [ "waf_group" ], "regularTypes": [ "sqli", "xss", "code_exec", "crlf", "lfilei", "rfilei", "webshell", "vvip", "other" ] }, // Lewati aturan kustom { "name": "wl_custom_acl", "status": "on", "conditions": [ { "key": "Http-Method", "subKey": "", "opValue": "match-one", "values": "GET,POST,DELETE" } ], "tags": [ "custom_acl" ] }, // Lewati daftar hitam IP { "name": "wl_ip_blacklist", "status": "on", "conditions": [ { "key": "Http-Method", "subKey": "", "opValue": "match-one", "values": "GET,POST,DELETE" } ], "tags": [ "ip_blacklist" ] }, // Lewati daftar hitam lokasi { "name": "wl_region_block", "status": "on", "conditions": [ { "key": "Http-Method", "subKey": "", "opValue": "match-one", "values": "GET,POST,DELETE" } ], "tags": [ "region_block" ] } ]

### Skenario 4: Daftar hitam IP (ip\_blacklist)

| Nama       | Tipe      | Wajib | Contoh                                                            | Deskripsi                                                                                                                              |
| ---------- | --------- | ----- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| name       | string    | Ya    | ipblacklist                                                       | Nama aturan. Nama dapat berisi huruf kecil, huruf besar, digit (0 sampai 9), dan garis bawah (\_). Panjang nama maksimum 64 karakter.   |
| status     | string    | Tidak | on                                                                | Status aturan. Nilai valid: on dan off. Nilai default adalah on.                                                                       |
| remoteAddr | \[]String | Ya    | \["192.168.0.1","10.10.10.10/24","::1","abcd::abcd","BCDE::BCDE"] | Alamat IP yang akan difilter. Untuk informasi lebih lanjut, lihat [DescribeDcdnWafFilterInfo](~~423285~~).                              |
| action     | string    | Ya    | deny                                                              | Tindakan aturan. Nilai valid: deny dan monitor.                                                                                        |

Contoh konfigurasi ip\_blacklist dalam format berikut:

[ { "name": "ipblacklist", "status": "on", "remoteAddr": ["192.168.0.1","10.10.10.10/24","::1","abcd::abcd","BCDE::BCDE"], "action": "deny" } ]

### Skenario 5: Daftar hitam lokasi (region\_block)

| Nama            | Tipe   | Wajib | Contoh       | Deskripsi                                                                                                                                                                                  |
| --------------- | ------ | ----- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status          | string | Tidak | on           | Status aturan. Nilai valid: on dan off. Nilai default adalah on.                                                                                                                           |
| cnRegionList    | string | Tidak | 110000,TW,MO | Wilayah di Tiongkok daratan yang akan diblokir. Pisahkan beberapa wilayah dengan koma (,). Untuk informasi lebih lanjut tentang wilayah yang didukung, lihat [DescribeDcdnWafGeoInfo](~~433207~~).      |
| otherRegionList | string | Tidak | JP,GB        | Wilayah di luar Tiongkok daratan yang akan diblokir. Pisahkan beberapa wilayah dengan koma (,). Untuk informasi lebih lanjut tentang wilayah yang didukung, lihat [DescribeDcdnWafGeoInfo](~~433207~~). |
| action          | string | Ya    | deny         | Tindakan aturan. Nilai valid: deny dan monitor.                                                                                                                                            |

> Anda harus menentukan setidaknya salah satu dari cnRegionList dan otherRegionList.

Contoh konfigurasi region\_block dalam format berikut:

[ { "status": "on", "cnRegionList": "110000,TW,MO", "otherRegionList": "JP,GB", "action": "deny" } ]

### Skenario 6: Manajemen bot (bot)

**Template aturan**

Semua aturan mencakup empat parameter berikut. Untuk informasi lebih lanjut tentang nilai valid, lihat deskripsi setiap klasifikasi aturan.

| Parameter | Tipe       | Wajib | Deskripsi                                                                                |
| --------- | ---------- | ----- | --------------------------------------------------------------------------------------- |
| type      | String     | Ya    | Tipe aturan. Untuk informasi lebih lanjut, lihat klasifikasi aturan tertentu.            |
| status    | String     | Ya    | Status aturan. Nilai valid: on dan off.                                                   |
| config    | TargetType | Tidak | Konfigurasi aturan. Untuk informasi lebih lanjut, lihat klasifikasi aturan tertentu.     |
| action    | String     | Tidak | Tindakan aturan. Untuk informasi lebih lanjut, lihat klasifikasi aturan tertentu.        |

**Klasifikasi aturan 1: Tipe objek yang dilindungi**

| Parameter | Tipe       | Wajib | Contoh           | Deskripsi                                                                                                                          |
| --------- | ---------- | ----- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| type      | String     | Ya    | target\_type     | Tipe aturan. Atur nilai ke target\_type.                                                                                            |
| status    | String     | Ya    | on               | Status aturan. Atur nilai ke on.                                                                                                    |
| config    | TargetType | Tidak | {"target":"app"} | Konfigurasi aturan. Format: target: Tipe objek yang dilindungi. Parameter ini wajib. Nilai valid: web dan app.                       |
| action    | String     | Tidak | empty            | Tindakan aturan. Parameter ini tidak berlaku. Kosongkan.                                                                            |

Contoh konfigurasi tipe objek yang dilindungi:

[ { "type":"target_type", "status":"on", "config":{"target":"app"}, "action":"" } ]

**Klasifikasi aturan 2: Integrasi Web SDK**

| Parameter | Tipe   | Wajib | Contoh                                           | Deskripsi                                                                                                                                                                                                                                                                                                      |
| --------- | ------ | ----- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| type      | String | Ya    | web\_sdk                                         | Tipe aturan. Atur nilai ke web\_sdk.                                                                                                                                                                                                                                                                            |
| status    | String | Ya    | on                                               | Status aturan. Atur nilai ke on.                                                                                                                                                                                                                                                                                |
| config    | WebSdk | Tidak | {"mode":"automatic","crossDomain":"example.com"} | Konfigurasi aturan. Format: mode: Mode integrasi software development kit (SDK) web. Parameter ini wajib. Nilai valid: automatic dan manual. crossDomain: Nama domain lintas domain untuk panggilan. Parameter ini opsional dan hanya berlaku jika mode diatur ke automatic.                                     |
| action    | String | Tidak | empty                                            | Tindakan aturan. Parameter ini tidak berlaku. Kosongkan.                                                                                                                                                                                                                                                        |

Contoh konfigurasi integrasi Web SDK:

[ { "type":"web_sdk", "status":"on", "config":{"mode":"automatic","crossDomain":"example.com"}, "action":"" } ]

**Klasifikasi aturan 3: Fitur objek yang dilindungi**

| Parameter | Tipe           | Wajib | Contoh                                                                                                                                                                  | Deskripsi                                                                  |
| --------- | -------------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
| type      | String         | Ya    | traffic\_feature                                                                                                                                                         | Tipe aturan. Atur nilai ke traffic\_feature.                                |
| status    | String         | Ya    | on                                                                                                                                                                       | Status aturan. Atur nilai ke on.                                            |
| config    | TrafficFeature | Ya    | {"conditions":\[{"key":"Header","subKey":"User-Agent","opValue":"contain","values":"Chrome"},{"key":"IP","subKey":"","opValue":"ip-contain","values":"192.168.0.1/24"}]} | Konfigurasi aturan. Untuk informasi lebih lanjut, lihat **condition**.      |
| action    | String         | Tidak | empty                                                                                                                                                                    | Tindakan aturan. Parameter ini tidak berlaku. Kosongkan.                    |

**condition** (kondisi pencocokan)

| Parameter | Tipe   | Wajib | Contoh     | Deskripsi                                                                                                                          |
| --------- | ------ | ----- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| key       | String | Ya    | Header     | Field yang dicocokkan. Untuk informasi lebih lanjut, lihat [Describ
[DescribeDcdnWafFilterInfo](~~423285~~).

Elemen respons

Element

Type

Description

Example

object

RequestId

string

The request ID.

CB1A380B-09F0-41BB-280B-72F8FD6DA2FE

RuleIds

object

RuleId

array

string

The IDs of the created rules.

100001,200002

Contoh

Respons sukses

JSONformat

{
  "RequestId": "CB1A380B-09F0-41BB-280B-72F8FD6DA2FE",
  "RuleIds": {
    "RuleId": [
      "100001,200002"
    ]
  }
}

Kode kesalahan

HTTP status code

Error code

Error message

Description

400 InvalidParameter The specified parameter is invalid. A parameter is set to an invalid value.
400 Policy.NotExist The specified policy does not exist. The specified protection policy does not exist.
400 RuleConfigs.Malformed The specified RuleConfigs format is invalid. The RuleConfigs parameter is in an invalid format.
400 RuleName.AlreadyExists Rule name already exists in specified policy. The specified rule name is already used by another rule.
400 Rule.QuantityOverflow Rules are overflowed quantity in specified policy. The number of rules in the specified policy has already reached the upper limit.
500 InternalError An internal error occurred; please try again later. An internal error occurred. Try again later. If the error persists, submit a ticket.
403 %s.NotSupport The specified resource type %s is not supported. The specified resource type is not supported. To use this type of resource, contact us.
403 %s.OverQuota The quantity of %s exceeds the quota. The number of resources exceeds the quota. If you want to apply for more resources, contact us.

Lihat Error Codes untuk daftar lengkap.

Catatan rilis

Lihat Release Notes untuk daftar lengkap.