Skip to content

Commit 4cd4f70

Browse files
Add rules_settings resource
1 parent 23c0ff2 commit 4cd4f70

8 files changed

Lines changed: 601 additions & 1 deletion

File tree

docs/resources/rules_settings.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
layout: "wallarm"
3+
page_title: "Wallarm: wallarm_rules_settings"
4+
subcategory: "Common"
5+
description: |-
6+
Provides the resource to manage rules settings of the company.
7+
---
8+
9+
# wallarm_rules_settings
10+
11+
Provides the resource to manage rules settings of the company.
12+
13+
## Duplicates
14+
Every client can have only one wallarm_rules_settings resource.
15+
Unfortunately, terraform doesn't support singleton resources.
16+
Therefore, you must ensure that there is no more than one resource per client in your configuration.
17+
Otherwise, the terraform provider will merge them and send them as one resource. Priority for identical fields will be random.
18+
19+
Let's break down the merge rules using the following configuration:
20+
```hcl
21+
# default client_id = 1
22+
23+
resource "wallarm_rules_settings" "rules_settings1" {
24+
min_lom_format = 50
25+
max_lom_format = 70
26+
}
27+
28+
resource "wallarm_rules_settings" "rules_settings2" {
29+
min_lom_format = 51
30+
max_lom_size = 10000000
31+
}
32+
33+
resource "wallarm_rules_settings" "rules_settings3" {
34+
client_id = 1
35+
min_lom_format = 52
36+
}
37+
38+
resource "wallarm_rules_settings" "rules_settings4" {
39+
client_id = 2
40+
min_lom_format = 53
41+
}
42+
43+
resource "wallarm_rules_settings" "rules_settings5" {
44+
client_id = 2
45+
min_lom_format = 54
46+
}
47+
48+
resource "wallarm_rules_settings" "rules_settings6" {
49+
client_id = 3
50+
min_lom_format = 55
51+
}
52+
```
53+
54+
The provider will merge them inside and the final configuration will be equivalent to:
55+
```hcl
56+
# based on rules_settings1, rules_settings2 and rules_settings3
57+
resource "wallarm_rules_settings" "new_rules_settings1" {
58+
client_id = 1
59+
min_lom_format = 51 # random value from 50, 51, 52
60+
max_lom_format = 70
61+
max_lom_size = 10000000
62+
}
63+
64+
# based on rules_settings3 and rules_settings4
65+
resource "wallarm_rules_settings" "new_rules_settings2" {
66+
client_id = 2
67+
min_lom_format = 52 # random value from 52, 53
68+
}
69+
70+
resource "wallarm_rules_settings" "rules_settings5" {
71+
client_id = 3
72+
min_lom_format = 55
73+
}
74+
```
75+
76+
## Example Usage
77+
78+
```hcl
79+
# Configure rules settings
80+
81+
resource "wallarm_rules_settings" "rules_settings" {
82+
client_id = 123
83+
min_lom_format = 50
84+
max_lom_format = 54
85+
max_lom_size = 10240
86+
lom_disabled = false
87+
lom_compilation_delay = 0
88+
rules_snapshot_enabled = true
89+
rules_snapshot_max_count = 5
90+
rules_manipulation_locked = false
91+
heavy_lom = false
92+
parameters_count_weight = 6
93+
path_variativity_weight = 6
94+
pii_weight = 8
95+
request_content_weight = 6
96+
open_vulns_weight = 9
97+
serialized_data_weight = 6
98+
risk_score_algo = "maximum"
99+
pii_fallback = false
100+
}
101+
```
102+
103+
## Argument Reference
104+
105+
* `client_id` - (optional) ID of the client which is a partner for the created tenant. By default, this argument has the value of the current client ID.
106+
* `min_lom_format` - (optional) Minimal Custom Ruleset format that will be compiled.
107+
* `max_lom_format` - (optional) Maximum Custom Ruleset format that will be compiled.
108+
* `max_lom_size` - (optional) Maximum size of Custom Ruleset size in bytes.
109+
* `lom_disabled` - (optional) Field determining whether Custom Ruleset is compiled.
110+
* `lom_compilation_delay` - (optional) Delay before Custom Ruleset compilition.
111+
* `rules_snapshot_enabled` - (optional) Field determining whether rules snapshots are created during Custom Ruleset compilation.
112+
* `rules_snapshot_max_count` - (optional) Maximum count of rules snapshot stored in wallarm.
113+
* `rules_manipulation_locked` - (optional) Field determining whether rules might changed.
114+
* `heavy_lom` - (optional) Field determining whether Custom Ruleset is compiled in special queue for huge rulesets.
115+
* `parameters_count_weight` - (optional) [Risk Score][1] weight of query and body parameters. The more parameters, the more potential malicious payloads.
116+
* `path_variativity_weight` - (optional) [Risk Score][1] weight of potential vulnerabilites to BOLA. Variable path parts make the endpoint a potential target of BOLA (IDOR) attacks.
117+
* `pii_weight` - (optional) [Risk Score][1] weight of parameters with sensitive data. Parameters with sensitive data are always at risk of exposure.
118+
* `request_content_weight` - (optional) [Risk Score][1] weight of uploading files to server. Attackers may be able to attack servers by uploading files containing malicious code.
119+
* `open_vulns_weight` - (optional) [Risk Score][1] weight of active vulnerabilities. Active vulnerabilities may result in unauthorized data access or corruption.
120+
* `serialized_data_weight` - (optional) [Risk Score][1] weight of accepting XML / JSON objects. XML / JSON objects are often used to transfer malicious payloads to attack servers.
121+
* `risk_score_algo` - (optional) Method of [Risk Score][1] calulation. Specify how the risk score calculation should be performed. Available values: maximum, average.
122+
* `pii_fallback` - (optional) Field determining whether fallback mechanism for PII detection is active.
123+
124+
[1]: https://docs.wallarm.com/api-discovery/overview/#endpoint-risk-score

examples/dev/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ provider "wallarm" {
3636
# name = "Tenant"
3737
# }
3838

39+
# # Rules settings section
40+
# #
41+
# resource "wallarm_rules_settings" "rules_settings" {
42+
# min_lom_format = 51
43+
# }
3944

4045
# #
4146
# # Denylist section

examples/wallarm_rules_settings.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
resource "wallarm_rules_settings" "rules_settings" {
2+
client_id = 123
3+
min_lom_format = 50
4+
max_lom_format = 54
5+
max_lom_size = 10240
6+
lom_disabled = false
7+
lom_compilation_delay = 0
8+
rules_snapshot_enabled = true
9+
rules_snapshot_max_count = 5
10+
rules_manipulation_locked = false
11+
heavy_lom = false
12+
parameters_count_weight = 6
13+
path_variativity_weight = 6
14+
pii_weight = 8
15+
request_content_weight = 6
16+
open_vulns_weight = 9
17+
serialized_data_weight = 6
18+
risk_score_algo = "maximum"
19+
pii_fallback = false
20+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/hashicorp/go-cleanhttp v0.5.1
88
github.com/hashicorp/terraform-plugin-sdk v1.16.0
99
github.com/pkg/errors v0.9.1
10-
github.com/wallarm/wallarm-go v0.1.0
10+
github.com/wallarm/wallarm-go v0.2.0
1111
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985 // indirect
1212
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
1313
golang.org/x/tools v0.1.5 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ github.com/wallarm/wallarm-go v0.0.26 h1:tiLMBfDMcR60Zy6PENJOXQfOQu7x0fQJFEXtdjs
314314
github.com/wallarm/wallarm-go v0.0.26/go.mod h1:KQxO+EBaGpIgOqBoByKW4KNMEJFgkxR64FSiA4U/52I=
315315
github.com/wallarm/wallarm-go v0.1.0 h1:0jHuG1P2/KBG+AG7u/dNcZgziqIdUbtfKL0FDQoi1s8=
316316
github.com/wallarm/wallarm-go v0.1.0/go.mod h1:KQxO+EBaGpIgOqBoByKW4KNMEJFgkxR64FSiA4U/52I=
317+
github.com/wallarm/wallarm-go v0.2.0 h1:2SzR3o+Z+P7r9eBwQNSYDi7bDTZAPq0VK+cz6Hz3Vys=
318+
github.com/wallarm/wallarm-go v0.2.0/go.mod h1:KQxO+EBaGpIgOqBoByKW4KNMEJFgkxR64FSiA4U/52I=
317319
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
318320
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
319321
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

wallarm/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func Provider() terraform.ResourceProvider {
143143
"wallarm_rule_bruteforce_counter": resourceWallarmBruteForceCounter(),
144144
"wallarm_rule_dirbust_counter": resourceWallarmDirbustCounter(),
145145
"wallarm_rule_uploads": resourceWallarmUploads(),
146+
"wallarm_rules_settings": resourceWallarmRulesSettings(),
146147
"wallarm_tenant": resourceWallarmTenant(),
147148
},
148149
}

0 commit comments

Comments
 (0)