1616HYPERNODE_API_APP_XGRADE_CHECK_ENDPOINT = "/v2/app/xgrade/{}/check/{}/"
1717HYPERNODE_API_APP_XGRADE_ENDPOINT = "/v2/app/xgrade/{}/"
1818HYPERNODE_API_BACKUPS_ENDPOINT = "/v2/app/{}/backup/"
19+ HYPERNODE_API_BLOCK_ATTACK_ENDPOINT = "/v2/app/{}/block_attack/"
1920HYPERNODE_API_BLOCK_ATTACK_DESCRIPTION_ENDPOINT = "/v2/app/block_attack_descriptions/"
2021HYPERNODE_API_BRANCHER_APP_ENDPOINT = "/v2/brancher/app/{}/"
2122HYPERNODE_API_BRANCHER_ENDPOINT = "/v2/brancher/{}/"
@@ -411,7 +412,7 @@ def get_block_attack_descriptions(self):
411412 by automatically placing an NGINX snippet in /data/web/nginx if the
412413 specified block is compatible with the current NGINX configuration.
413414 Example:
414- > client.requests("GET", "/v2/app/block_attack_descriptions/" ).json()
415+ > client.get_block_attack_descriptions( ).json()
415416 > {
416417 > 'BlockSqliBruteForce': 'Attempts to deploy NGINX rules to block suspected (blind) SQL injection attack',
417418 > ...
@@ -421,6 +422,27 @@ def get_block_attack_descriptions(self):
421422 """
422423 return self .requests ("GET" , HYPERNODE_API_BLOCK_ATTACK_DESCRIPTION_ENDPOINT )
423424
425+ def block_attack (self , app_name , attack_name ):
426+ """
427+ Attempts to deploy one of the block attack rules. The list of rules can be retrieved with the
428+ get_block_attack_descriptions method. This will place an NGINX snippet to block the specified attack
429+ in /data/web/nginx. If the nginx-config-validator detects that the new config is valid, it will leave
430+ the newly placed config. Otherwise it will be removed again.
431+
432+ Example:
433+ > client.block_attack('yourhypernodeappname', 'BlockSqliBruteForce').ok
434+ > True
435+
436+ :param str app_name: The name of the Hypernode you want to deploy the block attack nginx configuration on
437+ :param str attack_name: The specific attack you want to block. See get_block_attack_descriptions for options.
438+ :return obj response: The request response object
439+ """
440+ return self .requests (
441+ "POST" ,
442+ HYPERNODE_API_BLOCK_ATTACK_ENDPOINT .format (app_name ),
443+ data = {"attack_name" : attack_name },
444+ )
445+
424446 def get_whitelist_options (self , app_name ):
425447 """
426448 Get whitelist options for app. Retrieve the options for specifying
0 commit comments