Skip to content

Commit 9df7a1f

Browse files
resource/alicloud_threat_detection_web_lock_config: add lang and inclusive_file attributes
Add lang and inclusive_file attributes to the resource and data source. Create switches from ModifyWebLockStart to ModifyWebLockCreateConfig which accepts both parameters. Read reads back inclusive_file from DescribeWebLockConfigList.
1 parent 991dbca commit 9df7a1f

6 files changed

Lines changed: 39 additions & 5 deletions

alicloud/data_source_alicloud_threat_detection_web_lock_configs.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ func dataSourceAlicloudThreatDetectionWebLockConfigs() *schema.Resource {
8282
Computed: true,
8383
Type: schema.TypeString,
8484
},
85+
"inclusive_file": {
86+
Computed: true,
87+
Type: schema.TypeString,
88+
},
8589
"inclusive_file_type": {
8690
Computed: true,
8791
Type: schema.TypeString,
@@ -212,6 +216,7 @@ func dataSourceAlicloudThreatDetectionWebLockConfigsRead(d *schema.ResourceData,
212216
mapping["exclusive_dir"] = object["ExclusiveDir"]
213217
mapping["exclusive_file"] = object["ExclusiveFile"]
214218
mapping["exclusive_file_type"] = object["ExclusiveFileType"]
219+
mapping["inclusive_file"] = object["InclusiveFile"]
215220
mapping["inclusive_file_type"] = object["InclusiveFileType"]
216221
mapping["local_backup_dir"] = object["LocalBackupDir"]
217222
mapping["mode"] = object["Mode"]

alicloud/data_source_alicloud_threat_detection_web_lock_configs_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
99
)
1010

11-
func TestAccAlicloudThreatDetectionWebLockConfigDataSource(t *testing.T) {
11+
func TestAccAliCloudThreatDetectionWebLockConfigDataSource(t *testing.T) {
1212
rand := acctest.RandIntRange(1000000, 9999999)
1313

1414
idsConf := dataSourceTestAccConfig{
@@ -64,6 +64,7 @@ var existThreatDetectionWebLockConfigMapFunc = func(rand int) map[string]string
6464
"configs.0.exclusive_dir": "",
6565
"configs.0.exclusive_file": "",
6666
"configs.0.exclusive_file_type": "",
67+
"configs.0.inclusive_file": "/tmp/include.txt",
6768
"configs.0.inclusive_file_type": "php;jsp;asp;aspx;js;cgi;html;htm;xml;shtml;shtm;jpg",
6869
"configs.0.local_backup_dir": "/usr/local/aegis/bak",
6970
"configs.0.mode": "whitelist",
@@ -100,6 +101,8 @@ data "alicloud_threat_detection_assets" "default" {
100101
101102
resource "alicloud_threat_detection_web_lock_config" "default" {
102103
inclusive_file_type = "php;jsp;asp;aspx;js;cgi;html;htm;xml;shtml;shtm;jpg"
104+
inclusive_file = "/tmp/include.txt"
105+
lang = "zh"
103106
uuid = data.alicloud_threat_detection_assets.default.ids.0
104107
mode = "whitelist"
105108
local_backup_dir = "/usr/local/aegis/bak"

alicloud/resource_alicloud_threat_detection_web_lock_config.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ func resourceAlicloudThreatDetectionWebLockConfig() *schema.Resource {
4646
ForceNew: true,
4747
Type: schema.TypeString,
4848
},
49+
"inclusive_file": {
50+
Optional: true,
51+
ForceNew: true,
52+
Type: schema.TypeString,
53+
},
4954
"inclusive_file_type": {
5055
Optional: true,
5156
ForceNew: true,
@@ -56,6 +61,12 @@ func resourceAlicloudThreatDetectionWebLockConfig() *schema.Resource {
5661
ForceNew: true,
5762
Type: schema.TypeString,
5863
},
64+
"lang": {
65+
Optional: true,
66+
Computed: true,
67+
ForceNew: true,
68+
Type: schema.TypeString,
69+
},
5970
"mode": {
6071
Required: true,
6172
ForceNew: true,
@@ -88,15 +99,21 @@ func resourceAlicloudThreatDetectionWebLockConfigCreate(d *schema.ResourceData,
8899
if v, ok := d.GetOk("exclusive_file_type"); ok {
89100
request["ExclusiveFileType"] = v
90101
}
102+
if v, ok := d.GetOk("inclusive_file"); ok {
103+
request["InclusiveFile"] = v
104+
}
91105
if v, ok := d.GetOk("inclusive_file_type"); ok {
92106
request["InclusiveFileType"] = v
93107
}
108+
if v, ok := d.GetOk("lang"); ok {
109+
request["Lang"] = v
110+
}
94111
request["LocalBackupDir"] = d.Get("local_backup_dir")
95112
request["Mode"] = d.Get("mode")
96113
request["Uuid"] = d.Get("uuid")
97114

98115
var response map[string]interface{}
99-
action := "ModifyWebLockStart"
116+
action := "ModifyWebLockCreateConfig"
100117
wait := incrementalWait(3*time.Second, 3*time.Second)
101118
err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutCreate)), func() *resource.RetryError {
102119
resp, err := client.RpcPost("Sas", "2018-12-03", action, nil, request, false)
@@ -139,6 +156,7 @@ func resourceAlicloudThreatDetectionWebLockConfigRead(d *schema.ResourceData, me
139156
d.Set("exclusive_dir", object["ExclusiveDir"])
140157
d.Set("exclusive_file", object["ExclusiveFile"])
141158
d.Set("exclusive_file_type", object["ExclusiveFileType"])
159+
d.Set("inclusive_file", object["InclusiveFile"])
142160
d.Set("inclusive_file_type", object["InclusiveFileType"])
143161
d.Set("local_backup_dir", object["LocalBackupDir"])
144162
d.Set("mode", object["Mode"])

alicloud/resource_alicloud_threat_detection_web_lock_config_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
// Case 1
13-
func TestAccAlicloudThreatDetectionWebLockConfig_basic1875(t *testing.T) {
13+
func TestAccAliCloudThreatDetectionWebLockConfig_basic1875(t *testing.T) {
1414
var v map[string]interface{}
1515
resourceId := "alicloud_threat_detection_web_lock_config.default"
1616
ra := resourceAttrInit(resourceId, AlicloudThreatDetectionWebLockConfigMap1875)
@@ -33,6 +33,8 @@ func TestAccAlicloudThreatDetectionWebLockConfig_basic1875(t *testing.T) {
3333
{
3434
Config: testAccConfig(map[string]interface{}{
3535
"inclusive_file_type": "php;jsp;asp;aspx;js;cgi;html;htm;xml;shtml;shtm;jpg",
36+
"inclusive_file": "/tmp/include.txt",
37+
"lang": "zh",
3638
"uuid": "${data.alicloud_threat_detection_assets.default.ids.0}",
3739
"mode": "whitelist",
3840
"local_backup_dir": "/usr/local/aegis/bak",
@@ -42,6 +44,7 @@ func TestAccAlicloudThreatDetectionWebLockConfig_basic1875(t *testing.T) {
4244
Check: resource.ComposeTestCheckFunc(
4345
testAccCheck(map[string]string{
4446
"inclusive_file_type": "php;jsp;asp;aspx;js;cgi;html;htm;xml;shtml;shtm;jpg",
47+
"inclusive_file": "/tmp/include.txt",
4548
"uuid": CHECKSET,
4649
"mode": "whitelist",
4750
"local_backup_dir": "/usr/local/aegis/bak",
@@ -53,7 +56,7 @@ func TestAccAlicloudThreatDetectionWebLockConfig_basic1875(t *testing.T) {
5356
ResourceName: resourceId,
5457
ImportState: true,
5558
ImportStateVerify: true,
56-
ImportStateVerifyIgnore: []string{},
59+
ImportStateVerifyIgnore: []string{"lang"},
5760
},
5861
},
5962
})

website/docs/d/threat_detection_web_lock_configs.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ The following attributes are exported in addition to the arguments listed above:
4848
* `exclusive_dir` - The directory that has web tamper proofing disabled.
4949
* `exclusive_file` - The file that has web tamper proofing disabled. **Note:** If the value of `mode` is `blacklist`, this parameter is returned.
5050
* `exclusive_file_type` - The type of the file that has web tamper proofing disabled. **Note:** If the value of `mode` is `blacklist`, this parameter is returned.
51+
* `inclusive_file` - The files that have web tamper proofing enabled. **Note:** If the value of `mode` is `whitelist`, this parameter is returned.
5152
* `inclusive_file_type` - The type of the file that has web tamper proofing enabled. **Note:** If the value of `mode` is `whitelist`, this parameter is returned.
5253
* `local_backup_dir` - The local path to the backup files of the protected directory.
5354
* `mode` - The protection mode of web tamper proofing.

website/docs/r/threat_detection_web_lock_config.html.markdown

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ description: |-
1111

1212
Provides a Threat Detection Web Lock Config resource.
1313

14-
For information about Threat Detection Web Lock Config and how to use it, see [What is Web Lock Config](https://www.alibabacloud.com/help/en/security-center/developer-reference/api-sas-2018-12-03-modifyweblockstart).
14+
For information about Threat Detection Web Lock Config and how to use it, see [What is Web Lock Config](https://www.alibabacloud.com/help/en/security-center/developer-reference/api-sas-2018-12-03-modifyweblockcreateconfig).
1515

1616
-> **NOTE:** Available since v1.195.0.
1717

@@ -31,6 +31,8 @@ data "alicloud_threat_detection_assets" "default" {
3131
}
3232
resource "alicloud_threat_detection_web_lock_config" "default" {
3333
inclusive_file_type = "php;jsp;asp;aspx;js;cgi;html;htm;xml;shtml;shtm;jpg"
34+
inclusive_file = "/tmp/include.txt"
35+
lang = "zh"
3436
uuid = data.alicloud_threat_detection_assets.default.ids.0
3537
mode = "whitelist"
3638
local_backup_dir = "/usr/local/aegis/bak"
@@ -49,7 +51,9 @@ The following arguments are supported:
4951
* `exclusive_dir` - (ForceNew,Optional) Specify a directory address that does not require Web tamper protection (I. E. Excluded directories).> The protection Mode **Mode** is set to **blacklist**, you need to configure this parameter.
5052
* `exclusive_file` - (ForceNew,Optional) Specify files that do not need to enable tamper protection for web pages (that is, exclude files).> The protection Mode **Mode** is set to **blacklist**, you need to configure this parameter.
5153
* `exclusive_file_type` - (ForceNew,Optional) Specify the type of file that does not require Web tamper protection (that is, the type of excluded file). When there are multiple file types, use semicolons (;) separation. Value:-php-jsp-asp-aspx-js-cgi-html-htm-xml-shtml-shtm-jpg-gif-png > The protection Mode **Mode** is set to **blacklist**, you need to configure this parameter.
54+
* `inclusive_file` - (ForceNew,Optional) The files that require tamper protection. When the protection mode **Mode** is set to **whitelist**, you need to configure this parameter.
5255
* `inclusive_file_type` - (ForceNew,Optional) Specify the type of file that requires tamper protection. When there are multiple file types, use semicolons (;) separation. Value:-php-jsp-asp-aspx-js-cgi-html-htm-xml-shtml-shtm-jpg-gif-png> The protection Mode **Mode** is set to **whitelist**, you need to configure this parameter.
56+
* `lang` - (ForceNew,Optional,Computed) The language of the content within the request and the response. Valid values: `zh`, `en`.
5357
* `local_backup_dir` - (Required,ForceNew) The local backup path is used to protect the safe backup of the Directory.
5458
* `mode` - (Required,ForceNew) Specify the protected directory mode. Value:-**whitelist**: whitelist mode, which protects the added protected directories and file types.-**blacklist**: blacklist mode, which protects all unexcluded subdirectories, file types, and specified files under the added protection directory.
5559
* `uuid` - (Required,ForceNew) Specify the UUID of the server to which you want to add a protection directory.> You can call the [DescribeCloudCenterInstances](~~ 141932 ~~) interface to obtain the UUID of the server.

0 commit comments

Comments
 (0)