批量开启网页防篡改防护
功能介绍
批量开启网页防篡改防护
调用方法
请参见如何调用API。
URI
POST /v5/{project_id}/webtamper/protection/batch-open
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数解释: 项目ID,用于明确项目归属,配置后可通过该ID查询项目下资产。获取方式请参见获取项目ID。 约束限制: 不涉及 取值范围: 字符长度1-256位 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
enterprise_project_id |
否 |
String |
参数解释: 企业项目ID,用于过滤不同企业项目下的资产。获取方式请参见获取企业项目ID。 如需查询所有企业项目下的资产请传参“all_granted_eps”。 约束限制: 开通企业项目功能后才需要配置企业项目ID参数。 取值范围: 字符长度1-256位 默认取值: 0,表示默认企业项目(default)。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
参数解释: 用户Token,包含了用户的身份、权限等信息,在调用API接口时,可通过Token进行身份认证。获取方式请参见获取用户Token。 约束限制: 不涉及 取值范围: 字符长度1-32768位 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
host_id_list |
是 |
Array of strings |
参数解释: 需要开启防护的服务器ID列表,仅支持填写未开启网页防篡改防护的服务器ID,已开启网页防篡改防护的服务器可使用UpdateWebTamperHostPolicy接口进行修改策略。 约束限制 : 仅支持填写未开启网页防篡改防护的服务器ID,且Linux服务器和Windows服务器不可同时填写,需分批开启。 取值范围: 最少1条,最多20000条 默认取值 : 不涉及 |
charging_mode |
否 |
String |
参数解释: 计费模式 约束限制: 不涉及 取值范围:
默认取值: on_demand |
resource_id |
否 |
String |
参数解释: 资源ID,即网页防篡改配额的配额ID,当charging_mode选择packet_cycle时可填写该字段,表示使用一个指定配额,也可不填写该字段,表示随机选择符合的配额。 约束限制 : 不涉及 取值范围: 字符长度0-64位 默认取值 : 不涉及 |
tags |
否 |
Array of TagInfo objects |
参数解释: 资源标签列表,仅计费模式选择按需计费时支持填写。 约束限制: 仅计费模式选择按需计费时支持填写。 取值范围: 最少0条,最多2097152条 默认取值: 不涉及 |
protect_dir_info |
是 |
防护目录信息 |
|
enable_timing_off |
否 |
Boolean |
参数解释: 定时开关设置状态 约束限制: 不涉及 取值范围:
默认取值: False |
timing_off_config_info |
否 |
定时开关配置详情 |
|
enable_rasp_protect |
否 |
Boolean |
参数解释: 动态网页防篡改开启状态,仅Linux服务器支持。 约束限制: 仅Linux服务器支持开启动态网页防篡改,Windows服务器不可填写该字段。 取值范围:
默认取值: False |
rasp_path |
否 |
String |
参数解释: 动态网页防篡改的Tomcat bin目录,仅Linux服务器支持。 约束限制: 仅Linux服务器支持配置动态网页防篡改的Tomcat bin目录,Windows服务器不可填写该字段。 取值范围: 字符长度1-256位,必须以/开头,不能以/结尾,只能包含英文大小写字母,数字,下划线,中划线和点。 默认取值: 不涉及 |
enable_privileged_process |
否 |
Boolean |
参数解释: 特权进程开启状态 约束限制: 不涉及 取值范围:
默认取值: False |
privileged_process_info |
否 |
特权进程配置详情 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
key |
否 |
String |
参数解释: 键 取值范围: 最大长度128个unicode字符。 key不能为空 |
value |
否 |
String |
参数解释: 值 取值范围: 最大长度255个unicode字符。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
protect_dir_list |
是 |
Array of WebTamperProtectHostDirRequestInfo objects |
参数解释: 防护目录列表 约束限制: 不涉及 取值范围: 最少1条,最多50条 默认取值: 不涉及 |
exclude_file_type |
否 |
String |
参数解释: 排除文件类型 约束限制: 不涉及 取值范围: 文件类型只能输入字母、数字,最多支持10个文件类型,每个文件类型长度不超过10个字符,多个文件类型以分号隔开。 默认取值: 不涉及 |
protect_mode |
否 |
String |
参数解释: 防护模式,仅Linux服务器支持设置防护模式为告警模式,Windows服务器仅支持拦截模式。 约束限制: 不涉及 取值范围:
默认取值: recovery |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
protect_dir |
是 |
String |
参数解释: 防护目录 约束限制: 不涉及 取值范围: 字符长度1-256位。Linux服务器,必须以/开头,不能以/结尾,只能包含英文大小写字母,数字,下划线,中划线和点。Windows服务器,目录名不能包含;/*?"<>|,不能以空格开头,不能以\结尾。 默认取值: 不涉及 |
exclude_child_dir |
否 |
String |
参数解释: 排除子目录 约束限制: 不涉及 取值范围: 子目录名必须是防护目录的有效相对路径,目录名最大长度不能超过256个字符,最多可添加10个子目录,多个子目录用;隔开。Linux服务器的子目录名不能以/开头或结尾,Windows服务器的子目录名不能以\开头或结尾。 默认取值: 不涉及 |
exclude_file_path |
否 |
String |
参数解释: 排除文件路径 约束限制: 仅Linux服务器支持填写排除文件路径,Windows服务器不可填写该字段。 取值范围: 排除文件路径必须是防护目录的有效相对路径,不能以/开头或结尾,文件路径最大长度不能超过256个字符;最多可添加50个文件路径,多个文件路径用;隔开。 默认取值: 不涉及 |
local_backup_dir |
否 |
String |
参数解释: 本地备份路径,Linux服务器必须填写该字段。 约束限制: 仅Linux服务器需要填写本地备份路径,Windows服务器不可填写该字段。 取值范围: 本地备份路径不能包含;字符,不能以空格开头,不能以/结尾,本地备份路径长度不得超过256个字符。 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
week_off_list |
否 |
Array of integers |
参数解释: 自动关闭防护周期列表 约束限制: 不涉及 取值范围: 最少1条,最多7条 默认取值: 不涉及 |
timing_range_list |
否 |
Array of TimingRangeConfigRequestInfo objects |
参数解释: 自动关闭防护时间段 约束限制: 不涉及 取值范围: 最少1条,最多5条 默认取值: 不涉及 |
响应参数
状态码:200
请求已成功
无
请求示例
批量开启网页防篡改防护。
PUT https://{endpoint}/v5/{project_id}/webtamper/protection/batch-open { "host_id_list" : [ "f8b8c960-0057-4c32-9ece-567a3641ff25" ], "resource_id" : "", "charging_mode" : "packet_cycle", "protect_dir_info" : { "protect_dir_list" : [ { "local_backup_dir" : "/root/test2", "protect_dir" : "/root/test1" }, { "exclude_child_dir" : "pro", "exclude_file_path" : "path", "local_backup_dir" : "/root/test4", "protect_dir" : "/root/test3" } ], "exclude_file_type" : "log;pid;text", "protect_mode" : "recovery" }, "enable_timing_off" : true, "enable_privileged_process" : true, "enable_rasp_protect" : true, "timing_off_config_info" : { "week_off_list" : [ 5, 7 ], "timing_range_list" : [ { "time_range" : "02:00-04:00", "description" : "close" }, { "time_range" : "12:05-14:00" } ] }, "privileged_process_info" : { "privileged_process_path_list" : [ "/usr/bin/echo" ], "privileged_child_status" : true }, "rasp_path" : "/usr/bin/tomcat/bin" }
响应示例
无
SDK代码示例
SDK代码示例如下。
批量开启网页防篡改防护。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.hss.v5.region.HssRegion; import com.huaweicloud.sdk.hss.v5.*; import com.huaweicloud.sdk.hss.v5.model.*; import java.util.List; import java.util.ArrayList; public class BatchStartWebTamperProtectionSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); HssClient client = HssClient.newBuilder() .withCredential(auth) .withRegion(HssRegion.valueOf("<YOUR REGION>")) .build(); BatchStartWebTamperProtectionRequest request = new BatchStartWebTamperProtectionRequest(); BatchStartWebTamperProtectionRequestInfo body = new BatchStartWebTamperProtectionRequestInfo(); List<String> listPrivilegedProcessInfoPrivilegedProcessPathList = new ArrayList<>(); listPrivilegedProcessInfoPrivilegedProcessPathList.add("/usr/bin/echo"); WebTamperPrivilegedProcessRequestInfo privilegedProcessInfobody = new WebTamperPrivilegedProcessRequestInfo(); privilegedProcessInfobody.withPrivilegedProcessPathList(listPrivilegedProcessInfoPrivilegedProcessPathList) .withPrivilegedChildStatus(true); List<TimingRangeConfigRequestInfo> listTimingOffConfigInfoTimingRangeList = new ArrayList<>(); listTimingOffConfigInfoTimingRangeList.add( new TimingRangeConfigRequestInfo() .withTimeRange("02:00-04:00") .withDescription("close") ); listTimingOffConfigInfoTimingRangeList.add( new TimingRangeConfigRequestInfo() .withTimeRange("12:05-14:00") ); List<Integer> listTimingOffConfigInfoWeekOffList = new ArrayList<>(); listTimingOffConfigInfoWeekOffList.add(5); listTimingOffConfigInfoWeekOffList.add(7); WebTamperTimingOffConfigInfoRequestInfo timingOffConfigInfobody = new WebTamperTimingOffConfigInfoRequestInfo(); timingOffConfigInfobody.withWeekOffList(listTimingOffConfigInfoWeekOffList) .withTimingRangeList(listTimingOffConfigInfoTimingRangeList); List<WebTamperProtectHostDirRequestInfo> listProtectDirInfoProtectDirList = new ArrayList<>(); listProtectDirInfoProtectDirList.add( new WebTamperProtectHostDirRequestInfo() .withProtectDir("/root/test1") .withLocalBackupDir("/root/test2") ); listProtectDirInfoProtectDirList.add( new WebTamperProtectHostDirRequestInfo() .withProtectDir("/root/test3") .withExcludeChildDir("pro") .withExcludeFilePath("path") .withLocalBackupDir("/root/test4") ); WebTamperProtectDirRequestInfo protectDirInfobody = new WebTamperProtectDirRequestInfo(); protectDirInfobody.withProtectDirList(listProtectDirInfoProtectDirList) .withExcludeFileType("log;pid;text") .withProtectMode("recovery"); List<String> listbodyHostIdList = new ArrayList<>(); listbodyHostIdList.add("f8b8c960-0057-4c32-9ece-567a3641ff25"); body.withPrivilegedProcessInfo(privilegedProcessInfobody); body.withEnablePrivilegedProcess(true); body.withRaspPath("/usr/bin/tomcat/bin"); body.withEnableRaspProtect(true); body.withTimingOffConfigInfo(timingOffConfigInfobody); body.withEnableTimingOff(true); body.withProtectDirInfo(protectDirInfobody); body.withResourceId(""); body.withChargingMode("packet_cycle"); body.withHostIdList(listbodyHostIdList); request.withBody(body); try { BatchStartWebTamperProtectionResponse response = client.batchStartWebTamperProtection(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
批量开启网页防篡改防护。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkhss.v5.region.hss_region import HssRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkhss.v5 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = HssClient.new_builder() \ .with_credentials(credentials) \ .with_region(HssRegion.value_of("<YOUR REGION>")) \ .build() try: request = BatchStartWebTamperProtectionRequest() listPrivilegedProcessPathListPrivilegedProcessInfo = [ "/usr/bin/echo" ] privilegedProcessInfobody = WebTamperPrivilegedProcessRequestInfo( privileged_process_path_list=listPrivilegedProcessPathListPrivilegedProcessInfo, privileged_child_status=True ) listTimingRangeListTimingOffConfigInfo = [ TimingRangeConfigRequestInfo( time_range="02:00-04:00", description="close" ), TimingRangeConfigRequestInfo( time_range="12:05-14:00" ) ] listWeekOffListTimingOffConfigInfo = [ 5, 7 ] timingOffConfigInfobody = WebTamperTimingOffConfigInfoRequestInfo( week_off_list=listWeekOffListTimingOffConfigInfo, timing_range_list=listTimingRangeListTimingOffConfigInfo ) listProtectDirListProtectDirInfo = [ WebTamperProtectHostDirRequestInfo( protect_dir="/root/test1", local_backup_dir="/root/test2" ), WebTamperProtectHostDirRequestInfo( protect_dir="/root/test3", exclude_child_dir="pro", exclude_file_path="path", local_backup_dir="/root/test4" ) ] protectDirInfobody = WebTamperProtectDirRequestInfo( protect_dir_list=listProtectDirListProtectDirInfo, exclude_file_type="log;pid;text", protect_mode="recovery" ) listHostIdListbody = [ "f8b8c960-0057-4c32-9ece-567a3641ff25" ] request.body = BatchStartWebTamperProtectionRequestInfo( privileged_process_info=privilegedProcessInfobody, enable_privileged_process=True, rasp_path="/usr/bin/tomcat/bin", enable_rasp_protect=True, timing_off_config_info=timingOffConfigInfobody, enable_timing_off=True, protect_dir_info=protectDirInfobody, resource_id="", charging_mode="packet_cycle", host_id_list=listHostIdListbody ) response = client.batch_start_web_tamper_protection(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
批量开启网页防篡改防护。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" hss "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := hss.NewHssClient( hss.HssClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.BatchStartWebTamperProtectionRequest{} var listPrivilegedProcessPathListPrivilegedProcessInfo = []string{ "/usr/bin/echo", } privilegedChildStatusPrivilegedProcessInfo:= true privilegedProcessInfobody := &model.WebTamperPrivilegedProcessRequestInfo{ PrivilegedProcessPathList: &listPrivilegedProcessPathListPrivilegedProcessInfo, PrivilegedChildStatus: &privilegedChildStatusPrivilegedProcessInfo, } timeRangeTimingRangeList:= "02:00-04:00" descriptionTimingRangeList:= "close" timeRangeTimingRangeList1:= "12:05-14:00" var listTimingRangeListTimingOffConfigInfo = []model.TimingRangeConfigRequestInfo{ { TimeRange: &timeRangeTimingRangeList, Description: &descriptionTimingRangeList, }, { TimeRange: &timeRangeTimingRangeList1, }, } var listWeekOffListTimingOffConfigInfo = []int32{ int32(5), int32(7), } timingOffConfigInfobody := &model.WebTamperTimingOffConfigInfoRequestInfo{ WeekOffList: &listWeekOffListTimingOffConfigInfo, TimingRangeList: &listTimingRangeListTimingOffConfigInfo, } localBackupDirProtectDirList:= "/root/test2" excludeChildDirProtectDirList:= "pro" excludeFilePathProtectDirList:= "path" localBackupDirProtectDirList1:= "/root/test4" var listProtectDirListProtectDirInfo = []model.WebTamperProtectHostDirRequestInfo{ { ProtectDir: "/root/test1", LocalBackupDir: &localBackupDirProtectDirList, }, { ProtectDir: "/root/test3", ExcludeChildDir: &excludeChildDirProtectDirList, ExcludeFilePath: &excludeFilePathProtectDirList, LocalBackupDir: &localBackupDirProtectDirList1, }, } excludeFileTypeProtectDirInfo:= "log;pid;text" protectModeProtectDirInfo:= "recovery" protectDirInfobody := &model.WebTamperProtectDirRequestInfo{ ProtectDirList: listProtectDirListProtectDirInfo, ExcludeFileType: &excludeFileTypeProtectDirInfo, ProtectMode: &protectModeProtectDirInfo, } var listHostIdListbody = []string{ "f8b8c960-0057-4c32-9ece-567a3641ff25", } enablePrivilegedProcessBatchStartWebTamperProtectionRequestInfo:= true raspPathBatchStartWebTamperProtectionRequestInfo:= "/usr/bin/tomcat/bin" enableRaspProtectBatchStartWebTamperProtectionRequestInfo:= true enableTimingOffBatchStartWebTamperProtectionRequestInfo:= true resourceIdBatchStartWebTamperProtectionRequestInfo:= "" chargingModeBatchStartWebTamperProtectionRequestInfo:= "packet_cycle" request.Body = &model.BatchStartWebTamperProtectionRequestInfo{ PrivilegedProcessInfo: privilegedProcessInfobody, EnablePrivilegedProcess: &enablePrivilegedProcessBatchStartWebTamperProtectionRequestInfo, RaspPath: &raspPathBatchStartWebTamperProtectionRequestInfo, EnableRaspProtect: &enableRaspProtectBatchStartWebTamperProtectionRequestInfo, TimingOffConfigInfo: timingOffConfigInfobody, EnableTimingOff: &enableTimingOffBatchStartWebTamperProtectionRequestInfo, ProtectDirInfo: protectDirInfobody, ResourceId: &resourceIdBatchStartWebTamperProtectionRequestInfo, ChargingMode: &chargingModeBatchStartWebTamperProtectionRequestInfo, HostIdList: listHostIdListbody, } response, err := client.BatchStartWebTamperProtection(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
请求已成功 |
错误码
请参见错误码。