/
waf_overrides.go
93 lines (86 loc) · 3.29 KB
/
waf_overrides.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package services
import (
"context"
"github.com/cloudquery/cloudquery/plugins/source/cloudflare/client"
"github.com/cloudquery/cq-provider-sdk/provider/diag"
"github.com/cloudquery/cq-provider-sdk/provider/schema"
)
//go:generate cq-gen --resource waf_overrides --config waf.hcl --output .
func WafOverrides() *schema.Table {
return &schema.Table{
Name: "cloudflare_waf_overrides",
Description: "WAFOverride represents a WAF override.",
Resolver: fetchWafOverrides,
Multiplex: client.ZoneMultiplex,
DeleteFilter: client.DeleteAccountZoneFilter,
Options: schema.TableCreationOptions{PrimaryKeys: []string{"id"}},
Columns: []schema.Column{
{
Name: "account_id",
Description: "The Account ID of the resource.",
Type: schema.TypeString,
Resolver: client.ResolveAccountId,
},
{
Name: "zone_id",
Description: "The Zone ID of the resource.",
Type: schema.TypeString,
Resolver: client.ResolveZoneId,
},
{
Name: "id",
Description: "The unique identifier of the WAF override.",
Type: schema.TypeString,
Resolver: schema.PathResolver("ID"),
},
{
Name: "description",
Description: "An informative summary of the current URI-based WAF override.",
Type: schema.TypeString,
},
{
Name: "url_s",
Type: schema.TypeStringArray,
Resolver: schema.PathResolver("URLs"),
},
{
Name: "priority",
Description: "The relative priority of the current URI-based WAF override when multiple overrides match a single URL. A lower number indicates higher priority. Higher priority overrides may overwrite values set by lower priority overrides.",
Type: schema.TypeBigInt,
},
{
Name: "groups",
Description: "An object that allows you to enable or disable WAF rule groups for the current WAF override. Each key of this object must be the ID of a WAF rule group, and each value must be a valid WAF action (usually default or disable). When creating a new URI-based WAF override, you must provide a groups object or a rules object.",
Type: schema.TypeJSON,
},
{
Name: "rewrite_action",
Description: "Specifies that, when a WAF rule matches, its configured action will be replaced by the action configured in this object.",
Type: schema.TypeJSON,
},
{
Name: "rules",
Description: "The default action performed by the rules in the WAF package.",
Type: schema.TypeJSON,
},
{
Name: "paused",
Description: "When true, indicates that the WAF package is currently paused.",
Type: schema.TypeBool,
},
},
}
}
// ====================================================================================================================
// Table Resolver Functions
// ====================================================================================================================
func fetchWafOverrides(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
svc := meta.(*client.Client)
zoneId := svc.ZoneId
resp, err := svc.ClientApi.ListWAFOverrides(ctx, zoneId)
if err != nil {
return diag.WrapError(err)
}
res <- resp
return nil
}