Skip to content

Commit 364385f

Browse files
authored
Merge pull request #89 from wallarm/feat/api-discovery
Feat/api discovery
2 parents fbef8c4 + 976666a commit 364385f

9 files changed

Lines changed: 906 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## [Unreleased]
22

3+
### New Features
4+
5+
* **`wallarm_api_discovery_config`** — singleton resource managing the API Discovery configuration (Settings → API Discovery). Editable: enabled flag, protocols (REST/GraphQL/SOAP/GRPC/MCP), content-type filter, endpoint-stability thresholds, parameter-type and PII detection thresholds, disabled-apps list. Read-only attributes mirror the rest of the API response for drift visibility. Bumps `wallarm-go` to add `APIDiscovery` interface.
6+
37
### Bug Fixes
48

59
* **`data.wallarm_hits`: emit `instance` condition for default-app (poolID=-1) hits** — fixes 4-vs-5 condition hash mismatch on instance-included API clients.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ Request-level rules for detection tuning, virtual patching, and data handling. T
169169
| `wallarm_rules_settings` | Rules engine settings |
170170
| `wallarm_api_spec` | API specification management |
171171
| `wallarm_api_spec_policy` | API Specification Enforcement policy attached to an uploaded spec |
172+
| `wallarm_api_discovery_config` | API Discovery configuration (singleton per tenant) |
172173
| `wallarm_action` | Rule action scope tracking |
173174
| `wallarm_rule_generator` | Generate HCL config files from hits or existing API rules |
174175
| `wallarm_hits_index` | Track fetched request IDs for the [hits-to-rules workflow](docs/guides/hits_to_rules.md) |
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
layout: "wallarm"
3+
page_title: "Wallarm: wallarm_api_discovery_config"
4+
subcategory: "API Discovery"
5+
description: |-
6+
Manages the per-tenant API Discovery configuration.
7+
---
8+
9+
# wallarm_api_discovery_config
10+
11+
Manages the [API Discovery][1] configuration for a Wallarm tenant — the settings page in the console under **Settings → API Discovery**: the master toggle, which protocols to analyse, request-content filtering, endpoint-stability thresholds, parameter-type and PII detection thresholds, and the per-application include/exclude list.
12+
13+
API Discovery configuration is a **singleton per `client_id`** — the record always exists on the server. Declaring two `wallarm_api_discovery_config` resources for the same client will conflict (each apply overwrites the previous).
14+
15+
## Example Usage
16+
17+
```hcl
18+
resource "wallarm_api_discovery_config" "this" {
19+
enabled = true
20+
apply_extended_filter = true
21+
type_detection_threshold = 0.5
22+
pii_detection_threshold = 0.1
23+
disabled_apps = []
24+
25+
protocols {
26+
rest = true
27+
graphql = true
28+
soap = true
29+
grpc = true
30+
mcp = true
31+
}
32+
33+
endpoint_stability {
34+
min_count = 2
35+
min_time = 300
36+
}
37+
}
38+
```
39+
40+
Multi-tenant:
41+
42+
```hcl
43+
resource "wallarm_api_discovery_config" "tenant_a" {
44+
client_id = 22510
45+
enabled = true
46+
}
47+
```
48+
49+
## Argument Reference
50+
51+
### General
52+
53+
* `client_id` - (Optional, ForceNew) Client ID. Defaults to the provider's client ID.
54+
* `enabled` - (Optional, Default: `true`) Master toggle for API Discovery.
55+
56+
### Protocols
57+
58+
A `protocols` block configures which protocols API Discovery analyses. The block is `Optional` — omitting it enables all five.
59+
60+
* `rest` - (Optional, Default: `true`)
61+
* `graphql` - (Optional, Default: `true`)
62+
* `soap` - (Optional, Default: `true`)
63+
* `grpc` - (Optional, Default: `true`)
64+
* `mcp` - (Optional, Default: `true`)
65+
66+
### Filtering
67+
68+
* `apply_extended_filter` - (Optional, Default: `true`) Filter endpoints by response content type.
69+
* `disabled_apps` - (Optional) List of pool/application IDs to exclude from API Discovery. Default: empty list.
70+
71+
### Detection thresholds
72+
73+
Fractions in the `[0.0, 1.0]` range (the console displays them as percentages).
74+
75+
* `type_detection_threshold` - (Optional, Default: `0.5`) Fraction of requests used to determine parameter types.
76+
* `pii_detection_threshold` - (Optional, Default: `0.1`) Fraction of requests used to detect sensitive data.
77+
78+
### Endpoint stability
79+
80+
An `endpoint_stability` block defines when a newly observed endpoint is promoted to the discovered inventory.
81+
82+
* `min_count` - (Optional, Default: `2`, Range: `1–100`) Minimum number of requests.
83+
* `min_time` - (Optional, Default: `300`, Range: `1–900`) Minimum time window in seconds.
84+
85+
## Attributes Reference
86+
87+
In addition to the arguments above, the following read-only attributes are populated from the API on Read:
88+
89+
* `call_points_storage_limit` - Storage limit for call points.
90+
* `group_soap` - Whether SOAP endpoints are grouped under a parent definition.
91+
* `allowed_content_types_patterns` - Content-type patterns considered for discovery.
92+
* `sensitive_samples` - Sample-masking configuration (block): `enabled`, `min_masked`, `max_masked`, `mask_symbols`.
93+
* `server_variability` - Server-variability heuristics (block): `enabled`, `by_date_enabled`, `by_local_code_enabled`, `by_email_enabled`, `by_alphanumeric_id_enabled`; nested `by_custom_paths` sub-block with `enabled` and `paths`.
94+
* `extensions_whitelist` - File-extension allowlist (block): `enabled`, `extensions`.
95+
96+
These mirror the API's full response shape but cannot be set via Terraform — they're surfaced for drift visibility.
97+
98+
## Import
99+
100+
```bash
101+
terraform import wallarm_api_discovery_config.this 22510/apid_config
102+
```
103+
104+
The import ID format is `{client_id}/apid_config`. The suffix is constant; the `client_id` prefix identifies the tenant.
105+
106+
Deleting the resource from Terraform state is a noop — the singleton record persists on the server. To restore defaults, set the schema's Optional+Default values explicitly in HCL and `terraform apply`.
107+
108+
[1]: https://docs.wallarm.com/api-discovery/overview/
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
terraform {
2+
required_providers {
3+
wallarm = {
4+
source = "wallarm/wallarm"
5+
}
6+
}
7+
}
8+
9+
provider "wallarm" {
10+
api_token = var.wallarm_api_token
11+
api_host = var.wallarm_api_host
12+
}
13+
14+
variable "wallarm_api_token" {
15+
type = string
16+
sensitive = true
17+
}
18+
19+
variable "wallarm_api_host" {
20+
type = string
21+
default = "https://api.wallarm.com"
22+
}
23+
24+
# Singleton per client_id. Settings → API Discovery in the console.
25+
resource "wallarm_api_discovery_config" "this" {
26+
enabled = true
27+
apply_extended_filter = true
28+
type_detection_threshold = 0.5
29+
pii_detection_threshold = 0.1
30+
disabled_apps = []
31+
32+
protocols {
33+
rest = true
34+
graphql = true
35+
soap = true
36+
grpc = true
37+
mcp = true
38+
}
39+
40+
endpoint_stability {
41+
min_count = 2
42+
min_time = 300
43+
}
44+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/hashicorp/terraform-plugin-sdk/v2 v2.39.0
1111
github.com/pkg/errors v0.9.1
1212
github.com/samber/lo v1.51.0
13-
github.com/wallarm/wallarm-go v0.12.2
13+
github.com/wallarm/wallarm-go v0.13.0
1414
github.com/zclconf/go-cty v1.17.0
1515
)
1616

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IU
157157
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
158158
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
159159
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
160-
github.com/wallarm/wallarm-go v0.12.2 h1:Yb0QVuMzBUWTn48MLxh/JQIUReQuFFVxJSsKualJqUk=
161-
github.com/wallarm/wallarm-go v0.12.2/go.mod h1:yqZcNkOdSXL7K0CXRDJ3WyjyjDOHyk41iAv9fXsFP8o=
160+
github.com/wallarm/wallarm-go v0.13.0 h1:k3PYKl+DiD6hIg2K/Y0n+c+Ky08IQzFx/Wvymg1a7sM=
161+
github.com/wallarm/wallarm-go v0.13.0/go.mod h1:yqZcNkOdSXL7K0CXRDJ3WyjyjDOHyk41iAv9fXsFP8o=
162162
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
163163
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
164164
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=

wallarm/provider/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ func Provider() *schema.Provider {
132132
"wallarm_node": resourceWallarmNode(),
133133
"wallarm_application": resourceWallarmApp(),
134134
"wallarm_user": resourceWallarmUser(),
135+
"wallarm_api_discovery_config": resourceWallarmAPIDiscoveryConfig(),
135136
"wallarm_api_spec": resourceWallarmAPISpec(),
136137
"wallarm_api_spec_policy": resourceWallarmAPISpecPolicy(),
137138
"wallarm_denylist": resourceWallarmDenylist(),

0 commit comments

Comments
 (0)