Documentation
¶
Index ¶
- Constants
- Variables
- type APIKey
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Snapshot(ctx context.Context) []byte
- type IPSet
- type InMemoryBackend
- func (b *InMemoryBackend) AccountID() string
- func (b *InMemoryBackend) AssociateWebACL(ctx context.Context, webACLARN, resourceARN string) error
- func (b *InMemoryBackend) CheckCapacity(ctx context.Context, _ string, rules []map[string]any) (int64, error)
- func (b *InMemoryBackend) CreateAPIKey(ctx context.Context, scope string, tokenDomains []string) (*APIKey, error)
- func (b *InMemoryBackend) CreateIPSet(ctx context.Context, name, scope, description, ipAddressVersion string, ...) (*IPSet, error)
- func (b *InMemoryBackend) CreateRegexPatternSet(ctx context.Context, name, scope, description string, ...) (*RegexPatternSet, error)
- func (b *InMemoryBackend) CreateRuleGroup(ctx context.Context, name, scope, description, visibilityConfig string, ...) (*RuleGroup, error)
- func (b *InMemoryBackend) CreateWebACL(ctx context.Context, name, scope, description string, ...) (*WebACL, error)
- func (b *InMemoryBackend) DeleteAPIKey(ctx context.Context, scope, apiKey string) error
- func (b *InMemoryBackend) DeleteFirewallManagerRuleGroups(ctx context.Context, webACLARN string) (*WebACL, error)
- func (b *InMemoryBackend) DeleteIPSet(ctx context.Context, id, lockToken string) error
- func (b *InMemoryBackend) DeleteLoggingConfiguration(ctx context.Context, resourceARN string) error
- func (b *InMemoryBackend) DeletePermissionPolicy(ctx context.Context, resourceARN string) error
- func (b *InMemoryBackend) DeleteRegexPatternSet(ctx context.Context, id, lockToken string) error
- func (b *InMemoryBackend) DeleteRuleGroup(ctx context.Context, id, lockToken string) error
- func (b *InMemoryBackend) DeleteWebACL(ctx context.Context, id, lockToken string) error
- func (b *InMemoryBackend) DisassociateWebACL(ctx context.Context, resourceARN string) error
- func (b *InMemoryBackend) GetDecryptedAPIKey(ctx context.Context, scope, apiKey string) (*APIKey, error)
- func (b *InMemoryBackend) GetIPSet(ctx context.Context, id string) (*IPSet, error)
- func (b *InMemoryBackend) GetLoggingConfiguration(ctx context.Context, resourceARN string) (json.RawMessage, error)
- func (b *InMemoryBackend) GetManagedRuleSet(ctx context.Context, id string) (*ManagedRuleSet, error)
- func (b *InMemoryBackend) GetPermissionPolicy(ctx context.Context, resourceARN string) (string, error)
- func (b *InMemoryBackend) GetRegexPatternSet(ctx context.Context, id string) (*RegexPatternSet, error)
- func (b *InMemoryBackend) GetRuleGroup(ctx context.Context, id string) (*RuleGroup, error)
- func (b *InMemoryBackend) GetWebACL(ctx context.Context, id string) (*WebACL, error)
- func (b *InMemoryBackend) GetWebACLForResource(ctx context.Context, resourceARN string) (*WebACL, error)
- func (b *InMemoryBackend) IPSetARN(name, id, scope string) string
- func (b *InMemoryBackend) ListAPIKeys(ctx context.Context, scope string) []*APIKey
- func (b *InMemoryBackend) ListIPSets(ctx context.Context) []*IPSet
- func (b *InMemoryBackend) ListLoggingConfigurations(ctx context.Context) []json.RawMessage
- func (b *InMemoryBackend) ListManagedRuleSets(ctx context.Context, scope string) []*ManagedRuleSet
- func (b *InMemoryBackend) ListRegexPatternSets(ctx context.Context) []*RegexPatternSet
- func (b *InMemoryBackend) ListResourcesForWebACL(ctx context.Context, webACLARN string) ([]string, error)
- func (b *InMemoryBackend) ListRuleGroups(ctx context.Context) []*RuleGroup
- func (b *InMemoryBackend) ListTagsForResource(_ context.Context, resourceARN string) (map[string]string, error)
- func (b *InMemoryBackend) ListWebACLs(ctx context.Context) []*WebACL
- func (b *InMemoryBackend) ManagedRuleSetARN(name, id, scope string) string
- func (b *InMemoryBackend) PutLoggingConfiguration(ctx context.Context, resourceARN string, configJSON json.RawMessage) error
- func (b *InMemoryBackend) PutManagedRuleSetVersions(ctx context.Context, id, name, scope, lockToken, recommendedVersion string, ...) (*ManagedRuleSet, error)
- func (b *InMemoryBackend) PutPermissionPolicy(ctx context.Context, resourceARN, policy string) error
- func (b *InMemoryBackend) RegexPatternSetARN(name, id, scope string) string
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) RuleGroupARN(name, id, scope string) string
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) TagResource(_ context.Context, resourceARN string, tags map[string]string) error
- func (b *InMemoryBackend) TaggedResources() []TaggedEntry
- func (b *InMemoryBackend) UntagResource(_ context.Context, resourceARN string, tagKeys []string) error
- func (b *InMemoryBackend) UpdateIPSet(ctx context.Context, id, description, lockToken string, addresses []string) (*IPSet, error)
- func (b *InMemoryBackend) UpdateManagedRuleSetVersionExpiryDate(ctx context.Context, id, lockToken, versionToExpire string, ...) (*ManagedRuleSet, error)
- func (b *InMemoryBackend) UpdateRegexPatternSet(ctx context.Context, id, description, lockToken string, ...) (*RegexPatternSet, error)
- func (b *InMemoryBackend) UpdateRuleGroup(ctx context.Context, id, description, visibilityConfig, lockToken string, ...) (*RuleGroup, error)
- func (b *InMemoryBackend) UpdateWebACL(ctx context.Context, id, description, lockToken string, ...) (*WebACL, error)
- func (b *InMemoryBackend) WebACLARN(name, id, scope string) string
- type ManagedRuleSet
- type ManagedRuleSetVersion
- type Provider
- type RegexEntry
- type RegexPatternSet
- type RuleGroup
- type StorageBackend
- type TaggedEntry
- type VisibilityConfig
- type WebACL
Constants ¶
const ( // ScopeRegional is the REGIONAL WAFv2 scope. ScopeRegional = "REGIONAL" // ScopeCloudFront is the CLOUDFRONT WAFv2 scope. ScopeCloudFront = "CLOUDFRONT" // IPVersionIPv4 is the IPV4 address version. IPVersionIPv4 = "IPV4" // IPVersionIPv6 is the IPV6 address version. IPVersionIPv6 = "IPV6" )
Variables ¶
var ( // ErrWebACLNotFound is returned when a WebACL does not exist. ErrWebACLNotFound = awserr.New("WAFNonexistentItemException", awserr.ErrNotFound) // ErrWebACLAlreadyExists is returned when a WebACL with the same name already exists. ErrWebACLAlreadyExists = awserr.New("WAFDuplicateItemException", awserr.ErrConflict) // ErrIPSetNotFound is returned when an IPSet does not exist. ErrIPSetNotFound = awserr.New("WAFNonexistentItemException", awserr.ErrNotFound) // ErrIPSetAlreadyExists is returned when an IPSet with the same name already exists. ErrIPSetAlreadyExists = awserr.New("WAFDuplicateItemException", awserr.ErrConflict) // ErrAssociationNotFound is returned when a WebACL association does not exist. ErrAssociationNotFound = awserr.New("WAFNonexistentItemException", awserr.ErrNotFound) // ErrRegexPatternSetNotFound is returned when a RegexPatternSet does not exist. ErrRegexPatternSetNotFound = awserr.New("WAFNonexistentItemException", awserr.ErrNotFound) // ErrRegexPatternSetAlreadyExists is returned when a RegexPatternSet with the same name already exists. ErrRegexPatternSetAlreadyExists = awserr.New("WAFDuplicateItemException", awserr.ErrConflict) // ErrRuleGroupNotFound is returned when a RuleGroup does not exist. ErrRuleGroupNotFound = awserr.New("WAFNonexistentItemException", awserr.ErrNotFound) // ErrRuleGroupAlreadyExists is returned when a RuleGroup with the same name already exists. ErrRuleGroupAlreadyExists = awserr.New("WAFDuplicateItemException", awserr.ErrConflict) // ErrAPIKeyNotFound is returned when an API key does not exist. ErrAPIKeyNotFound = awserr.New("WAFNonexistentItemException", awserr.ErrNotFound) // ErrLoggingConfigNotFound is returned when a logging configuration does not exist. ErrLoggingConfigNotFound = awserr.New("WAFNonexistentItemException", awserr.ErrNotFound) // ErrPermissionPolicyNotFound is returned when a permission policy does not exist. ErrPermissionPolicyNotFound = awserr.New("WAFNonexistentItemException", awserr.ErrNotFound) // ErrOptimisticLock is returned when the LockToken does not match. ErrOptimisticLock = awserr.New("WAFOptimisticLockException", awserr.ErrConflict) // ErrAssociatedItem is returned when a resource is referenced by another resource. ErrAssociatedItem = awserr.New("WAFAssociatedItemException", awserr.ErrConflict) // ErrLimitsExceeded is returned when a resource limit is exceeded. ErrLimitsExceeded = awserr.New("WAFLimitsExceededException", awserr.ErrConflict) // ErrInvalidOperation is returned when an operation is invalid. ErrInvalidOperation = awserr.New("WAFInvalidOperationException", awserr.ErrInvalidParameter) ErrUnavailableEntity = awserr.New("WAFUnavailableEntityException", awserr.ErrConflict) // ErrTagOperation is returned when a tag operation fails validation. ErrTagOperation = awserr.New("WAFTagOperationException", awserr.ErrInvalidParameter) // ErrConfigurationWarning is returned when there is a configuration warning. ErrConfigurationWarning = awserr.New("WAFConfigurationWarningException", awserr.ErrInvalidParameter) // ErrManagedRuleSetNotFound is returned when a managed rule set does not exist. ErrManagedRuleSetNotFound = awserr.New("WAFNonexistentItemException", awserr.ErrNotFound) // ErrMobileSdkReleaseNotFound is returned when a mobile SDK release is not in the catalog. ErrMobileSdkReleaseNotFound = awserr.New("WAFNonexistentItemException", awserr.ErrNotFound) // ErrManagedRuleGroupNotFound is returned when a managed rule group is not in the catalog. ErrManagedRuleGroupNotFound = awserr.New("WAFNonexistentItemException", awserr.ErrNotFound) )
var ErrNilAppContext = errors.New("wafv2: nil AppContext")
ErrNilAppContext is returned when the AppContext passed to Init is nil.
Functions ¶
This section is empty.
Types ¶
type APIKey ¶
type APIKey struct {
APIKeyValue string `json:"apiKey"`
Scope string `json:"scope"`
// Region is the store.Table[APIKey] key material replacing the old
// map[region]map[key]*APIKey nesting: the region bucket the key was
// created under (storeRegion-normalized -- see CreateAPIKey). Tagged
// json:"-" and round-tripped via persistence.go's apiKeySnapshot DTO,
// mirroring ManagedRuleSet.Region.
Region string `json:"-"`
TokenDomains []string `json:"tokenDomains,omitempty"`
}
APIKey represents an AWS WAFv2 API key.
type Handler ¶
type Handler struct {
// Backend is the storage interface for WAFv2 operations.
Backend StorageBackend
AccountID string
Region string
// contains filtered or unexported fields
}
Handler is the HTTP handler for the AWS WAFv2 API.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a new WAFv2 handler.
func (*Handler) ChaosOperations ¶
ChaosOperations returns all operations that can be fault-injected.
func (*Handler) ChaosRegions ¶
ChaosRegions returns all regions this handler handles.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase AWS service name for fault rule matching.
func (*Handler) ExtractOperation ¶
ExtractOperation extracts the operation name from the X-Amz-Target header.
func (*Handler) ExtractResource ¶
ExtractResource extracts the resource identifier from the request.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations returns the list of supported WAFv2 operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler function for WAFv2 requests.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) RouteMatcher ¶
RouteMatcher returns a function that matches WAFv2 API requests.
type IPSet ¶
type IPSet struct {
Tags map[string]string `json:"tags,omitempty"`
ARN string `json:"arn,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
Scope string `json:"scope"`
Description string `json:"description"`
IPAddressVersion string `json:"ipAddressVersion"`
LockToken string `json:"lockToken"`
Addresses []string `json:"addresses,omitempty"`
}
IPSet represents an AWS WAFv2 IP Set.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is an in-memory store for WAFv2 resources.
webACLs/ipSets/regexPatternSets/ruleGroups are "clean" store.Table registrations (Phase 3.3 -- see store_setup.go's file doc comment): each replaces what used to be three separate region-nested maps (the primary map[region]map[id]*T, plus map[region]map[arn]string and map[region]map[nameScope]string secondary indexes) with one *store.Table[T] keyed by a region+id composite (see regionKey) and two *store.Index[T] (by ARN, by name+scope) plus one *store.Index[T] grouping by region for List operations. managedRuleSets/apiKeys are "dirty" tables (identity-less: their region-bucket key isn't reliably recoverable from their other fields -- see ManagedRuleSet.Region/APIKey.Region) so they are NOT registered on b.registry; persistence.go round-trips them through a DTO registry instead, mirroring services/ses's pattern.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend creates a new in-memory WAFv2 backend.
func (*InMemoryBackend) AccountID ¶
func (b *InMemoryBackend) AccountID() string
AccountID returns the AWS account ID this backend is configured for.
func (*InMemoryBackend) AssociateWebACL ¶
func (b *InMemoryBackend) AssociateWebACL(ctx context.Context, webACLARN, resourceARN string) error
AssociateWebACL associates a WebACL with a resource ARN.
func (*InMemoryBackend) CheckCapacity ¶
func (b *InMemoryBackend) CheckCapacity(ctx context.Context, _ string, rules []map[string]any) (int64, error)
CheckCapacity returns the total WCU (web ACL capacity unit) cost of the given rules, replicating AWS's real per-statement-type cost model instead of a flat per-rule cost (see the constants block above for sourcing).
func (*InMemoryBackend) CreateAPIKey ¶
func (b *InMemoryBackend) CreateAPIKey(ctx context.Context, scope string, tokenDomains []string) (*APIKey, error)
CreateAPIKey creates a new API key for the given scope and token domains.
func (*InMemoryBackend) CreateIPSet ¶
func (b *InMemoryBackend) CreateIPSet( ctx context.Context, name, scope, description, ipAddressVersion string, addresses []string, tags map[string]string, ) (*IPSet, error)
CreateIPSet creates a new IPSet.
func (*InMemoryBackend) CreateRegexPatternSet ¶
func (b *InMemoryBackend) CreateRegexPatternSet( ctx context.Context, name, scope, description string, regularExpressionList []RegexEntry, tags map[string]string, ) (*RegexPatternSet, error)
CreateRegexPatternSet creates a new RegexPatternSet.
func (*InMemoryBackend) CreateRuleGroup ¶
func (b *InMemoryBackend) CreateRuleGroup( ctx context.Context, name, scope, description, visibilityConfig string, capacity int64, rules []map[string]any, tags map[string]string, ) (*RuleGroup, error)
CreateRuleGroup creates a new RuleGroup.
func (*InMemoryBackend) CreateWebACL ¶
func (b *InMemoryBackend) CreateWebACL( ctx context.Context, name, scope, description string, defaultAction, visibilityConfig json.RawMessage, rules []map[string]any, tokenDomains []string, customResponseBodies, associationConfig, captchaConfig, challengeConfig json.RawMessage, tags map[string]string, ) (*WebACL, error)
CreateWebACL creates a new WebACL.
func (*InMemoryBackend) DeleteAPIKey ¶
func (b *InMemoryBackend) DeleteAPIKey(ctx context.Context, scope, apiKey string) error
DeleteAPIKey deletes the API key identified by scope and key value.
func (*InMemoryBackend) DeleteFirewallManagerRuleGroups ¶
func (b *InMemoryBackend) DeleteFirewallManagerRuleGroups(ctx context.Context, webACLARN string) (*WebACL, error)
DeleteFirewallManagerRuleGroups removes all Firewall Manager rule group associations from the WebACL identified by webACLARN, then returns a fresh copy of the updated WebACL.
func (*InMemoryBackend) DeleteIPSet ¶
func (b *InMemoryBackend) DeleteIPSet(ctx context.Context, id, lockToken string) error
DeleteIPSet deletes an IPSet by ID.
func (*InMemoryBackend) DeleteLoggingConfiguration ¶
func (b *InMemoryBackend) DeleteLoggingConfiguration(ctx context.Context, resourceARN string) error
DeleteLoggingConfiguration removes the logging configuration for the given resource ARN.
func (*InMemoryBackend) DeletePermissionPolicy ¶
func (b *InMemoryBackend) DeletePermissionPolicy(ctx context.Context, resourceARN string) error
DeletePermissionPolicy removes the permission policy for the given resource ARN.
func (*InMemoryBackend) DeleteRegexPatternSet ¶
func (b *InMemoryBackend) DeleteRegexPatternSet(ctx context.Context, id, lockToken string) error
DeleteRegexPatternSet deletes a RegexPatternSet by ID.
func (*InMemoryBackend) DeleteRuleGroup ¶
func (b *InMemoryBackend) DeleteRuleGroup(ctx context.Context, id, lockToken string) error
DeleteRuleGroup deletes a RuleGroup by ID, checking for WebACL references.
func (*InMemoryBackend) DeleteWebACL ¶
func (b *InMemoryBackend) DeleteWebACL(ctx context.Context, id, lockToken string) error
DeleteWebACL deletes a WebACL by ID.
func (*InMemoryBackend) DisassociateWebACL ¶
func (b *InMemoryBackend) DisassociateWebACL(ctx context.Context, resourceARN string) error
DisassociateWebACL removes the WebACL association from a resource ARN. Per AWS behaviour, this is a no-op if no association exists (idempotent).
func (*InMemoryBackend) GetDecryptedAPIKey ¶
func (b *InMemoryBackend) GetDecryptedAPIKey(ctx context.Context, scope, apiKey string) (*APIKey, error)
GetDecryptedAPIKey returns the API key identified by scope and key value.
func (*InMemoryBackend) GetLoggingConfiguration ¶
func (b *InMemoryBackend) GetLoggingConfiguration(ctx context.Context, resourceARN string) (json.RawMessage, error)
GetLoggingConfiguration returns the stored logging configuration JSON for the given resource ARN.
func (*InMemoryBackend) GetManagedRuleSet ¶
func (b *InMemoryBackend) GetManagedRuleSet(ctx context.Context, id string) (*ManagedRuleSet, error)
GetManagedRuleSet returns a ManagedRuleSet by ID.
func (*InMemoryBackend) GetPermissionPolicy ¶
func (b *InMemoryBackend) GetPermissionPolicy(ctx context.Context, resourceARN string) (string, error)
GetPermissionPolicy returns the permission policy for the given resource ARN.
func (*InMemoryBackend) GetRegexPatternSet ¶
func (b *InMemoryBackend) GetRegexPatternSet(ctx context.Context, id string) (*RegexPatternSet, error)
GetRegexPatternSet returns a RegexPatternSet by ID.
func (*InMemoryBackend) GetRuleGroup ¶
GetRuleGroup returns a RuleGroup by ID.
func (*InMemoryBackend) GetWebACLForResource ¶
func (b *InMemoryBackend) GetWebACLForResource(ctx context.Context, resourceARN string) (*WebACL, error)
GetWebACLForResource returns the WebACL associated with the given resource ARN.
func (*InMemoryBackend) IPSetARN ¶
func (b *InMemoryBackend) IPSetARN(name, id, scope string) string
IPSetARN builds a public ARN for an IPSet.
func (*InMemoryBackend) ListAPIKeys ¶
func (b *InMemoryBackend) ListAPIKeys(ctx context.Context, scope string) []*APIKey
ListAPIKeys returns all API keys, optionally filtered by scope.
func (*InMemoryBackend) ListIPSets ¶
func (b *InMemoryBackend) ListIPSets(ctx context.Context) []*IPSet
ListIPSets returns all IPSets sorted by name.
func (*InMemoryBackend) ListLoggingConfigurations ¶
func (b *InMemoryBackend) ListLoggingConfigurations(ctx context.Context) []json.RawMessage
ListLoggingConfigurations returns all stored logging configuration JSONs.
func (*InMemoryBackend) ListManagedRuleSets ¶
func (b *InMemoryBackend) ListManagedRuleSets(ctx context.Context, scope string) []*ManagedRuleSet
ListManagedRuleSets returns all managed rule sets sorted by name, optionally filtered by scope.
func (*InMemoryBackend) ListRegexPatternSets ¶
func (b *InMemoryBackend) ListRegexPatternSets(ctx context.Context) []*RegexPatternSet
ListRegexPatternSets returns all RegexPatternSets sorted by name.
func (*InMemoryBackend) ListResourcesForWebACL ¶
func (b *InMemoryBackend) ListResourcesForWebACL(ctx context.Context, webACLARN string) ([]string, error)
ListResourcesForWebACL returns all resource ARNs associated with the given WebACL ARN.
func (*InMemoryBackend) ListRuleGroups ¶
func (b *InMemoryBackend) ListRuleGroups(ctx context.Context) []*RuleGroup
ListRuleGroups returns all RuleGroups sorted by name.
func (*InMemoryBackend) ListTagsForResource ¶
func (b *InMemoryBackend) ListTagsForResource(_ context.Context, resourceARN string) (map[string]string, error)
ListTagsForResource returns the tags for a WAFv2 resource identified by its ARN.
func (*InMemoryBackend) ListWebACLs ¶
func (b *InMemoryBackend) ListWebACLs(ctx context.Context) []*WebACL
ListWebACLs returns all WebACLs sorted by name. For a REGIONAL request, returns REGIONAL resources from the ctx region PLUS any CLOUDFRONT (global) resources.
func (*InMemoryBackend) ManagedRuleSetARN ¶
func (b *InMemoryBackend) ManagedRuleSetARN(name, id, scope string) string
ManagedRuleSetARN builds an ARN for a ManagedRuleSet.
func (*InMemoryBackend) PutLoggingConfiguration ¶
func (b *InMemoryBackend) PutLoggingConfiguration( ctx context.Context, resourceARN string, configJSON json.RawMessage, ) error
PutLoggingConfiguration stores a full logging configuration JSON for the given resource ARN.
func (*InMemoryBackend) PutManagedRuleSetVersions ¶
func (b *InMemoryBackend) PutManagedRuleSetVersions( ctx context.Context, id, name, scope, lockToken, recommendedVersion string, versionsToPublish map[string]any, ) (*ManagedRuleSet, error)
PutManagedRuleSetVersions creates or updates a managed rule set with the given versions. If the ID does not exist, a new managed rule set is created. If it exists, the lock token is verified before updating.
func (*InMemoryBackend) PutPermissionPolicy ¶
func (b *InMemoryBackend) PutPermissionPolicy(ctx context.Context, resourceARN, policy string) error
PutPermissionPolicy stores a permission policy for the given resource ARN.
func (*InMemoryBackend) RegexPatternSetARN ¶
func (b *InMemoryBackend) RegexPatternSetARN(name, id, scope string) string
RegexPatternSetARN builds an ARN for a RegexPatternSet.
func (*InMemoryBackend) Region ¶
func (b *InMemoryBackend) Region() string
Region returns the AWS region this backend is configured for.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a JSON snapshot.
func (*InMemoryBackend) RuleGroupARN ¶
func (b *InMemoryBackend) RuleGroupARN(name, id, scope string) string
RuleGroupARN builds an ARN for a RuleGroup.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serializes the backend state to JSON.
func (*InMemoryBackend) TagResource ¶
func (b *InMemoryBackend) TagResource(_ context.Context, resourceARN string, tags map[string]string) error
TagResource adds tags to a WAFv2 resource identified by its ARN.
func (*InMemoryBackend) TaggedResources ¶ added in v1.2.0
func (b *InMemoryBackend) TaggedResources() []TaggedEntry
TaggedResources returns every WAFv2 resource ARN that currently has at least one tag, across every taggable WAFv2 resource kind (web ACLs, IP sets, regex pattern sets, rule groups).
func (*InMemoryBackend) UntagResource ¶
func (b *InMemoryBackend) UntagResource(_ context.Context, resourceARN string, tagKeys []string) error
UntagResource removes tags from a WAFv2 resource identified by its ARN.
func (*InMemoryBackend) UpdateIPSet ¶
func (b *InMemoryBackend) UpdateIPSet( ctx context.Context, id, description, lockToken string, addresses []string, ) (*IPSet, error)
UpdateIPSet updates an IPSet by ID.
func (*InMemoryBackend) UpdateManagedRuleSetVersionExpiryDate ¶
func (b *InMemoryBackend) UpdateManagedRuleSetVersionExpiryDate( ctx context.Context, id, lockToken, versionToExpire string, expiryTimestamp *int64, ) (*ManagedRuleSet, error)
UpdateManagedRuleSetVersionExpiryDate updates the expiry timestamp on a specific version of a managed rule set. Returns the updated managed rule set, the expiring version name, and any error.
func (*InMemoryBackend) UpdateRegexPatternSet ¶
func (b *InMemoryBackend) UpdateRegexPatternSet( ctx context.Context, id, description, lockToken string, regularExpressionList []RegexEntry, ) (*RegexPatternSet, error)
UpdateRegexPatternSet updates a RegexPatternSet by ID.
func (*InMemoryBackend) UpdateRuleGroup ¶
func (b *InMemoryBackend) UpdateRuleGroup( ctx context.Context, id, description, visibilityConfig, lockToken string, rules []map[string]any, ) (*RuleGroup, error)
UpdateRuleGroup updates a RuleGroup by ID.
func (*InMemoryBackend) UpdateWebACL ¶
func (b *InMemoryBackend) UpdateWebACL( ctx context.Context, id, description, lockToken string, defaultAction, visibilityConfig json.RawMessage, rules []map[string]any, tokenDomains []string, customResponseBodies, associationConfig, captchaConfig, challengeConfig json.RawMessage, ) (*WebACL, error)
UpdateWebACL updates a WebACL by ID.
func (*InMemoryBackend) WebACLARN ¶
func (b *InMemoryBackend) WebACLARN(name, id, scope string) string
WebACLARN builds an ARN for a WebACL.
type ManagedRuleSet ¶
type ManagedRuleSet struct {
PublishedVersions map[string]ManagedRuleSetVersion `json:"publishedVersions,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
Scope string `json:"scope"`
ARN string `json:"arn,omitempty"`
LockToken string `json:"lockToken"`
// Region is the request region this managed rule set was created/looked
// up under (see getRegion). Unlike WebACL/IPSet/RegexPatternSet/RuleGroup,
// ManagedRuleSet storage keys off the RAW request region rather than the
// scope-normalized region baked into ARN, so it cannot be reliably
// recovered from ARN alone -- this field is the store.Table[ManagedRuleSet]
// key material that replaces the old map[region]map[id] nesting. Tagged
// json:"-" because it is not part of the AWS-facing shape; it is
// round-tripped through persistence.go's managedRuleSetSnapshot DTO
// instead (see that file's doc comment).
Region string `json:"-"`
RecommendedVersion string `json:"recommendedVersion,omitempty"`
}
ManagedRuleSet represents an AWS WAFv2 managed rule set.
type ManagedRuleSetVersion ¶
type ManagedRuleSetVersion struct {
ExpiryTimestamp *int64 `json:"ExpiryTimestamp,omitempty"`
ForecastedLifetime *int64 `json:"ForecastedLifetime,omitempty"`
LastUpdateTimestamp *int64 `json:"LastUpdateTimestamp,omitempty"`
PublishTimestamp *int64 `json:"PublishTimestamp,omitempty"`
AssociatedRuleGroupArn string `json:"AssociatedRuleGroupArn,omitempty"`
Capacity int64 `json:"Capacity,omitempty"`
}
ManagedRuleSetVersion holds metadata for a single published version of a managed rule set.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for AWS WAFv2.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the WAFv2 service backend and handler.
type RegexEntry ¶
type RegexEntry struct {
RegexString string `json:"RegexString"`
}
RegexEntry represents a single regex pattern in AWS API shape.
type RegexPatternSet ¶
type RegexPatternSet struct {
Tags map[string]string `json:"tags,omitempty"`
ARN string `json:"arn,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
Scope string `json:"scope"`
Description string `json:"description"`
LockToken string `json:"lockToken"`
RegularExpressionList []RegexEntry `json:"regularExpressionList,omitempty"`
}
RegexPatternSet represents an AWS WAFv2 Regex Pattern Set.
type RuleGroup ¶
type RuleGroup struct {
Tags map[string]string `json:"tags,omitempty"`
ARN string `json:"arn,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
Scope string `json:"scope"`
Description string `json:"description"`
VisibilityConfig string `json:"visibilityConfig"`
LockToken string `json:"lockToken"`
Rules []map[string]any `json:"rules,omitempty"`
Capacity int64 `json:"capacity"`
}
RuleGroup represents an AWS WAFv2 Rule Group.
type StorageBackend ¶
type StorageBackend interface {
AccountID() string
Region() string
WebACLARN(name, id, scope string) string
IPSetARN(name, id, scope string) string
RegexPatternSetARN(name, id, scope string) string
RuleGroupARN(name, id, scope string) string
CreateWebACL(
ctx context.Context,
name, scope, description string,
defaultAction, visibilityConfig json.RawMessage,
rules []map[string]any,
tokenDomains []string,
customResponseBodies, associationConfig, captchaConfig, challengeConfig json.RawMessage,
tags map[string]string,
) (*WebACL, error)
GetWebACL(ctx context.Context, id string) (*WebACL, error)
UpdateWebACL(
ctx context.Context,
id, description, lockToken string,
defaultAction, visibilityConfig json.RawMessage,
rules []map[string]any,
tokenDomains []string,
customResponseBodies, associationConfig, captchaConfig, challengeConfig json.RawMessage,
) (*WebACL, error)
DeleteWebACL(ctx context.Context, id, lockToken string) error
ListWebACLs(ctx context.Context) []*WebACL
CreateIPSet(
ctx context.Context,
name, scope, description, ipAddressVersion string,
addresses []string,
tags map[string]string,
) (*IPSet, error)
GetIPSet(ctx context.Context, id string) (*IPSet, error)
UpdateIPSet(ctx context.Context, id, description, lockToken string, addresses []string) (*IPSet, error)
DeleteIPSet(ctx context.Context, id, lockToken string) error
ListIPSets(ctx context.Context) []*IPSet
TagResource(ctx context.Context, resourceARN string, tags map[string]string) error
ListTagsForResource(ctx context.Context, resourceARN string) (map[string]string, error)
UntagResource(ctx context.Context, resourceARN string, tagKeys []string) error
Reset()
AssociateWebACL(ctx context.Context, webACLARN, resourceARN string) error
DisassociateWebACL(ctx context.Context, resourceARN string) error
GetWebACLForResource(ctx context.Context, resourceARN string) (*WebACL, error)
CheckCapacity(ctx context.Context, scope string, rules []map[string]any) (int64, error)
CreateAPIKey(ctx context.Context, scope string, tokenDomains []string) (*APIKey, error)
CreateRegexPatternSet(
ctx context.Context,
name, scope, description string,
regularExpressionList []RegexEntry,
tags map[string]string,
) (*RegexPatternSet, error)
GetRegexPatternSet(ctx context.Context, id string) (*RegexPatternSet, error)
ListRegexPatternSets(ctx context.Context) []*RegexPatternSet
UpdateRegexPatternSet(
ctx context.Context,
id, description, lockToken string,
regularExpressionList []RegexEntry,
) (*RegexPatternSet, error)
CreateRuleGroup(
ctx context.Context,
name, scope, description, visibilityConfig string,
capacity int64,
rules []map[string]any,
tags map[string]string,
) (*RuleGroup, error)
GetRuleGroup(ctx context.Context, id string) (*RuleGroup, error)
ListRuleGroups(ctx context.Context) []*RuleGroup
UpdateRuleGroup(
ctx context.Context,
id, description, visibilityConfig, lockToken string,
rules []map[string]any,
) (*RuleGroup, error)
DeleteRuleGroup(ctx context.Context, id, lockToken string) error
DeleteAPIKey(ctx context.Context, scope, apiKey string) error
DeleteFirewallManagerRuleGroups(ctx context.Context, webACLARN string) (*WebACL, error)
PutLoggingConfiguration(ctx context.Context, resourceARN string, configJSON json.RawMessage) error
DeleteLoggingConfiguration(ctx context.Context, resourceARN string) error
GetLoggingConfiguration(ctx context.Context, resourceARN string) (json.RawMessage, error)
ListLoggingConfigurations(ctx context.Context) []json.RawMessage
DeletePermissionPolicy(ctx context.Context, resourceARN string) error
DeleteRegexPatternSet(ctx context.Context, id, lockToken string) error
ListAPIKeys(ctx context.Context, scope string) []*APIKey
GetDecryptedAPIKey(ctx context.Context, scope, apiKey string) (*APIKey, error)
GetPermissionPolicy(ctx context.Context, resourceARN string) (string, error)
ListResourcesForWebACL(ctx context.Context, webACLARN string) ([]string, error)
PutPermissionPolicy(ctx context.Context, resourceARN, policy string) error
ManagedRuleSetARN(name, id, scope string) string
GetManagedRuleSet(ctx context.Context, id string) (*ManagedRuleSet, error)
ListManagedRuleSets(ctx context.Context, scope string) []*ManagedRuleSet
PutManagedRuleSetVersions(
ctx context.Context,
id, name, scope, lockToken, recommendedVersion string,
versionsToPublish map[string]any,
) (*ManagedRuleSet, error)
UpdateManagedRuleSetVersionExpiryDate(
ctx context.Context,
id, lockToken, versionToExpire string,
expiryTimestamp *int64,
) (*ManagedRuleSet, error)
Snapshot(ctx context.Context) []byte
Restore(ctx context.Context, data []byte) error
}
StorageBackend is the interface for WAFv2 storage operations.
type TaggedEntry ¶ added in v1.2.0
TaggedEntry pairs a resource ARN with its tag map, for cross-service tag enumeration by the Resource Groups Tagging API (see cli.go's wireTaggingWAFv2).
type VisibilityConfig ¶
type VisibilityConfig struct {
MetricName string `json:"MetricName"`
SampledRequestsEnabled bool `json:"SampledRequestsEnabled"`
CloudWatchMetricsEnabled bool `json:"CloudWatchMetricsEnabled"`
}
VisibilityConfig holds the parsed VisibilityConfig structure.
type WebACL ¶
type WebACL struct {
Tags map[string]string `json:"tags,omitempty"`
ARN string `json:"arn,omitempty"`
DefaultAction json.RawMessage `json:"defaultAction,omitempty"`
VisibilityConfig json.RawMessage `json:"visibilityConfig,omitempty"`
CustomResponseBodies json.RawMessage `json:"customResponseBodies,omitempty"`
AssociationConfig json.RawMessage `json:"associationConfig,omitempty"`
CaptchaConfig json.RawMessage `json:"captchaConfig,omitempty"`
ChallengeConfig json.RawMessage `json:"challengeConfig,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
Scope string `json:"scope"`
Description string `json:"description"`
LockToken string `json:"lockToken"`
TokenDomains []string `json:"tokenDomains,omitempty"`
Rules []map[string]any `json:"rules,omitempty"`
}
WebACL represents an AWS WAFv2 Web ACL.
Source Files
¶
- api_keys.go
- capacity.go
- errors.go
- handler.go
- handler_api_keys.go
- handler_ip_sets.go
- handler_logging_config.go
- handler_managed_rule_catalog.go
- handler_managed_rule_sets.go
- handler_permission_policies.go
- handler_rate_based_rules.go
- handler_regex_pattern_sets.go
- handler_resource_associations.go
- handler_revenue_statistics.go
- handler_rule_groups.go
- handler_tags.go
- handler_web_acls.go
- interfaces.go
- ip_sets.go
- logging_config.go
- managed_rule_catalog.go
- managed_rule_sets.go
- models.go
- permission_policies.go
- persistence.go
- provider.go
- rate_based_rules.go
- regex_pattern_sets.go
- resource_associations.go
- rule_groups.go
- store.go
- store_setup.go
- tags.go
- web_acls.go