diff --git a/.changelog/3356.txt b/.changelog/3356.txt new file mode 100644 index 0000000000..c195da4407 --- /dev/null +++ b/.changelog/3356.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +tencentcloud_waf_bot_scene_ucb_rule +``` \ No newline at end of file diff --git a/go.mod b/go.mod index 4c6e8b14de..dfd5feb56c 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,7 @@ require ( github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.1107 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.1033 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.1148 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1162 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1163 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.1153 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.1161 @@ -97,7 +97,7 @@ require ( github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.674 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.860 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.1154 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.1162 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.1163 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata v1.0.792 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wss v1.0.199 github.com/tencentyun/cos-go-sdk-v5 v0.7.64 diff --git a/go.sum b/go.sum index b89924ddcb..c293e58e3a 100644 --- a/go.sum +++ b/go.sum @@ -973,6 +973,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1161 h1:S4d github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1161/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1162 h1:bscCBygP9JRl6iNabF+vmBOhY+xayFFGYV5Wa0NzH0A= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1162/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1163 h1:RZs8N4afU816Foz4/M1byw1iIBK80ZuV3S66re64J+o= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1163/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993 h1:WlPgXldQCxt7qi5Xrc6j6zTrsXWzN5BcOGs7Irq7fwQ= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993/go.mod h1:Z9U8zNtyuyKhjS0698wqsrG/kLx1TQ5CEixXBwVe7xY= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860 h1:F3esKBIT3HW9+7Gt8cVgf8X06VdGIczpgLBUECzSEzU= @@ -1125,6 +1127,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.1161 h1:7eXR3p github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.1161/go.mod h1:v3l7e0+48bKOFo8V/KLLDtegi0H7zLDqGKLMdqNPblI= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.1162 h1:gnmuUaoFAShc9FKj3Omswu3n08bHM/sGsl8xjFAkFNs= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.1162/go.mod h1:bu3KAFeoJ1xDGQp72h9Le3FqbOcCcdomOUig3OqgcE4= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.1163 h1:dR/VWftnsFH/O18MaaM4DXDkBgFMIZYSWR4/6moy78A= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.1163/go.mod h1:RsiGONPLLzraDKCq1fs7bcm1OStioX7OWLXydoAmUf0= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata v1.0.792 h1:NLgKNOIHWa38AmW7dyfI9Jlcp2Kr9VRD94f48pPNmxM= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata v1.0.792/go.mod h1:Xz6vPV3gHlzPwtEcmWdWO1EUXJDgn2p7UMCXbJiVioQ= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wss v1.0.199 h1:hMBLtiJPnZ9GvA677cTB6ELBR6B68wCR2QY1sNoGQc4= diff --git a/tencentcloud/provider.md b/tencentcloud/provider.md index ce3f3cc937..cd73c877e0 100644 --- a/tencentcloud/provider.md +++ b/tencentcloud/provider.md @@ -2187,6 +2187,7 @@ tencentcloud_waf_domain_post_action_config tencentcloud_waf_instance_attack_log_post_config tencentcloud_waf_bot_scene_status_config tencentcloud_waf_bot_status_config +tencentcloud_waf_bot_scene_ucb_rule Wedata Data Source diff --git a/tencentcloud/services/waf/resource_tc_waf_waf_bot_scene_ucb_rule.go b/tencentcloud/services/waf/resource_tc_waf_bot_scene_ucb_rule.go similarity index 66% rename from tencentcloud/services/waf/resource_tc_waf_waf_bot_scene_ucb_rule.go rename to tencentcloud/services/waf/resource_tc_waf_bot_scene_ucb_rule.go index 175c237f32..1cb9744118 100644 --- a/tencentcloud/services/waf/resource_tc_waf_waf_bot_scene_ucb_rule.go +++ b/tencentcloud/services/waf/resource_tc_waf_bot_scene_ucb_rule.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "strings" + "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -105,6 +106,7 @@ func ResourceTencentCloudWafBotSceneUCBRule() *schema.Resource { "valid_key": { Type: schema.TypeString, Optional: true, + Computed: true, Description: "Indicate valid fields.", }, @@ -207,12 +209,6 @@ func ResourceTencentCloudWafBotSceneUCBRule() *schema.Resource { Description: "Rule priority.", }, - "timestamp": { - Type: schema.TypeInt, - Required: true, - Description: "Modifying timestamps.", - }, - "label": { Type: schema.TypeString, Required: true, @@ -228,6 +224,7 @@ func ResourceTencentCloudWafBotSceneUCBRule() *schema.Resource { "scene_id": { Type: schema.TypeString, Optional: true, + Computed: true, Description: "Scene ID.", }, @@ -242,6 +239,7 @@ func ResourceTencentCloudWafBotSceneUCBRule() *schema.Resource { Optional: true, Description: "Appid.", }, + "addition_arg": { Type: schema.TypeString, Optional: true, @@ -254,12 +252,6 @@ func ResourceTencentCloudWafBotSceneUCBRule() *schema.Resource { Description: "Rule description.", }, - "rule_id": { - Type: schema.TypeString, - Optional: true, - Description: "Rule ID.", - }, - "pre_define": { Type: schema.TypeBool, Optional: true, @@ -282,18 +274,21 @@ func ResourceTencentCloudWafBotSceneUCBRule() *schema.Resource { "timed": { Type: schema.TypeList, Optional: true, + Computed: true, Description: "Time parameter for timed execution.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "start_date_time": { Type: schema.TypeInt, Optional: true, + Computed: true, Description: "Start timestamp, in seconds.", }, "end_date_time": { Type: schema.TypeInt, Optional: true, + Computed: true, Description: "End timestamp, in seconds.", }, }, @@ -303,6 +298,7 @@ func ResourceTencentCloudWafBotSceneUCBRule() *schema.Resource { "cron": { Type: schema.TypeList, Optional: true, + Computed: true, Description: "Time parameter for cycle execution.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -312,6 +308,7 @@ func ResourceTencentCloudWafBotSceneUCBRule() *schema.Resource { Type: schema.TypeInt, }, Optional: true, + Computed: true, Description: "On what day of each month is it executed.", }, @@ -321,17 +318,21 @@ func ResourceTencentCloudWafBotSceneUCBRule() *schema.Resource { Type: schema.TypeInt, }, Optional: true, + Computed: true, Description: "What day of the week is executed each week.", }, "start_time": { Type: schema.TypeString, Optional: true, + Computed: true, Description: "Start time.", }, + "end_time": { Type: schema.TypeString, Optional: true, + Computed: true, Description: "End time.", }, }, @@ -356,6 +357,7 @@ func ResourceTencentCloudWafBotSceneUCBRule() *schema.Resource { "valid_status": { Type: schema.TypeInt, Optional: true, + Computed: true, Description: "Effective -1, Invalid -0.", }, @@ -388,6 +390,13 @@ func ResourceTencentCloudWafBotSceneUCBRule() *schema.Resource { }, }, }, + + // computed + "rule_id": { + Type: schema.TypeString, + Computed: true, + Description: "Rule ID.", + }, }, } } @@ -497,21 +506,22 @@ func resourceTencentCloudWafBotSceneUCBRuleCreate(d *schema.ResourceData, meta i if v, ok := ruleMap["areas"]; ok { for _, item := range v.([]interface{}) { - areasMap := item.(map[string]interface{}) - area := waf.Area{} - if v, ok := areasMap["country"]; ok { - area.Country = helper.String(v.(string)) - } + if areasMap, ok := item.(map[string]interface{}); ok && areasMap != nil { + area := waf.Area{} + if v, ok := areasMap["country"]; ok { + area.Country = helper.String(v.(string)) + } - if v, ok := areasMap["region"]; ok { - area.Region = helper.String(v.(string)) - } + if v, ok := areasMap["region"]; ok { + area.Region = helper.String(v.(string)) + } - if v, ok := areasMap["city"]; ok { - area.City = helper.String(v.(string)) - } + if v, ok := areasMap["city"]; ok { + area.City = helper.String(v.(string)) + } - inOutputUCBRuleEntry.Areas = append(inOutputUCBRuleEntry.Areas, &area) + inOutputUCBRuleEntry.Areas = append(inOutputUCBRuleEntry.Areas, &area) + } } } @@ -540,18 +550,13 @@ func resourceTencentCloudWafBotSceneUCBRuleCreate(d *schema.ResourceData, meta i inOutputBotUCBRule.Prior = helper.IntInt64(v.(int)) } - if v, ok := dMap["timestamp"]; ok { - inOutputBotUCBRule.Timestamp = helper.IntInt64(v.(int)) - } + tmpTime := time.Now().UnixMilli() + inOutputBotUCBRule.Timestamp = &tmpTime if v, ok := dMap["label"]; ok { inOutputBotUCBRule.Label = helper.String(v.(string)) } - if v, ok := dMap["id"]; ok { - inOutputBotUCBRule.Id = helper.String(v.(string)) - } - if v, ok := dMap["scene_id"]; ok { inOutputBotUCBRule.SceneId = helper.String(v.(string)) } @@ -572,10 +577,6 @@ func resourceTencentCloudWafBotSceneUCBRuleCreate(d *schema.ResourceData, meta i inOutputBotUCBRule.Desc = helper.String(v.(string)) } - if v, ok := dMap["rule_id"]; ok { - inOutputBotUCBRule.RuleId = helper.String(v.(string)) - } - if v, ok := dMap["pre_define"]; ok { inOutputBotUCBRule.PreDefine = helper.Bool(v.(bool)) } @@ -610,16 +611,20 @@ func resourceTencentCloudWafBotSceneUCBRuleCreate(d *schema.ResourceData, meta i if v, ok := cronMap["days"]; ok { daysSet := v.(*schema.Set).List() for i := range daysSet { - days := daysSet[i].(int) - cronJob.Days = append(cronJob.Days, helper.IntUint64(days)) + if daysSet[i] != nil { + days := daysSet[i].(int) + cronJob.Days = append(cronJob.Days, helper.IntUint64(days)) + } } } if v, ok := cronMap["w_days"]; ok { wDaysSet := v.(*schema.Set).List() for i := range wDaysSet { - wDays := wDaysSet[i].(int) - cronJob.WDays = append(cronJob.WDays, helper.IntUint64(wDays)) + if wDaysSet[i] != nil { + wDays := wDaysSet[i].(int) + cronJob.WDays = append(cronJob.WDays, helper.IntUint64(wDays)) + } } } @@ -696,8 +701,11 @@ func resourceTencentCloudWafBotSceneUCBRuleCreate(d *schema.ResourceData, meta i return err } - _ = response - ruleId := "" + if response.Response.RuleIdList == nil || len(response.Response.RuleIdList) < 1 { + return fmt.Errorf("RuleIdList is nil.") + } + + ruleId := *response.Response.RuleIdList[0] d.SetId(strings.Join([]string{domain, sceneId, ruleId}, tccommon.FILED_SP)) return resourceTencentCloudWafBotSceneUCBRuleRead(d, meta) @@ -741,254 +749,246 @@ func resourceTencentCloudWafBotSceneUCBRuleRead(d *schema.ResourceData, meta int _ = d.Set("scene_id", respData.SceneId) } - // if waf_bot_scene_ucb_rule.Rule != nil { - // ruleMap := map[string]interface{}{} - - // if waf_bot_scene_ucb_rule.Rule.Domain != nil { - // ruleMap["domain"] = waf_bot_scene_ucb_rule.Rule.Domain - // } - - // if waf_bot_scene_ucb_rule.Rule.Name != nil { - // ruleMap["name"] = waf_bot_scene_ucb_rule.Rule.Name - // } - - // if waf_bot_scene_ucb_rule.Rule.Rule != nil { - // ruleList := []interface{}{} - // for _, rule := range waf_bot_scene_ucb_rule.Rule.Rule { - // ruleMap := map[string]interface{}{} - - // if rule.Key != nil { - // ruleMap["key"] = rule.Key - // } - - // if rule.Op != nil { - // ruleMap["op"] = rule.Op - // } - - // if rule.Value != nil { - // valueMap := map[string]interface{}{} - - // if rule.Value.BasicValue != nil { - // valueMap["basic_value"] = rule.Value.BasicValue - // } - - // if rule.Value.LogicValue != nil { - // valueMap["logic_value"] = rule.Value.LogicValue - // } - - // if rule.Value.BelongValue != nil { - // valueMap["belong_value"] = rule.Value.BelongValue - // } + if respData.RuleId != nil { + _ = d.Set("rule_id", respData.RuleId) + } - // if rule.Value.ValidKey != nil { - // valueMap["valid_key"] = rule.Value.ValidKey - // } + ruleList := make([]map[string]interface{}, 0, 1) + ruleMap := make(map[string]interface{}) + if respData.Domain != nil { + ruleMap["domain"] = respData.Domain + } - // if rule.Value.MultiValue != nil { - // valueMap["multi_value"] = rule.Value.MultiValue - // } + if respData.Name != nil { + ruleMap["name"] = respData.Name + } - // ruleMap["value"] = []interface{}{valueMap} - // } + if respData.Rule != nil && len(respData.Rule) > 0 { + tmpList := make([]map[string]interface{}, 0, len(respData.Rule)) + for _, item := range respData.Rule { + dMap := make(map[string]interface{}) + if item.Key != nil { + dMap["key"] = item.Key + } - // if rule.OpOp != nil { - // ruleMap["op_op"] = rule.OpOp - // } + if item.Op != nil { + dMap["op"] = item.Op + } - // if rule.OpArg != nil { - // ruleMap["op_arg"] = rule.OpArg - // } + if item.Value != nil { + valueList := make([]map[string]interface{}, 0, 1) + valueMap := make(map[string]interface{}) + if item.Value.BasicValue != nil { + valueMap["basic_value"] = item.Value.BasicValue + } - // if rule.OpValue != nil { - // ruleMap["op_value"] = rule.OpValue - // } + if item.Value.LogicValue != nil { + valueMap["logic_value"] = item.Value.LogicValue + } - // if rule.Name != nil { - // ruleMap["name"] = rule.Name - // } + if item.Value.BelongValue != nil { + valueMap["belong_value"] = item.Value.BelongValue + } - // if rule.Areas != nil { - // areasList := []interface{}{} - // for _, areas := range rule.Areas { - // areasMap := map[string]interface{}{} + if item.Value.ValidKey != nil { + valueMap["valid_key"] = item.Value.ValidKey + } - // if areas.Country != nil { - // areasMap["country"] = areas.Country - // } + if item.Value.MultiValue != nil { + valueMap["multi_value"] = item.Value.MultiValue + } - // if areas.Region != nil { - // areasMap["region"] = areas.Region - // } + valueList = append(valueList, valueMap) + dMap["value"] = valueList + } - // if areas.City != nil { - // areasMap["city"] = areas.City - // } + if item.OpOp != nil { + dMap["op_op"] = item.OpOp + } - // areasList = append(areasList, areasMap) - // } + if item.OpArg != nil { + dMap["op_arg"] = item.OpArg + } - // ruleMap["areas"] = areasList - // } + if item.OpValue != nil { + dMap["op_value"] = item.OpValue + } - // if rule.Lang != nil { - // ruleMap["lang"] = rule.Lang - // } + if item.Name != nil { + dMap["name"] = item.Name + } - // ruleList = append(ruleList, ruleMap) - // } + if item.Areas != nil && len(item.Areas) > 0 { + areasList := make([]map[string]interface{}, 0, 1) + areasMap := make(map[string]interface{}) + for _, item := range item.Areas { + if item.Country != nil { + areasMap["country"] = item.Country + } - // ruleMap["rule"] = ruleList - // } + if item.Region != nil { + areasMap["region"] = item.Region + } - // if waf_bot_scene_ucb_rule.Rule.Action != nil { - // ruleMap["action"] = waf_bot_scene_ucb_rule.Rule.Action - // } + if item.City != nil { + areasMap["city"] = item.City + } - // if waf_bot_scene_ucb_rule.Rule.OnOff != nil { - // ruleMap["on_off"] = waf_bot_scene_ucb_rule.Rule.OnOff - // } + areasList = append(areasList, areasMap) + } - // if waf_bot_scene_ucb_rule.Rule.RuleType != nil { - // ruleMap["rule_type"] = waf_bot_scene_ucb_rule.Rule.RuleType - // } + dMap["areas"] = areasList + } - // if waf_bot_scene_ucb_rule.Rule.Prior != nil { - // ruleMap["prior"] = waf_bot_scene_ucb_rule.Rule.Prior - // } + if item.Lang != nil { + dMap["lang"] = item.Lang + } - // if waf_bot_scene_ucb_rule.Rule.Timestamp != nil { - // ruleMap["timestamp"] = waf_bot_scene_ucb_rule.Rule.Timestamp - // } + tmpList = append(tmpList, dMap) + } - // if waf_bot_scene_ucb_rule.Rule.Label != nil { - // ruleMap["label"] = waf_bot_scene_ucb_rule.Rule.Label - // } + ruleMap["rule"] = tmpList + } - // if waf_bot_scene_ucb_rule.Rule.Id != nil { - // ruleMap["id"] = waf_bot_scene_ucb_rule.Rule.Id - // } + if respData.Action != nil { + ruleMap["action"] = respData.Action + } - // if waf_bot_scene_ucb_rule.Rule.SceneId != nil { - // ruleMap["scene_id"] = waf_bot_scene_ucb_rule.Rule.SceneId - // } + if respData.OnOff != nil { + ruleMap["on_off"] = respData.OnOff + } - // if waf_bot_scene_ucb_rule.Rule.ValidTime != nil { - // ruleMap["valid_time"] = waf_bot_scene_ucb_rule.Rule.ValidTime - // } + if respData.RuleType != nil { + ruleMap["rule_type"] = respData.RuleType + } - // if waf_bot_scene_ucb_rule.Rule.Appid != nil { - // ruleMap["appid"] = waf_bot_scene_ucb_rule.Rule.Appid - // } + if respData.Prior != nil { + ruleMap["prior"] = respData.Prior + } - // if waf_bot_scene_ucb_rule.Rule.AdditionArg != nil { - // ruleMap["addition_arg"] = waf_bot_scene_ucb_rule.Rule.AdditionArg - // } + if respData.Label != nil { + ruleMap["label"] = respData.Label + } - // if waf_bot_scene_ucb_rule.Rule.Desc != nil { - // ruleMap["desc"] = waf_bot_scene_ucb_rule.Rule.Desc - // } + if respData.Id != nil { + ruleMap["id"] = respData.Id + } - // if waf_bot_scene_ucb_rule.Rule.RuleId != nil { - // ruleMap["rule_id"] = waf_bot_scene_ucb_rule.Rule.RuleId - // } + if respData.SceneId != nil { + ruleMap["scene_id"] = respData.SceneId + } - // if waf_bot_scene_ucb_rule.Rule.PreDefine != nil { - // ruleMap["pre_define"] = waf_bot_scene_ucb_rule.Rule.PreDefine - // } + if respData.ValidTime != nil { + ruleMap["valid_time"] = respData.ValidTime + } - // if waf_bot_scene_ucb_rule.Rule.JobType != nil { - // ruleMap["job_type"] = waf_bot_scene_ucb_rule.Rule.JobType - // } + if respData.Appid != nil { + ruleMap["appid"] = respData.Appid + } - // if waf_bot_scene_ucb_rule.Rule.JobDateTime != nil { - // jobDateTimeMap := map[string]interface{}{} + if respData.AdditionArg != nil { + ruleMap["addition_arg"] = respData.AdditionArg + } - // if waf_bot_scene_ucb_rule.Rule.JobDateTime.Timed != nil { - // timedList := []interface{}{} - // for _, timed := range waf_bot_scene_ucb_rule.Rule.JobDateTime.Timed { - // timedMap := map[string]interface{}{} + if respData.Desc != nil { + ruleMap["desc"] = respData.Desc + } - // if timed.StartDateTime != nil { - // timedMap["start_date_time"] = timed.StartDateTime - // } + if respData.PreDefine != nil { + ruleMap["pre_define"] = respData.PreDefine + } - // if timed.EndDateTime != nil { - // timedMap["end_date_time"] = timed.EndDateTime - // } + if respData.JobType != nil { + ruleMap["job_type"] = respData.JobType + } - // timedList = append(timedList, timedMap) - // } + if respData.JobDateTime != nil { + jdtList := make([]map[string]interface{}, 0, 1) + jdtMap := make(map[string]interface{}) + if respData.JobDateTime.Timed != nil && len(respData.JobDateTime.Timed) > 0 { + tList := make([]map[string]interface{}, 0, len(respData.JobDateTime.Timed)) + for _, item := range respData.JobDateTime.Timed { + tMap := make(map[string]interface{}) + if item.StartDateTime != nil { + tMap["start_date_time"] = item.StartDateTime + } - // jobDateTimeMap["timed"] = timedList - // } + if item.EndDateTime != nil { + tMap["end_date_time"] = item.EndDateTime + } - // if waf_bot_scene_ucb_rule.Rule.JobDateTime.Cron != nil { - // cronList := []interface{}{} - // for _, cron := range waf_bot_scene_ucb_rule.Rule.JobDateTime.Cron { - // cronMap := map[string]interface{}{} + tList = append(tList, tMap) + } - // if cron.Days != nil { - // cronMap["days"] = cron.Days - // } + jdtMap["timed"] = tList + } - // if cron.WDays != nil { - // cronMap["w_days"] = cron.WDays - // } + if respData.JobDateTime.Cron != nil && len(respData.JobDateTime.Cron) > 0 { + cList := make([]map[string]interface{}, 0, len(respData.JobDateTime.Cron)) + for _, item := range respData.JobDateTime.Cron { + cMap := make(map[string]interface{}) + if item.Days != nil { + cMap["days"] = item.Days + } - // if cron.StartTime != nil { - // cronMap["start_time"] = cron.StartTime - // } + if item.WDays != nil { + cMap["w_days"] = item.WDays + } - // if cron.EndTime != nil { - // cronMap["end_time"] = cron.EndTime - // } + if item.StartTime != nil { + cMap["start_time"] = item.StartTime + } - // cronList = append(cronList, cronMap) - // } + if item.EndTime != nil { + cMap["end_time"] = item.EndTime + } - // jobDateTimeMap["cron"] = cronList - // } + cList = append(cList, cMap) + } - // if waf_bot_scene_ucb_rule.Rule.JobDateTime.TimeTZone != nil { - // jobDateTimeMap["time_t_zone"] = waf_bot_scene_ucb_rule.Rule.JobDateTime.TimeTZone - // } + jdtMap["cron"] = cList + } - // ruleMap["job_date_time"] = []interface{}{jobDateTimeMap} - // } + if respData.JobDateTime.TimeTZone != nil { + jdtMap["time_t_zone"] = respData.JobDateTime.TimeTZone + } - // if waf_bot_scene_ucb_rule.Rule.ExpireTime != nil { - // ruleMap["expire_time"] = waf_bot_scene_ucb_rule.Rule.ExpireTime - // } + jdtList = append(jdtList, jdtMap) + ruleMap["job_date_time"] = jdtList + } - // if waf_bot_scene_ucb_rule.Rule.ValidStatus != nil { - // ruleMap["valid_status"] = waf_bot_scene_ucb_rule.Rule.ValidStatus - // } + if respData.ExpireTime != nil { + ruleMap["expire_time"] = respData.ExpireTime + } - // if waf_bot_scene_ucb_rule.Rule.BlockPageId != nil { - // ruleMap["block_page_id"] = waf_bot_scene_ucb_rule.Rule.BlockPageId - // } + if respData.ValidStatus != nil { + ruleMap["valid_status"] = respData.ValidStatus + } - // if waf_bot_scene_ucb_rule.Rule.ActionList != nil { - // actionListList := []interface{}{} - // for _, actionList := range waf_bot_scene_ucb_rule.Rule.ActionList { - // actionListMap := map[string]interface{}{} + if respData.BlockPageId != nil { + ruleMap["block_page_id"] = respData.BlockPageId + } - // if actionList.Action != nil { - // actionListMap["action"] = actionList.Action - // } + if respData.ActionList != nil && len(respData.ActionList) > 0 { + alList := make([]map[string]interface{}, 0, len(respData.ActionList)) + for _, item := range respData.ActionList { + alMap := make(map[string]interface{}) + if item.Action != nil { + alMap["action"] = item.Action + } - // if actionList.Proportion != nil { - // actionListMap["proportion"] = actionList.Proportion - // } + if item.Proportion != nil { + alMap["proportion"] = item.Proportion + } - // actionListList = append(actionListList, actionListMap) - // } + alList = append(alList, alMap) + } - // ruleMap["action_list"] = actionListList - // } + ruleMap["action_list"] = alList + } - // _ = d.Set("rule", []interface{}{ruleMap}) - // } + ruleList = append(ruleList, ruleMap) + _ = d.Set("rule", ruleList) return nil } @@ -1026,100 +1026,102 @@ func resourceTencentCloudWafBotSceneUCBRuleUpdate(d *schema.ResourceData, meta i if v, ok := dMap["rule"]; ok { for _, item := range v.([]interface{}) { - ruleMap := item.(map[string]interface{}) - inOutputUCBRuleEntry := waf.InOutputUCBRuleEntry{} - if v, ok := ruleMap["key"]; ok { - inOutputUCBRuleEntry.Key = helper.String(v.(string)) - } - - if v, ok := ruleMap["op"]; ok { - inOutputUCBRuleEntry.Op = helper.String(v.(string)) - } - - if valueMap, ok := helper.InterfaceToMap(ruleMap, "value"); ok { - uCBEntryValue := waf.UCBEntryValue{} - if v, ok := valueMap["basic_value"]; ok { - uCBEntryValue.BasicValue = helper.String(v.(string)) + if ruleMap, ok := item.(map[string]interface{}); ok && ruleMap != nil { + inOutputUCBRuleEntry := waf.InOutputUCBRuleEntry{} + if v, ok := ruleMap["key"]; ok { + inOutputUCBRuleEntry.Key = helper.String(v.(string)) } - if v, ok := valueMap["logic_value"]; ok { - uCBEntryValue.LogicValue = helper.Bool(v.(bool)) + if v, ok := ruleMap["op"]; ok { + inOutputUCBRuleEntry.Op = helper.String(v.(string)) } - if v, ok := valueMap["belong_value"]; ok { - belongValueSet := v.(*schema.Set).List() - for i := range belongValueSet { - if belongValueSet[i] != nil { - belongValue := belongValueSet[i].(string) - uCBEntryValue.BelongValue = append(uCBEntryValue.BelongValue, &belongValue) + if valueMap, ok := helper.InterfaceToMap(ruleMap, "value"); ok { + uCBEntryValue := waf.UCBEntryValue{} + if v, ok := valueMap["basic_value"]; ok { + uCBEntryValue.BasicValue = helper.String(v.(string)) + } + + if v, ok := valueMap["logic_value"]; ok { + uCBEntryValue.LogicValue = helper.Bool(v.(bool)) + } + + if v, ok := valueMap["belong_value"]; ok { + belongValueSet := v.(*schema.Set).List() + for i := range belongValueSet { + if belongValueSet[i] != nil { + belongValue := belongValueSet[i].(string) + uCBEntryValue.BelongValue = append(uCBEntryValue.BelongValue, &belongValue) + } } } - } - if v, ok := valueMap["valid_key"]; ok { - uCBEntryValue.ValidKey = helper.String(v.(string)) - } + if v, ok := valueMap["valid_key"]; ok { + uCBEntryValue.ValidKey = helper.String(v.(string)) + } - if v, ok := valueMap["multi_value"]; ok { - multiValueSet := v.(*schema.Set).List() - for i := range multiValueSet { - if multiValueSet[i] != nil { - multiValue := multiValueSet[i].(string) - uCBEntryValue.MultiValue = append(uCBEntryValue.MultiValue, &multiValue) + if v, ok := valueMap["multi_value"]; ok { + multiValueSet := v.(*schema.Set).List() + for i := range multiValueSet { + if multiValueSet[i] != nil { + multiValue := multiValueSet[i].(string) + uCBEntryValue.MultiValue = append(uCBEntryValue.MultiValue, &multiValue) + } } } - } - inOutputUCBRuleEntry.Value = &uCBEntryValue - } + inOutputUCBRuleEntry.Value = &uCBEntryValue + } - if v, ok := ruleMap["op_op"]; ok { - inOutputUCBRuleEntry.OpOp = helper.String(v.(string)) - } + if v, ok := ruleMap["op_op"]; ok { + inOutputUCBRuleEntry.OpOp = helper.String(v.(string)) + } - if v, ok := ruleMap["op_arg"]; ok { - opArgSet := v.(*schema.Set).List() - for i := range opArgSet { - if opArgSet[i] != nil { - opArg := opArgSet[i].(string) - inOutputUCBRuleEntry.OpArg = append(inOutputUCBRuleEntry.OpArg, &opArg) + if v, ok := ruleMap["op_arg"]; ok { + opArgSet := v.(*schema.Set).List() + for i := range opArgSet { + if opArgSet[i] != nil { + opArg := opArgSet[i].(string) + inOutputUCBRuleEntry.OpArg = append(inOutputUCBRuleEntry.OpArg, &opArg) + } } } - } - if v, ok := ruleMap["op_value"]; ok { - inOutputUCBRuleEntry.OpValue = helper.Float64(v.(float64)) - } + if v, ok := ruleMap["op_value"]; ok { + inOutputUCBRuleEntry.OpValue = helper.Float64(v.(float64)) + } - if v, ok := ruleMap["name"]; ok { - inOutputUCBRuleEntry.Name = helper.String(v.(string)) - } + if v, ok := ruleMap["name"]; ok { + inOutputUCBRuleEntry.Name = helper.String(v.(string)) + } - if v, ok := ruleMap["areas"]; ok { - for _, item := range v.([]interface{}) { - areasMap := item.(map[string]interface{}) - area := waf.Area{} - if v, ok := areasMap["country"]; ok { - area.Country = helper.String(v.(string)) - } + if v, ok := ruleMap["areas"]; ok { + for _, item := range v.([]interface{}) { + if areasMap, ok := item.(map[string]interface{}); ok && areasMap != nil { + area := waf.Area{} + if v, ok := areasMap["country"]; ok { + area.Country = helper.String(v.(string)) + } - if v, ok := areasMap["region"]; ok { - area.Region = helper.String(v.(string)) - } + if v, ok := areasMap["region"]; ok { + area.Region = helper.String(v.(string)) + } + + if v, ok := areasMap["city"]; ok { + area.City = helper.String(v.(string)) + } - if v, ok := areasMap["city"]; ok { - area.City = helper.String(v.(string)) + inOutputUCBRuleEntry.Areas = append(inOutputUCBRuleEntry.Areas, &area) + } } + } - inOutputUCBRuleEntry.Areas = append(inOutputUCBRuleEntry.Areas, &area) + if v, ok := ruleMap["lang"]; ok { + inOutputUCBRuleEntry.Lang = helper.String(v.(string)) } - } - if v, ok := ruleMap["lang"]; ok { - inOutputUCBRuleEntry.Lang = helper.String(v.(string)) + inOutputBotUCBRule.Rule = append(inOutputBotUCBRule.Rule, &inOutputUCBRuleEntry) } - - inOutputBotUCBRule.Rule = append(inOutputBotUCBRule.Rule, &inOutputUCBRuleEntry) } } @@ -1139,9 +1141,8 @@ func resourceTencentCloudWafBotSceneUCBRuleUpdate(d *schema.ResourceData, meta i inOutputBotUCBRule.Prior = helper.IntInt64(v.(int)) } - if v, ok := dMap["timestamp"]; ok { - inOutputBotUCBRule.Timestamp = helper.IntInt64(v.(int)) - } + tmpTime := time.Now().UnixMilli() + inOutputBotUCBRule.Timestamp = &tmpTime if v, ok := dMap["label"]; ok { inOutputBotUCBRule.Label = helper.String(v.(string)) @@ -1185,49 +1186,55 @@ func resourceTencentCloudWafBotSceneUCBRuleUpdate(d *schema.ResourceData, meta i jobDateTime := waf.JobDateTime{} if v, ok := jobDateTimeMap["timed"]; ok { for _, item := range v.([]interface{}) { - timedMap := item.(map[string]interface{}) - timedJob := waf.TimedJob{} - if v, ok := timedMap["start_date_time"]; ok { - timedJob.StartDateTime = helper.IntUint64(v.(int)) - } + if timedMap, ok := item.(map[string]interface{}); ok && timedMap != nil { + timedJob := waf.TimedJob{} + if v, ok := timedMap["start_date_time"]; ok { + timedJob.StartDateTime = helper.IntUint64(v.(int)) + } - if v, ok := timedMap["end_date_time"]; ok { - timedJob.EndDateTime = helper.IntUint64(v.(int)) - } + if v, ok := timedMap["end_date_time"]; ok { + timedJob.EndDateTime = helper.IntUint64(v.(int)) + } - jobDateTime.Timed = append(jobDateTime.Timed, &timedJob) + jobDateTime.Timed = append(jobDateTime.Timed, &timedJob) + } } } if v, ok := jobDateTimeMap["cron"]; ok { for _, item := range v.([]interface{}) { - cronMap := item.(map[string]interface{}) - cronJob := waf.CronJob{} - if v, ok := cronMap["days"]; ok { - daysSet := v.(*schema.Set).List() - for i := range daysSet { - days := daysSet[i].(int) - cronJob.Days = append(cronJob.Days, helper.IntUint64(days)) + if cronMap, ok := item.(map[string]interface{}); ok && cronMap != nil { + cronJob := waf.CronJob{} + if v, ok := cronMap["days"]; ok { + daysSet := v.(*schema.Set).List() + for i := range daysSet { + if daysSet[i] != nil { + days := daysSet[i].(int) + cronJob.Days = append(cronJob.Days, helper.IntUint64(days)) + } + } } - } - if v, ok := cronMap["w_days"]; ok { - wDaysSet := v.(*schema.Set).List() - for i := range wDaysSet { - wDays := wDaysSet[i].(int) - cronJob.WDays = append(cronJob.WDays, helper.IntUint64(wDays)) + if v, ok := cronMap["w_days"]; ok { + wDaysSet := v.(*schema.Set).List() + for i := range wDaysSet { + if wDaysSet[i] != nil { + wDays := wDaysSet[i].(int) + cronJob.WDays = append(cronJob.WDays, helper.IntUint64(wDays)) + } + } } - } - if v, ok := cronMap["start_time"]; ok { - cronJob.StartTime = helper.String(v.(string)) - } + if v, ok := cronMap["start_time"]; ok { + cronJob.StartTime = helper.String(v.(string)) + } - if v, ok := cronMap["end_time"]; ok { - cronJob.EndTime = helper.String(v.(string)) - } + if v, ok := cronMap["end_time"]; ok { + cronJob.EndTime = helper.String(v.(string)) + } - jobDateTime.Cron = append(jobDateTime.Cron, &cronJob) + jobDateTime.Cron = append(jobDateTime.Cron, &cronJob) + } } } @@ -1252,17 +1259,18 @@ func resourceTencentCloudWafBotSceneUCBRuleUpdate(d *schema.ResourceData, meta i if v, ok := dMap["action_list"]; ok { for _, item := range v.([]interface{}) { - actionListMap := item.(map[string]interface{}) - uCBActionProportion := waf.UCBActionProportion{} - if v, ok := actionListMap["action"]; ok { - uCBActionProportion.Action = helper.String(v.(string)) - } + if actionListMap, ok := item.(map[string]interface{}); ok && actionListMap != nil { + uCBActionProportion := waf.UCBActionProportion{} + if v, ok := actionListMap["action"]; ok { + uCBActionProportion.Action = helper.String(v.(string)) + } - if v, ok := actionListMap["proportion"]; ok { - uCBActionProportion.Proportion = helper.Float64(v.(float64)) - } + if v, ok := actionListMap["proportion"]; ok { + uCBActionProportion.Proportion = helper.Float64(v.(float64)) + } - inOutputBotUCBRule.ActionList = append(inOutputBotUCBRule.ActionList, &uCBActionProportion) + inOutputBotUCBRule.ActionList = append(inOutputBotUCBRule.ActionList, &uCBActionProportion) + } } } diff --git a/tencentcloud/services/waf/resource_tc_waf_bot_scene_ucb_rule.md b/tencentcloud/services/waf/resource_tc_waf_bot_scene_ucb_rule.md new file mode 100644 index 0000000000..8c948f7a25 --- /dev/null +++ b/tencentcloud/services/waf/resource_tc_waf_bot_scene_ucb_rule.md @@ -0,0 +1,152 @@ +Provides a resource to create a WAF bot scene ucb rule + +Example Usage + +The rules are permanently effective + +```hcl +resource "tencentcloud_waf_bot_scene_ucb_rule" "example" { + domain = "examle.com" + scene_id = "3000000791" + rule { + domain = "examle.com" + name = "tf-example" + rule { + key = "ip_scope" + op = "belong" + lang = "cn" + value { + belong_value = ["1.1.1.1"] + } + } + + action = "monitor" + on_off = "on" + rule_type = 0 + prior = 100 + label = "疑似BOT" + appid = 1276513791 + addition_arg = "none" + desc = "rule desc." + pre_define = true + job_type = "forever" + job_date_time { + timed { + start_date_time = 0 + end_date_time = 0 + } + + time_t_zone = "UTC+8" + } + } +} +``` + +The rules take effect on a scheduled basis + +```hcl +resource "tencentcloud_waf_bot_scene_ucb_rule" "example" { + domain = "examle.com" + scene_id = "3000000791" + rule { + domain = "examle.com" + name = "tf-example" + rule { + key = "header_value" + op = "logic" + name = "token" + lang = "cn" + value { + logic_value = true + } + } + + action = "multi_action" + action_list { + action = "monitor" + proportion = 0.3 + } + + action_list { + action = "intercept" + proportion = 0.3 + } + + action_list { + action = "captcha" + proportion = 0.4 + } + + on_off = "on" + rule_type = 0 + prior = 100 + label = "正常流量" + appid = 1256704386 + addition_arg = "none" + desc = "rule desc." + pre_define = true + job_type = "timed_job" + job_date_time { + timed { + start_date_time = 1747324800 + end_date_time = 1747152000 + } + + time_t_zone = "UTC+8" + } + } +} +``` + +The rules take effect on a weekly basis + +```hcl +resource "tencentcloud_waf_bot_scene_ucb_rule" "example" { + domain = "examle.com" + scene_id = "3000000791" + rule { + domain = "examle.com" + name = "tf-example" + rule { + key = "post_value" + op = "prefix" + lang = "cn" + value { + multi_value = [ + "terraform", + "provider" + ] + } + } + + action = "intercept" + on_off = "on" + rule_type = 0 + prior = 100 + label = "恶意BOT" + appid = 1256704386 + addition_arg = "none" + desc = "rule desc." + pre_define = true + block_page_id = 71 + job_type = "cron_week" + job_date_time { + cron { + w_days = [1, 2, 3, 4, 5] + start_time = "00:00:00" + end_time = "23:59:59" + } + + time_t_zone = "UTC+8" + } + } +} +``` + +Import + +WAF bot scene ucb rule can be imported using the id, e.g. + +``` +terraform import tencentcloud_waf_bot_scene_ucb_rule.example examle.com#3000000791#3000003489 +``` diff --git a/tencentcloud/services/waf/resource_tc_waf_bot_scene_ucb_rule_test.go b/tencentcloud/services/waf/resource_tc_waf_bot_scene_ucb_rule_test.go new file mode 100644 index 0000000000..469c6bb794 --- /dev/null +++ b/tencentcloud/services/waf/resource_tc_waf_bot_scene_ucb_rule_test.go @@ -0,0 +1,130 @@ +package waf_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest" +) + +func TestAccTencentClouddWafBotSceneUCBRuleResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + tcacctest.AccPreCheck(t) + }, + Providers: tcacctest.AccProviders, + Steps: []resource.TestStep{ + { + Config: testAccdWafBotSceneUCBRule, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("tencentcloud_waf_bot_scene_ucb_rule.example", "id"), + resource.TestCheckResourceAttrSet("tencentcloud_waf_bot_scene_ucb_rule.example", "domain"), + resource.TestCheckResourceAttrSet("tencentcloud_waf_bot_scene_ucb_rule.example", "scene_id"), + resource.TestCheckResourceAttrSet("tencentcloud_waf_bot_scene_ucb_rule.example", "rule.#"), + ), + }, + { + Config: testAccdWafBotSceneUCBRuleUpdate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("tencentcloud_waf_bot_scene_ucb_rule.example", "id"), + resource.TestCheckResourceAttrSet("tencentcloud_waf_bot_scene_ucb_rule.example", "domain"), + resource.TestCheckResourceAttrSet("tencentcloud_waf_bot_scene_ucb_rule.example", "scene_id"), + resource.TestCheckResourceAttrSet("tencentcloud_waf_bot_scene_ucb_rule.example", "rule.#"), + ), + }, + { + ResourceName: "tencentcloud_waf_bot_scene_ucb_rule.example", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccdWafBotSceneUCBRule = ` +resource "tencentcloud_waf_bot_scene_ucb_rule" "example" { + domain = "news.bots.icu" + scene_id = "3000000791" + rule { + domain = "news.bots.icu" + name = "tf-example" + rule { + key = "post_value" + op = "prefix" + lang = "cn" + value { + multi_value = [ + "terraform", + "provider" + ] + } + } + + action = "intercept" + on_off = "on" + rule_type = 0 + prior = 100 + label = "恶意BOT" + appid = 1256704386 + addition_arg = "none" + desc = "rule desc." + pre_define = true + block_page_id = 71 + job_type = "cron_week" + job_date_time { + cron { + w_days = [1, 2, 3, 4, 5] + start_time = "00:00:00" + end_time = "23:59:59" + } + + time_t_zone = "UTC+8" + } + } +} +` + +const testAccdWafBotSceneUCBRuleUpdate = ` +resource "tencentcloud_waf_bot_scene_ucb_rule" "example" { + domain = "news.bots.icu" + scene_id = "3000000791" + rule { + domain = "news.bots.icu" + name = "tf-example-update" + rule { + key = "post_value" + op = "prefix" + lang = "cn" + value { + multi_value = [ + "terraform", + "provider" + ] + } + } + + action = "intercept" + on_off = "on" + rule_type = 0 + prior = 100 + label = "恶意BOT" + appid = 1256704386 + addition_arg = "none" + desc = "rule desc." + pre_define = true + block_page_id = 71 + job_type = "cron_week" + job_date_time { + cron { + w_days = [1, 2, 3, 4, 5] + start_time = "01:00:00" + end_time = "20:00:00" + } + + time_t_zone = "UTC+8" + } + } +} +` diff --git a/tencentcloud/services/waf/service_tencentcloud_waf.go b/tencentcloud/services/waf/service_tencentcloud_waf.go index c78b048dfd..823768ace3 100644 --- a/tencentcloud/services/waf/service_tencentcloud_waf.go +++ b/tencentcloud/services/waf/service_tencentcloud_waf.go @@ -1704,7 +1704,8 @@ func (me *WafService) DescribeWafBotSceneStatusConfigById(ctx context.Context, d request := waf.NewDescribeBotSceneListRequest() response := waf.NewDescribeBotSceneListResponse() - request.Domain = helper.String(domain) + request.Domain = &domain + request.SceneId = &sceneId // wait waf sdk update // request.BusinessType = common.StringPtrs([]string{"all"}) request.BusinessType = common.StringPtrs([]string{"login", "seckill", "crawl", "scan", "key-protect", "click-farming", "junk-mail", "social-media", "auto-download", "custom"}) @@ -1804,9 +1805,10 @@ func (me *WafService) DescribeWafBotSceneUCBRuleById(ctx context.Context, domain request := waf.NewDescribeBotSceneUCBRuleRequest() response := waf.NewDescribeBotSceneUCBRuleResponse() - request.Domain = helper.String(domain) - request.SceneId = helper.String(sceneId) - request.Sort = helper.String("desc") + request.Domain = &domain + request.SceneId = &sceneId + request.RuleId = &ruleId + request.Sort = helper.String("timestamp:-1") defer func() { if errRet != nil { diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go index 788b771b86..1d7bc8c98a 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go @@ -265,7 +265,7 @@ func CompleteCommonParams(request Request, region string, requestClient string) params["Action"] = request.GetAction() params["Timestamp"] = strconv.FormatInt(time.Now().Unix(), 10) params["Nonce"] = strconv.Itoa(rand.Int()) - params["RequestClient"] = "SDK_GO_1.0.1162" + params["RequestClient"] = "SDK_GO_1.0.1163" if requestClient != "" { params["RequestClient"] += ": " + requestClient } diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf/v20180125/client.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf/v20180125/client.go index 4312684a12..2ba3264139 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf/v20180125/client.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf/v20180125/client.go @@ -3538,12 +3538,16 @@ func NewDescribeCertificateVerifyResultResponse() (response *DescribeCertificate // // 可能返回的错误码: // FAILEDOPERATION = "FailedOperation" +// FAILEDOPERATION_CERTIFICATENOTFOUND = "FailedOperation.CertificateNotFound" // INTERNALERROR = "InternalError" +// INTERNALERROR_SSLCALLFAILED = "InternalError.SSLCallFailed" // INVALIDPARAMETER = "InvalidParameter" +// INVALIDPARAMETER_CERTIFICATECHECKERR = "InvalidParameter.CertificateCheckErr" // INVALIDPARAMETER_INVALIDCERTIFICATE = "InvalidParameter.InvalidCertificate" // INVALIDPARAMETER_QUERYCERTBYSSLIDFAILED = "InvalidParameter.QueryCertBySSLIDFailed" // INVALIDPARAMETERVALUE = "InvalidParameterValue" // RESOURCEUNAVAILABLE = "ResourceUnavailable" +// RESOURCEUNAVAILABLE_SSLCERTIFICATEERR = "ResourceUnavailable.SSLCertificateErr" func (c *Client) DescribeCertificateVerifyResult(request *DescribeCertificateVerifyResultRequest) (response *DescribeCertificateVerifyResultResponse, err error) { return c.DescribeCertificateVerifyResultWithContext(context.Background(), request) } @@ -3553,12 +3557,16 @@ func (c *Client) DescribeCertificateVerifyResult(request *DescribeCertificateVer // // 可能返回的错误码: // FAILEDOPERATION = "FailedOperation" +// FAILEDOPERATION_CERTIFICATENOTFOUND = "FailedOperation.CertificateNotFound" // INTERNALERROR = "InternalError" +// INTERNALERROR_SSLCALLFAILED = "InternalError.SSLCallFailed" // INVALIDPARAMETER = "InvalidParameter" +// INVALIDPARAMETER_CERTIFICATECHECKERR = "InvalidParameter.CertificateCheckErr" // INVALIDPARAMETER_INVALIDCERTIFICATE = "InvalidParameter.InvalidCertificate" // INVALIDPARAMETER_QUERYCERTBYSSLIDFAILED = "InvalidParameter.QueryCertBySSLIDFailed" // INVALIDPARAMETERVALUE = "InvalidParameterValue" // RESOURCEUNAVAILABLE = "ResourceUnavailable" +// RESOURCEUNAVAILABLE_SSLCERTIFICATEERR = "ResourceUnavailable.SSLCertificateErr" func (c *Client) DescribeCertificateVerifyResultWithContext(ctx context.Context, request *DescribeCertificateVerifyResultRequest) (response *DescribeCertificateVerifyResultResponse, err error) { if request == nil { request = NewDescribeCertificateVerifyResultRequest() diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf/v20180125/errors.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf/v20180125/errors.go index 955cfb0520..edeaa4317f 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf/v20180125/errors.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf/v20180125/errors.go @@ -38,6 +38,9 @@ const ( // CLS内部错误。 FAILEDOPERATION_CLSINTERNALERROR = "FailedOperation.CLSInternalError" + // 证书不存在 + FAILEDOPERATION_CERTIFICATENOTFOUND = "FailedOperation.CertificateNotFound" + // 操作CH数据库失败 FAILEDOPERATION_CLICKHOUSEOPERATIONFAILED = "FailedOperation.ClickHouseOperationFailed" @@ -68,6 +71,9 @@ const ( // DBErr INTERNALERROR_DBERR = "InternalError.DBErr" + // 调用SSL证书接口发生内部错误 + INTERNALERROR_SSLCALLFAILED = "InternalError.SSLCallFailed" + // 存在内部错误,请联系我们 INTERNALERROR_UNKNOWNERR = "InternalError.UnknownErr" @@ -80,6 +86,9 @@ const ( // Bot场景不存在 INVALIDPARAMETER_BOTSCENENOTEXISTERR = "InvalidParameter.BotSceneNotExistErr" + // 证书和私钥检查不通过 + INVALIDPARAMETER_CERTIFICATECHECKERR = "InvalidParameter.CertificateCheckErr" + // 证书信息参数错误 INVALIDPARAMETER_CERTIFICATIONPARAMETERERR = "InvalidParameter.CertificationParameterErr" @@ -176,6 +185,9 @@ const ( // IPV6网络正在分配,请耐心等待 RESOURCEUNAVAILABLE_DOMAINIPV6INCONFIGERR = "ResourceUnavailable.DomainIpv6InConfigErr" + // SSL证书ID关联的证书内容错误 + RESOURCEUNAVAILABLE_SSLCERTIFICATEERR = "ResourceUnavailable.SSLCertificateErr" + // 资源售罄。 RESOURCESSOLDOUT = "ResourcesSoldOut" diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf/v20180125/models.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf/v20180125/models.go index e8bc0ae860..d05cea86ac 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf/v20180125/models.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf/v20180125/models.go @@ -2090,6 +2090,9 @@ type CCRuleItems struct { // 创建时间 CreateTime *uint64 `json:"CreateTime,omitnil,omitempty" name:"CreateTime"` + + // 限频方式 + LimitMethod *string `json:"LimitMethod,omitnil,omitempty" name:"LimitMethod"` } type CCRuleLists struct { @@ -2258,6 +2261,12 @@ type ClbObject struct { // 数值形式的私有网络 ID NumericalVpcId *int64 `json:"NumericalVpcId,omitnil,omitempty" name:"NumericalVpcId"` + + // 修改时间 + ModifyTime *string `json:"ModifyTime,omitnil,omitempty" name:"ModifyTime"` + + // 创建时间 + AddTime *string `json:"AddTime,omitnil,omitempty" name:"AddTime"` } type ClbWafRegionItem struct { @@ -2632,7 +2641,7 @@ func (r *CreateDealsResponse) FromJsonString(s string) error { // Predefined struct for user type CreateHostRequestParams struct { - // 防护域名配置信息 + // 防护域名配置信息。内网负载均衡器必须携带对应的NumericalVpcId。 Host *HostRecord `json:"Host,omitnil,omitempty" name:"Host"` // 实例id @@ -2642,7 +2651,7 @@ type CreateHostRequestParams struct { type CreateHostRequest struct { *tchttp.BaseRequest - // 防护域名配置信息 + // 防护域名配置信息。内网负载均衡器必须携带对应的NumericalVpcId。 Host *HostRecord `json:"Host,omitnil,omitempty" name:"Host"` // 实例id @@ -5595,6 +5604,9 @@ type DescribeBotSceneListRequestParams struct { // 是否仅显示生效场景 IsValid *bool `json:"IsValid,omitnil,omitempty" name:"IsValid"` + + // 要查询的场景id + SceneId *string `json:"SceneId,omitnil,omitempty" name:"SceneId"` } type DescribeBotSceneListRequest struct { @@ -5620,6 +5632,9 @@ type DescribeBotSceneListRequest struct { // 是否仅显示生效场景 IsValid *bool `json:"IsValid,omitnil,omitempty" name:"IsValid"` + + // 要查询的场景id + SceneId *string `json:"SceneId,omitnil,omitempty" name:"SceneId"` } func (r *DescribeBotSceneListRequest) ToJsonString() string { @@ -5641,6 +5656,7 @@ func (r *DescribeBotSceneListRequest) FromJsonString(s string) error { delete(f, "SceneName") delete(f, "IsDefault") delete(f, "IsValid") + delete(f, "SceneId") if len(f) > 0 { return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DescribeBotSceneListRequest has unknown keys!", "") } @@ -5722,7 +5738,6 @@ type DescribeBotSceneOverviewResponseParams struct { ValidSceneCount *int64 `json:"ValidSceneCount,omitnil,omitempty" name:"ValidSceneCount"` // 当前开启的、匹配范围为全局、优先级最高的场景 - // 注意:此字段可能返回 null,表示取不到有效值。 CurrentGlobalScene *GlobalSceneInfo `json:"CurrentGlobalScene,omitnil,omitempty" name:"CurrentGlobalScene"` // 自定义规则总数,不包括BOT白名单 @@ -5779,6 +5794,9 @@ type DescribeBotSceneUCBRuleRequestParams struct { // 0-全部 1-生效中 2-已过期 ValidStatus *uint64 `json:"ValidStatus,omitnil,omitempty" name:"ValidStatus"` + + // 规则id + RuleId *string `json:"RuleId,omitnil,omitempty" name:"RuleId"` } type DescribeBotSceneUCBRuleRequest struct { @@ -5813,6 +5831,9 @@ type DescribeBotSceneUCBRuleRequest struct { // 0-全部 1-生效中 2-已过期 ValidStatus *uint64 `json:"ValidStatus,omitnil,omitempty" name:"ValidStatus"` + + // 规则id + RuleId *string `json:"RuleId,omitnil,omitempty" name:"RuleId"` } func (r *DescribeBotSceneUCBRuleRequest) ToJsonString() string { @@ -5837,6 +5858,7 @@ func (r *DescribeBotSceneUCBRuleRequest) FromJsonString(s string) error { delete(f, "VersionFlag") delete(f, "TimerType") delete(f, "ValidStatus") + delete(f, "RuleId") if len(f) > 0 { return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DescribeBotSceneUCBRuleRequest has unknown keys!", "") } @@ -5846,7 +5868,6 @@ func (r *DescribeBotSceneUCBRuleRequest) FromJsonString(s string) error { // Predefined struct for user type DescribeBotSceneUCBRuleResponseParams struct { // 返回数据包 - // 注意:此字段可能返回 null,表示取不到有效值。 Data *DescribeBotUCBRuleRsp `json:"Data,omitnil,omitempty" name:"Data"` // 唯一请求 ID,由服务端生成,每次请求都会返回(若请求因其他原因未能抵达服务端,则该次请求不会获得 RequestId)。定位问题时需要提供该次请求的 RequestId。 @@ -6123,7 +6144,7 @@ type DescribeCertificateVerifyResultRequestParams struct { // 域名 Domain *string `json:"Domain,omitnil,omitempty" name:"Domain"` - // 证书类型。 0:不检测国际标准证书 1:证书来源为自有证书 2:证书来源为托管证书 + // 证书类型,此参数和GmCertType不可同时为0。 0:不检测国际标准证书 1:证书来源为自有证书 2:证书来源为托管证书 CertType *int64 `json:"CertType,omitnil,omitempty" name:"CertType"` // CertType为1时,需要填充此参数,表示自有证书的证书链 @@ -6135,7 +6156,7 @@ type DescribeCertificateVerifyResultRequestParams struct { // CertType为1时,需要填充此参数,表示自有证书的私钥 PrivateKey *string `json:"PrivateKey,omitnil,omitempty" name:"PrivateKey"` - // 国密证书类型。0:不检测国密证书 1:证书来源为自有国密证书 2:证书来源为托管国密证书 + // 国密证书类型,此参数和CertType不可同时为0。0:不检测国密证书 1:证书来源为自有国密证书 2:证书来源为托管国密证书 GmCertType *int64 `json:"GmCertType,omitnil,omitempty" name:"GmCertType"` // GmCertType为1时,需要填充此参数,表示自有国密证书的证书链 @@ -6160,7 +6181,7 @@ type DescribeCertificateVerifyResultRequest struct { // 域名 Domain *string `json:"Domain,omitnil,omitempty" name:"Domain"` - // 证书类型。 0:不检测国际标准证书 1:证书来源为自有证书 2:证书来源为托管证书 + // 证书类型,此参数和GmCertType不可同时为0。 0:不检测国际标准证书 1:证书来源为自有证书 2:证书来源为托管证书 CertType *int64 `json:"CertType,omitnil,omitempty" name:"CertType"` // CertType为1时,需要填充此参数,表示自有证书的证书链 @@ -6172,7 +6193,7 @@ type DescribeCertificateVerifyResultRequest struct { // CertType为1时,需要填充此参数,表示自有证书的私钥 PrivateKey *string `json:"PrivateKey,omitnil,omitempty" name:"PrivateKey"` - // 国密证书类型。0:不检测国密证书 1:证书来源为自有国密证书 2:证书来源为托管国密证书 + // 国密证书类型,此参数和CertType不可同时为0。0:不检测国密证书 1:证书来源为自有国密证书 2:证书来源为托管国密证书 GmCertType *int64 `json:"GmCertType,omitnil,omitempty" name:"GmCertType"` // GmCertType为1时,需要填充此参数,表示自有国密证书的证书链 @@ -8067,6 +8088,12 @@ func (r *DescribeModuleStatusResponse) FromJsonString(s string) error { type DescribeObjectsRequestParams struct { // 支持的过滤器: ObjectId: clb实例ID VIP: clb实例的公网IP InstanceId: waf实例ID Domain: 精准域名 Status: waf防护开关状态: 0关闭,1开启 ClsStatus: waf日志开关: 0关闭,1开启 Filters []*FiltersItemNew `json:"Filters,omitnil,omitempty" name:"Filters"` + + // 排序方式,支持asc或者desc + Order *string `json:"Order,omitnil,omitempty" name:"Order"` + + // 根据哪个字段排序 + By *string `json:"By,omitnil,omitempty" name:"By"` } type DescribeObjectsRequest struct { @@ -8074,6 +8101,12 @@ type DescribeObjectsRequest struct { // 支持的过滤器: ObjectId: clb实例ID VIP: clb实例的公网IP InstanceId: waf实例ID Domain: 精准域名 Status: waf防护开关状态: 0关闭,1开启 ClsStatus: waf日志开关: 0关闭,1开启 Filters []*FiltersItemNew `json:"Filters,omitnil,omitempty" name:"Filters"` + + // 排序方式,支持asc或者desc + Order *string `json:"Order,omitnil,omitempty" name:"Order"` + + // 根据哪个字段排序 + By *string `json:"By,omitnil,omitempty" name:"By"` } func (r *DescribeObjectsRequest) ToJsonString() string { @@ -8089,6 +8122,8 @@ func (r *DescribeObjectsRequest) FromJsonString(s string) error { return err } delete(f, "Filters") + delete(f, "Order") + delete(f, "By") if len(f) > 0 { return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DescribeObjectsRequest has unknown keys!", "") } @@ -11538,6 +11573,9 @@ type InOutputBotUCBRule struct { // 当Action=intercept时,此字段必填 ActionList []*UCBActionProportion `json:"ActionList,omitnil,omitempty" name:"ActionList"` + + // 惩罚时间 + DelayTime *int64 `json:"DelayTime,omitnil,omitempty" name:"DelayTime"` } type InOutputUCBRuleEntry struct { @@ -11567,6 +11605,9 @@ type InOutputUCBRuleEntry struct { // 语言环境 Lang *string `json:"Lang,omitnil,omitempty" name:"Lang"` + + // 参数匹配 + ParamCompareList []*ParamCompareList `json:"ParamCompareList,omitnil,omitempty" name:"ParamCompareList"` } type InstanceInfo struct { @@ -11839,9 +11880,6 @@ type LoadBalancer struct { // 负载均衡监听器的名称 ListenerName *string `json:"ListenerName,omitnil,omitempty" name:"ListenerName"` - // 负载均衡实例的IP - Vip *string `json:"Vip,omitnil,omitempty" name:"Vip"` - // 负载均衡实例的端口 Vport *uint64 `json:"Vport,omitnil,omitempty" name:"Vport"` @@ -11854,6 +11892,9 @@ type LoadBalancer struct { // 负载均衡监听器所在的zone Zone *string `json:"Zone,omitnil,omitempty" name:"Zone"` + // 负载均衡实例的IP。域名化CLB VIP可填空。 + Vip *string `json:"Vip,omitnil,omitempty" name:"Vip"` + // 负载均衡的VPCID,公网为-1,内网按实际填写 NumericalVpcId *int64 `json:"NumericalVpcId,omitnil,omitempty" name:"NumericalVpcId"` @@ -12984,6 +13025,9 @@ type ModifyBotSceneUCBRuleResponseParams struct { // 正常情况下为null Data *string `json:"Data,omitnil,omitempty" name:"Data"` + // ["1231"] + RuleIdList []*string `json:"RuleIdList,omitnil,omitempty" name:"RuleIdList"` + // 唯一请求 ID,由服务端生成,每次请求都会返回(若请求因其他原因未能抵达服务端,则该次请求不会获得 RequestId)。定位问题时需要提供该次请求的 RequestId。 RequestId *string `json:"RequestId,omitnil,omitempty" name:"RequestId"` } @@ -15863,6 +15907,14 @@ func (r *ModifyWebshellStatusResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +type ParamCompareList struct { + // 请求参数比对的匹配参数 + Key *string `json:"Key,omitnil,omitempty" name:"Key"` + + // 请求参数比对的匹配值 + Value *string `json:"Value,omitnil,omitempty" name:"Value"` +} + type PeakPointsItem struct { // 秒级别时间戳 Time *uint64 `json:"Time,omitnil,omitempty" name:"Time"` @@ -16658,7 +16710,7 @@ type SessionItem struct { } type SpartaProtectionPort struct { - // 分配的服务器id + // 分配的服务器id。首次接入的域名和端口该参数填0,已接入的域名和端口分配的id可以通过DescribeDomainDetailsSaas或DescribeDomains接口获取。 NginxServerId *uint64 `json:"NginxServerId,omitnil,omitempty" name:"NginxServerId"` // 端口 @@ -17145,7 +17197,7 @@ type UpsertCCRuleRequestParams struct { // 动作有效时间 ValidTime *int64 `json:"ValidTime,omitnil,omitempty" name:"ValidTime"` - // CC的匹配条件JSON序列化的字符串,示例:[{\"key\":\"Method\",\"args\":[\"=R0VU\"],\"match\":\"0\",\"encodeflag\":true}] Key可选值为 Method、Post、Referer、Cookie、User-Agent、CustomHeader match可选值为,当Key为Method的时候可选值为0(等于)、3(不等于)。 Key为Post的时候可选值为0(等于)、3(不等于),Key为Cookie的时候可选值为0(等于)、2(包含),3(不等于)、7(不包含)、 当Key为Referer的时候可选值为0(等于)、3(不等于)、1(前缀匹配)、6(后缀匹配)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空), 当Key为Cookie的时候可选值为0(等于)、3(不等于)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空), 当Key为User-Agent的时候可选值为0(等于)、3(不等于)、1(前缀匹配)、6(后缀匹配)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空), 当Key为CustomHeader的时候可选值为0(等于)、3(不等于)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空)。 args用来表示匹配内容,需要设置encodeflag为true,当Key为Post、Cookie、CustomHeader时,用等号=来分别串接Key和Value,并分别用Base64编码,类似YWJj=YWJj。当Key为Referer、User-Agent时,用等号=来串接Value,类似=YWJj。 + // CC的匹配条件JSON序列化的字符串,示例:[{\"key\":\"Method\",\"args\":[\"=R0VU\"],\"match\":\"0\",\"encodeflag\":true}] Key可选值为 Method、Post、Referer、Cookie、User-Agent、CustomHeader match可选值为,当Key为Method的时候可选值为0(等于)、3(不等于)。 Key为Post的时候可选值为0(等于)、3(不等于),Key为Cookie的时候可选值为0(等于)、2(包含),3(不等于)、7(不包含)、 当Key为Referer的时候可选值为0(等于)、3(不等于)、1(前缀匹配)、6(后缀匹配)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空), 当Key为Cookie的时候可选值为0(等于)、3(不等于)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空), 当Key为User-Agent的时候可选值为0(等于)、3(不等于)、1(前缀匹配)、6(后缀匹配)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空), 当Key为CustomHeader的时候可选值为0(等于)、3(不等于)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空)。 Key为IPLocation时,可选值为13(属于)、14(不属于)。args用来表示匹配内容,需要设置encodeflag为true,当Key为Post、Cookie、CustomHeader时,用等号=来分别串接Key和Value,并分别用Base64编码,类似YWJj=YWJj。当Key为Referer、User-Agent时,用等号=来串接Value,类似=YWJj。 OptionsArr *string `json:"OptionsArr,omitnil,omitempty" name:"OptionsArr"` // waf版本,sparta-waf或者clb-waf @@ -17168,6 +17220,9 @@ type UpsertCCRuleRequestParams struct { // url长度 Length *uint64 `json:"Length,omitnil,omitempty" name:"Length"` + + // 限频方式 + LimitMethod *string `json:"LimitMethod,omitnil,omitempty" name:"LimitMethod"` } type UpsertCCRuleRequest struct { @@ -17206,7 +17261,7 @@ type UpsertCCRuleRequest struct { // 动作有效时间 ValidTime *int64 `json:"ValidTime,omitnil,omitempty" name:"ValidTime"` - // CC的匹配条件JSON序列化的字符串,示例:[{\"key\":\"Method\",\"args\":[\"=R0VU\"],\"match\":\"0\",\"encodeflag\":true}] Key可选值为 Method、Post、Referer、Cookie、User-Agent、CustomHeader match可选值为,当Key为Method的时候可选值为0(等于)、3(不等于)。 Key为Post的时候可选值为0(等于)、3(不等于),Key为Cookie的时候可选值为0(等于)、2(包含),3(不等于)、7(不包含)、 当Key为Referer的时候可选值为0(等于)、3(不等于)、1(前缀匹配)、6(后缀匹配)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空), 当Key为Cookie的时候可选值为0(等于)、3(不等于)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空), 当Key为User-Agent的时候可选值为0(等于)、3(不等于)、1(前缀匹配)、6(后缀匹配)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空), 当Key为CustomHeader的时候可选值为0(等于)、3(不等于)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空)。 args用来表示匹配内容,需要设置encodeflag为true,当Key为Post、Cookie、CustomHeader时,用等号=来分别串接Key和Value,并分别用Base64编码,类似YWJj=YWJj。当Key为Referer、User-Agent时,用等号=来串接Value,类似=YWJj。 + // CC的匹配条件JSON序列化的字符串,示例:[{\"key\":\"Method\",\"args\":[\"=R0VU\"],\"match\":\"0\",\"encodeflag\":true}] Key可选值为 Method、Post、Referer、Cookie、User-Agent、CustomHeader match可选值为,当Key为Method的时候可选值为0(等于)、3(不等于)。 Key为Post的时候可选值为0(等于)、3(不等于),Key为Cookie的时候可选值为0(等于)、2(包含),3(不等于)、7(不包含)、 当Key为Referer的时候可选值为0(等于)、3(不等于)、1(前缀匹配)、6(后缀匹配)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空), 当Key为Cookie的时候可选值为0(等于)、3(不等于)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空), 当Key为User-Agent的时候可选值为0(等于)、3(不等于)、1(前缀匹配)、6(后缀匹配)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空), 当Key为CustomHeader的时候可选值为0(等于)、3(不等于)、2(包含)、7(不包含)、12(存在)、5(不存在)、4(内容为空)。 Key为IPLocation时,可选值为13(属于)、14(不属于)。args用来表示匹配内容,需要设置encodeflag为true,当Key为Post、Cookie、CustomHeader时,用等号=来分别串接Key和Value,并分别用Base64编码,类似YWJj=YWJj。当Key为Referer、User-Agent时,用等号=来串接Value,类似=YWJj。 OptionsArr *string `json:"OptionsArr,omitnil,omitempty" name:"OptionsArr"` // waf版本,sparta-waf或者clb-waf @@ -17229,6 +17284,9 @@ type UpsertCCRuleRequest struct { // url长度 Length *uint64 `json:"Length,omitnil,omitempty" name:"Length"` + + // 限频方式 + LimitMethod *string `json:"LimitMethod,omitnil,omitempty" name:"LimitMethod"` } func (r *UpsertCCRuleRequest) ToJsonString() string { @@ -17262,6 +17320,7 @@ func (r *UpsertCCRuleRequest) FromJsonString(s string) error { delete(f, "RuleId") delete(f, "CreateTime") delete(f, "Length") + delete(f, "LimitMethod") if len(f) > 0 { return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "UpsertCCRuleRequest has unknown keys!", "") } diff --git a/vendor/modules.txt b/vendor/modules.txt index 1d929942c6..9e81c1f3cf 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1166,7 +1166,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit/v20190319 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.1148 ## explicit; go 1.14 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls/v20201016 -# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1162 +# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1163 ## explicit; go 1.11 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors @@ -1352,7 +1352,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod/v20180717 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.1154 ## explicit; go 1.14 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312 -# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.1162 +# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.1163 ## explicit; go 1.14 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf/v20180125 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata v1.0.792 diff --git a/website/docs/r/waf_bot_scene_ucb_rule.html.markdown b/website/docs/r/waf_bot_scene_ucb_rule.html.markdown new file mode 100644 index 0000000000..a227aaeab9 --- /dev/null +++ b/website/docs/r/waf_bot_scene_ucb_rule.html.markdown @@ -0,0 +1,253 @@ +--- +subcategory: "Web Application Firewall(WAF)" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_waf_bot_scene_ucb_rule" +sidebar_current: "docs-tencentcloud-resource-waf_bot_scene_ucb_rule" +description: |- + Provides a resource to create a WAF bot scene ucb rule +--- + +# tencentcloud_waf_bot_scene_ucb_rule + +Provides a resource to create a WAF bot scene ucb rule + +## Example Usage + +### The rules are permanently effective + +```hcl +resource "tencentcloud_waf_bot_scene_ucb_rule" "example" { + domain = "examle.com" + scene_id = "3000000791" + rule { + domain = "examle.com" + name = "tf-example" + rule { + key = "ip_scope" + op = "belong" + lang = "cn" + value { + belong_value = ["1.1.1.1"] + } + } + + action = "monitor" + on_off = "on" + rule_type = 0 + prior = 100 + label = "疑似BOT" + appid = 1276513791 + addition_arg = "none" + desc = "rule desc." + pre_define = true + job_type = "forever" + job_date_time { + timed { + start_date_time = 0 + end_date_time = 0 + } + + time_t_zone = "UTC+8" + } + } +} +``` + +### The rules take effect on a scheduled basis + +```hcl +resource "tencentcloud_waf_bot_scene_ucb_rule" "example" { + domain = "examle.com" + scene_id = "3000000791" + rule { + domain = "examle.com" + name = "tf-example" + rule { + key = "header_value" + op = "logic" + name = "token" + lang = "cn" + value { + logic_value = true + } + } + + action = "multi_action" + action_list { + action = "monitor" + proportion = 0.3 + } + + action_list { + action = "intercept" + proportion = 0.3 + } + + action_list { + action = "captcha" + proportion = 0.4 + } + + on_off = "on" + rule_type = 0 + prior = 100 + label = "正常流量" + appid = 1256704386 + addition_arg = "none" + desc = "rule desc." + pre_define = true + job_type = "timed_job" + job_date_time { + timed { + start_date_time = 1747324800 + end_date_time = 1747152000 + } + + time_t_zone = "UTC+8" + } + } +} +``` + +### The rules take effect on a weekly basis + +```hcl +resource "tencentcloud_waf_bot_scene_ucb_rule" "example" { + domain = "examle.com" + scene_id = "3000000791" + rule { + domain = "examle.com" + name = "tf-example" + rule { + key = "post_value" + op = "prefix" + lang = "cn" + value { + multi_value = [ + "terraform", + "provider" + ] + } + } + + action = "intercept" + on_off = "on" + rule_type = 0 + prior = 100 + label = "恶意BOT" + appid = 1256704386 + addition_arg = "none" + desc = "rule desc." + pre_define = true + block_page_id = 71 + job_type = "cron_week" + job_date_time { + cron { + w_days = [1, 2, 3, 4, 5] + start_time = "00:00:00" + end_time = "23:59:59" + } + + time_t_zone = "UTC+8" + } + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `domain` - (Required, String, ForceNew) Domain. +* `scene_id` - (Required, String, ForceNew) When calling at the BOT global whitelist, pass `global`; When configuring BOT scenarios, transmit the specific scenario ID. +* `rule` - (Optional, List) Rule content, add encoding SceneId information. When calling at the BOT global whitelist, SceneId is set to `global` and RuleType is passed as 10, Action is `permit`; When configuring BOT scenarios, SceneId is the scenario ID. + +The `action_list` object of `rule` supports the following: + +* `action` - (Optional, String) Action. +* `proportion` - (Optional, Float64) Proportion. + +The `areas` object of `rule` supports the following: + +* `country` - (Required, String) In addition to standard countries, the country also supports two special identifiers: domestic and foreign. +* `city` - (Optional, String) City. +* `region` - (Optional, String) Province. + +The `cron` object of `job_date_time` supports the following: + +* `days` - (Optional, Set) On what day of each month is it executed. +* `end_time` - (Optional, String) End time. +* `start_time` - (Optional, String) Start time. +* `w_days` - (Optional, Set) What day of the week is executed each week. + +The `job_date_time` object of `rule` supports the following: + +* `cron` - (Optional, List) Time parameter for cycle execution. +* `time_t_zone` - (Optional, String) Time zone. +* `timed` - (Optional, List) Time parameter for timed execution. + +The `rule` object of `rule` supports the following: + +* `areas` - (Optional, List) Regional selection. +* `key` - (Optional, String) Key. +* `lang` - (Optional, String) Language environment. +* `name` - (Optional, String) When using header parameter values. +* `op_arg` - (Optional, Set) Optional supplementary parameters. +* `op_op` - (Optional, String) Optional Supplementary Operators. +* `op_value` - (Optional, Float64) Optional supplementary values. +* `op` - (Optional, String) Operator. +* `value` - (Optional, List) Value. + +The `rule` object supports the following: + +* `action` - (Required, String) Disposal action. +* `domain` - (Required, String) Domain. +* `label` - (Required, String) Label. +* `name` - (Required, String) Rule name. +* `on_off` - (Required, String) Rule switch. +* `prior` - (Required, Int) Rule priority. +* `rule_type` - (Required, Int) Rule type. +* `rule` - (Required, List) Specific rule items of UCB. +* `action_list` - (Optional, List) When Action=intercept, this field is mandatory. +* `addition_arg` - (Optional, String) Additional parameters. +* `appid` - (Optional, Int) Appid. +* `block_page_id` - (Optional, Int) Customize interception page ID. +* `desc` - (Optional, String) Rule description. +* `expire_time` - (Optional, Int) Effective deadline. +* `id` - (Optional, String) Entry ID. +* `job_date_time` - (Optional, List) Scheduled task configuration. +* `job_type` - (Optional, String) Scheduled task type. +* `pre_define` - (Optional, Bool) True - System preset rules False - Custom rules. +* `scene_id` - (Optional, String) Scene ID. +* `valid_status` - (Optional, Int) Effective -1, Invalid -0. +* `valid_time` - (Optional, Int) Valid time. + +The `timed` object of `job_date_time` supports the following: + +* `end_date_time` - (Optional, Int) End timestamp, in seconds. +* `start_date_time` - (Optional, Int) Start timestamp, in seconds. + +The `value` object of `rule` supports the following: + +* `basic_value` - (Optional, String) String type value. +* `belong_value` - (Optional, Set) String array type value. +* `logic_value` - (Optional, Bool) Bool type value. +* `multi_value` - (Optional, Set) String array type value. +* `valid_key` - (Optional, String) Indicate valid fields. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - ID of the resource. +* `rule_id` - Rule ID. + + +## Import + +WAF bot scene ucb rule can be imported using the id, e.g. + +``` +terraform import tencentcloud_waf_bot_scene_ucb_rule.example examle.com#3000000791#3000003489 +``` + diff --git a/website/tencentcloud.erb b/website/tencentcloud.erb index fccd1f0e2e..5b69b00cb5 100644 --- a/website/tencentcloud.erb +++ b/website/tencentcloud.erb @@ -6832,6 +6832,9 @@
  • tencentcloud_waf_bot_scene_status_config
  • +
  • + tencentcloud_waf_bot_scene_ucb_rule +
  • tencentcloud_waf_bot_status_config