|
69 | 69 | "minItems": 1, |
70 | 70 | "type": "array", |
71 | 71 | "uniqueItems": true |
| 72 | + }, |
| 73 | + "waf": { |
| 74 | + "$ref": "#/components/schemas/WafConfig" |
72 | 75 | } |
73 | 76 | }, |
74 | 77 | "required": [ |
75 | 78 | "regions", |
76 | 79 | "backend", |
77 | 80 | "blockedIPs", |
78 | | - "blockedCountries" |
| 81 | + "blockedCountries", |
| 82 | + "waf" |
79 | 83 | ], |
80 | 84 | "type": "object" |
81 | 85 | }, |
|
148 | 152 | "minItems": 1, |
149 | 153 | "type": "array", |
150 | 154 | "uniqueItems": true |
| 155 | + }, |
| 156 | + "waf": { |
| 157 | + "$ref": "#/components/schemas/WafConfigPatch" |
151 | 158 | } |
152 | 159 | }, |
153 | 160 | "type": "object" |
|
234 | 241 | "minItems": 1, |
235 | 242 | "type": "array", |
236 | 243 | "uniqueItems": true |
| 244 | + }, |
| 245 | + "waf": { |
| 246 | + "$ref": "#/components/schemas/WafConfig" |
237 | 247 | } |
238 | 248 | }, |
239 | 249 | "required": [ |
|
342 | 352 | "description": "RFC3339 string which returns the last time the distribution configuration was modified.\n", |
343 | 353 | "format": "date-time", |
344 | 354 | "type": "string" |
| 355 | + }, |
| 356 | + "waf": { |
| 357 | + "description": "For this property to be present two pre-conditions must be met: \n- the WAF was enabled at least once\n- the query parameter ?withWafStatus is truthy\n\nThis property contains the waf Status. At this point in time, this contains all resolved rules.\nRules are split into 3 groups: \n- enabledRules\n- logOnlyRules \n- disabledRules\n\n**Do note that the global waf mode (Disabled, LogOnly, Enabled) is *NOT* reflected in this list!**\n", |
| 358 | + "properties": { |
| 359 | + "disabledRules": { |
| 360 | + "items": { |
| 361 | + "$ref": "#/components/schemas/WAFStatusRuleBlock" |
| 362 | + }, |
| 363 | + "type": "array" |
| 364 | + }, |
| 365 | + "enabledRules": { |
| 366 | + "items": { |
| 367 | + "$ref": "#/components/schemas/WAFStatusRuleBlock" |
| 368 | + }, |
| 369 | + "type": "array" |
| 370 | + }, |
| 371 | + "logOnlyRules": { |
| 372 | + "items": { |
| 373 | + "$ref": "#/components/schemas/WAFStatusRuleBlock" |
| 374 | + }, |
| 375 | + "type": "array" |
| 376 | + } |
| 377 | + }, |
| 378 | + "required": [ |
| 379 | + "enabledRules", |
| 380 | + "logOnlyRules", |
| 381 | + "disabledRules" |
| 382 | + ], |
| 383 | + "type": "object" |
345 | 384 | } |
346 | 385 | }, |
347 | 386 | "required": [ |
|
890 | 929 | ], |
891 | 930 | "type": "object" |
892 | 931 | }, |
| 932 | + "ListWAFCollectionsResponse": { |
| 933 | + "properties": { |
| 934 | + "collections": { |
| 935 | + "items": { |
| 936 | + "$ref": "#/components/schemas/WAFRuleCollection" |
| 937 | + }, |
| 938 | + "type": "array" |
| 939 | + } |
| 940 | + }, |
| 941 | + "required": [ |
| 942 | + "collections" |
| 943 | + ], |
| 944 | + "type": "object" |
| 945 | + }, |
| 946 | + "LocalizedString": { |
| 947 | + "additionalProperties": { |
| 948 | + "type": "string" |
| 949 | + }, |
| 950 | + "description": "LocalizedString is a map from language to string value", |
| 951 | + "type": "object" |
| 952 | + }, |
893 | 953 | "LokiLogSink": { |
894 | 954 | "properties": { |
895 | 955 | "pushUrl": { |
|
1127 | 1187 | "key" |
1128 | 1188 | ], |
1129 | 1189 | "type": "object" |
| 1190 | + }, |
| 1191 | + "WAFRule": { |
| 1192 | + "properties": { |
| 1193 | + "code": { |
| 1194 | + "description": "Optional CoreRuleSet rule ID in case this is a CRS rule", |
| 1195 | + "type": "string" |
| 1196 | + }, |
| 1197 | + "description": { |
| 1198 | + "$ref": "#/components/schemas/LocalizedString" |
| 1199 | + }, |
| 1200 | + "id": { |
| 1201 | + "type": "string" |
| 1202 | + } |
| 1203 | + }, |
| 1204 | + "required": [ |
| 1205 | + "id", |
| 1206 | + "description" |
| 1207 | + ], |
| 1208 | + "type": "object" |
| 1209 | + }, |
| 1210 | + "WAFRuleCollection": { |
| 1211 | + "properties": { |
| 1212 | + "groups": { |
| 1213 | + "items": { |
| 1214 | + "$ref": "#/components/schemas/WAFRuleGroup" |
| 1215 | + }, |
| 1216 | + "type": "array" |
| 1217 | + }, |
| 1218 | + "id": { |
| 1219 | + "type": "string" |
| 1220 | + }, |
| 1221 | + "name": { |
| 1222 | + "$ref": "#/components/schemas/LocalizedString" |
| 1223 | + } |
| 1224 | + }, |
| 1225 | + "required": [ |
| 1226 | + "name", |
| 1227 | + "id", |
| 1228 | + "groups" |
| 1229 | + ], |
| 1230 | + "type": "object" |
| 1231 | + }, |
| 1232 | + "WAFRuleGroup": { |
| 1233 | + "properties": { |
| 1234 | + "description": { |
| 1235 | + "$ref": "#/components/schemas/LocalizedString" |
| 1236 | + }, |
| 1237 | + "name": { |
| 1238 | + "$ref": "#/components/schemas/LocalizedString" |
| 1239 | + }, |
| 1240 | + "rules": { |
| 1241 | + "items": { |
| 1242 | + "$ref": "#/components/schemas/WAFRule" |
| 1243 | + }, |
| 1244 | + "type": "array" |
| 1245 | + } |
| 1246 | + }, |
| 1247 | + "required": [ |
| 1248 | + "name", |
| 1249 | + "description", |
| 1250 | + "rules" |
| 1251 | + ], |
| 1252 | + "type": "object" |
| 1253 | + }, |
| 1254 | + "WAFStatusRuleBlock": { |
| 1255 | + "properties": { |
| 1256 | + "id": { |
| 1257 | + "description": "Specifies the ID of the Rule.", |
| 1258 | + "type": "string" |
| 1259 | + } |
| 1260 | + }, |
| 1261 | + "required": [ |
| 1262 | + "id" |
| 1263 | + ], |
| 1264 | + "type": "object" |
| 1265 | + }, |
| 1266 | + "WafConfig": { |
| 1267 | + "description": "Configuration of the WAF of a distribution", |
| 1268 | + "properties": { |
| 1269 | + "enabledRuleIds": { |
| 1270 | + "description": "IDs of the WAF rules that are **explicitly** enabled for this distribution. \nIf this rule is in a disabled / log Only RuleGroup or Collection,\nit will be enabled regardless as `enabledRuleIds` overrides those in specificity.\n\nDo note that rules can also be enabled because a Rulegroup or Collection is enabled. \n**DO NOT** use this property to find all active rules. Instead, pass `?withWafStatus=true` as a query parameter\nto `GetDistribution` or `ListDistributions`. This will expose the `waf` Property on distribution Level.\n\nFrom there you can `$.waf.enabledRules.map(e =\u003e e.id)` to get a list of all enabled rules.\n", |
| 1271 | + "items": { |
| 1272 | + "type": "string" |
| 1273 | + }, |
| 1274 | + "type": "array" |
| 1275 | + }, |
| 1276 | + "mode": { |
| 1277 | + "$ref": "#/components/schemas/WafMode" |
| 1278 | + }, |
| 1279 | + "type": { |
| 1280 | + "$ref": "#/components/schemas/WafType" |
| 1281 | + } |
| 1282 | + }, |
| 1283 | + "required": [ |
| 1284 | + "mode", |
| 1285 | + "type", |
| 1286 | + "enabledRuleIds" |
| 1287 | + ], |
| 1288 | + "type": "object" |
| 1289 | + }, |
| 1290 | + "WafConfigPatch": { |
| 1291 | + "properties": { |
| 1292 | + "mode": { |
| 1293 | + "$ref": "#/components/schemas/WafMode" |
| 1294 | + }, |
| 1295 | + "type": { |
| 1296 | + "$ref": "#/components/schemas/WafType" |
| 1297 | + } |
| 1298 | + }, |
| 1299 | + "type": "object" |
| 1300 | + }, |
| 1301 | + "WafMode": { |
| 1302 | + "enum": [ |
| 1303 | + "DISABLED", |
| 1304 | + "ENABLED", |
| 1305 | + "LOG_ONLY" |
| 1306 | + ], |
| 1307 | + "format": "enum", |
| 1308 | + "type": "string" |
| 1309 | + }, |
| 1310 | + "WafType": { |
| 1311 | + "description": "Enable or disable the Premium WAF. Do note that enabling the Premium WAF will cause additional fees. \n\nSome features are gated behind the Premium WAF, like additional, **premium-only rules** and the ability to create **custom rules** (not yet implemented)\n", |
| 1312 | + "enum": [ |
| 1313 | + "FREE", |
| 1314 | + "PREMIUM" |
| 1315 | + ], |
| 1316 | + "format": "enum", |
| 1317 | + "type": "string" |
1130 | 1318 | } |
1131 | 1319 | } |
1132 | 1320 | }, |
|
1163 | 1351 | "type": "integer" |
1164 | 1352 | } |
1165 | 1353 | }, |
| 1354 | + { |
| 1355 | + "description": "If set, the top level of a distribution contains a `waf` property, which defines the status of the waf. This includes a list of all resolved rules.", |
| 1356 | + "in": "query", |
| 1357 | + "name": "withWafStatus", |
| 1358 | + "schema": { |
| 1359 | + "default": false, |
| 1360 | + "type": "boolean" |
| 1361 | + } |
| 1362 | + }, |
1166 | 1363 | { |
1167 | 1364 | "description": "Identifier is returned by the previous response and is used to request the next page.\n\nAs the `pageIdentifier` encodes an element, inserts during pagination will *not* shift the result.\nSo a scenario like: \n- Start listing first page\n- Insert new element\n- Start listing second page\nwill *never* result in an element from the first page to get \"pushed\" to the second page, like it could \noccur with basic limit + offset pagination.\n\nThe identifier should be treated as an opaque string and never modified. Only pass values returned by the API.\n", |
1168 | 1365 | "in": "query", |
|
1656 | 1853 | "format": "uuid", |
1657 | 1854 | "type": "string" |
1658 | 1855 | } |
| 1856 | + }, |
| 1857 | + { |
| 1858 | + "description": "If set, the top level of a distribution contains a `waf` property, which defines the status of the waf. This includes a list of all resolved rules.", |
| 1859 | + "in": "query", |
| 1860 | + "name": "withWafStatus", |
| 1861 | + "schema": { |
| 1862 | + "default": false, |
| 1863 | + "type": "boolean" |
| 1864 | + } |
1659 | 1865 | } |
1660 | 1866 | ], |
1661 | 1867 | "responses": { |
|
3221 | 3427 | "resource-type": "project" |
3222 | 3428 | } |
3223 | 3429 | } |
| 3430 | + }, |
| 3431 | + "/v1beta/projects/{projectId}/waf/collections": { |
| 3432 | + "get": { |
| 3433 | + "description": "Returns all WAF rule collections available to the project", |
| 3434 | + "operationId": "ListWAFCollections", |
| 3435 | + "parameters": [ |
| 3436 | + { |
| 3437 | + "description": "Your STACKIT Project ID", |
| 3438 | + "in": "path", |
| 3439 | + "name": "projectId", |
| 3440 | + "required": true, |
| 3441 | + "schema": { |
| 3442 | + "type": "string" |
| 3443 | + } |
| 3444 | + } |
| 3445 | + ], |
| 3446 | + "responses": { |
| 3447 | + "200": { |
| 3448 | + "content": { |
| 3449 | + "application/json": { |
| 3450 | + "examples": { |
| 3451 | + "default": { |
| 3452 | + "value": { |
| 3453 | + "collections": [ |
| 3454 | + { |
| 3455 | + "groups": [ |
| 3456 | + { |
| 3457 | + "description": {}, |
| 3458 | + "name": { |
| 3459 | + "en": "Method Enforcement" |
| 3460 | + }, |
| 3461 | + "rules": [ |
| 3462 | + { |
| 3463 | + "code": "911100", |
| 3464 | + "description": { |
| 3465 | + "en": "Method is not allowed by policy" |
| 3466 | + }, |
| 3467 | + "id": "@builtin/crs/request/911100" |
| 3468 | + } |
| 3469 | + ] |
| 3470 | + } |
| 3471 | + ], |
| 3472 | + "id": "@builtin/crs/request", |
| 3473 | + "name": { |
| 3474 | + "en": "CRS Request" |
| 3475 | + } |
| 3476 | + } |
| 3477 | + ] |
| 3478 | + } |
| 3479 | + } |
| 3480 | + }, |
| 3481 | + "schema": { |
| 3482 | + "$ref": "#/components/schemas/ListWAFCollectionsResponse" |
| 3483 | + } |
| 3484 | + } |
| 3485 | + }, |
| 3486 | + "description": "OK" |
| 3487 | + }, |
| 3488 | + "401": { |
| 3489 | + "content": { |
| 3490 | + "text/plain": { |
| 3491 | + "schema": { |
| 3492 | + "type": "string" |
| 3493 | + } |
| 3494 | + } |
| 3495 | + }, |
| 3496 | + "description": "unauthorized - please make sure the \"Authorization\" header is set and uses correct credentials" |
| 3497 | + }, |
| 3498 | + "422": { |
| 3499 | + "content": { |
| 3500 | + "application/json": { |
| 3501 | + "schema": { |
| 3502 | + "$ref": "#/components/schemas/GenericJSONResponse" |
| 3503 | + } |
| 3504 | + } |
| 3505 | + }, |
| 3506 | + "description": "unprocessable entity - please make sure the body you provided is constructed according to spec" |
| 3507 | + }, |
| 3508 | + "500": { |
| 3509 | + "content": { |
| 3510 | + "application/json": { |
| 3511 | + "schema": { |
| 3512 | + "$ref": "#/components/schemas/GenericJSONResponse" |
| 3513 | + } |
| 3514 | + } |
| 3515 | + }, |
| 3516 | + "description": "internal error - please try again later or contact support if the issue persists" |
| 3517 | + }, |
| 3518 | + "default": { |
| 3519 | + "content": { |
| 3520 | + "application/json": { |
| 3521 | + "schema": { |
| 3522 | + "$ref": "#/components/schemas/GenericJSONResponse" |
| 3523 | + } |
| 3524 | + } |
| 3525 | + }, |
| 3526 | + "description": "Default error response" |
| 3527 | + } |
| 3528 | + }, |
| 3529 | + "summary": "List all WAF rule collections of the project", |
| 3530 | + "x-stackit-authorization": { |
| 3531 | + "actions": [ |
| 3532 | + "cdn.distribution.get" |
| 3533 | + ], |
| 3534 | + "resource-id": "projectId", |
| 3535 | + "resource-id-type": "dynamic", |
| 3536 | + "resource-type": "project" |
| 3537 | + } |
| 3538 | + } |
3224 | 3539 | } |
3225 | 3540 | }, |
3226 | 3541 | "security": [ |
|
0 commit comments