wafv2

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 25 Imported by: 0

README

WAFv2

Parity grade: A- · SDK aws-sdk-go-v2/service/wafv2@v1.76.0 · last audited 2026-07-25 (7061877e4)

Coverage

Metric Value
Operations audited 59 (50 ok, 9 partial)
Feature families 4 (4 ok)
Known gaps 3
Deferred items 0
Resource leaks clean
Known gaps
  • GetWebACL response omits the optional top-level ApplicationIntegrationURL field (only populated when a web ACL uses AWSManagedRulesATPRuleSet/ACFPRuleSet with client app integration). Re-investigated this pass: AWS has never published the URL-generation scheme (it's an opaque, AWS-internal-service-generated URL), so there is no deterministic value this emulator could fabricate that would be meaningfully AWS-accurate -- niche, rarely asserted by IaC tooling. Left unmodeled rather than invented.
  • GetManagedRuleSet/ListManagedRuleSets don't model Description/LabelNamespace (ManagedRuleSet struct has no such fields). Re-investigated this pass: confirmed genuinely non-actionable, not merely low-priority -- PutManagedRuleSetVersionsInput (the only op that creates/updates a ManagedRuleSet in this emulator; there is no CreateManagedRuleSet in the real API either, it's vendor-onboarding-only) has no Description/LabelNamespace input fields, so no caller can ever populate them through any modeled or real API path. Since both are *string with omitempty JSON serialization on the real SDK, an always-absent field is byte-for-byte identical on the wire to an always-nil field -- there is no observable client-visible gap here today. Vendor-only Firewall-Manager API family, not used by Terraform/CDK for the common WAFv2 workflow.
  • New this pass: GetRevenueStatistics/GetRevenueStatisticsSummary/GetRevenueStatisticsTimeSeries/ListSettlementRecords (added in aws-sdk-go-v2/service/wafv2@v1.76.0) always return honestly empty/zero results. This emulator has no real HTTP traffic, no AI-bot detection pipeline, and no billing/blockchain-settlement system, so there is no genuine revenue, bot, path, or settlement data to report -- exactly the same class of gap already documented for GetRateBasedStatementManagedKeys/GetSampledRequests/GetTopPathStatisticsByTraffic above. Deliberately NOT fabricated: no invented dollar amounts, bot names, path statistics, or settlement records. Every field validated (required-ness, enums, CLOUDFRONT-only Scope, Currency=USDC, 90-day TimeWindow cap, Filter enum values, Limit bounds) is checked for real; only the data, which does not exist in this backend, is honestly absent.

More

Documentation

Index

Constants

View Source
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

View Source
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 is returned when a resource is temporarily unavailable.
	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)
)
View Source
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

func (h *Handler) ChaosOperations() []string

ChaosOperations returns all operations that can be fault-injected.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions returns all regions this handler handles.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase AWS service name for fault rule matching.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation extracts the operation name from the X-Amz-Target header.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource extracts the resource identifier from the request.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

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

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all backend state.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher returns a function that matches WAFv2 API requests.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

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) GetIPSet

func (b *InMemoryBackend) GetIPSet(ctx context.Context, id string) (*IPSet, error)

GetIPSet returns an IPSet by ID.

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

func (b *InMemoryBackend) GetRuleGroup(ctx context.Context, id string) (*RuleGroup, error)

GetRuleGroup returns a RuleGroup by ID.

func (*InMemoryBackend) GetWebACL

func (b *InMemoryBackend) GetWebACL(ctx context.Context, id string) (*WebACL, error)

GetWebACL returns a WebACL 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) Reset

func (b *InMemoryBackend) Reset()

Reset clears all WAFv2 state.

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

Init initializes the WAFv2 service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

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

type TaggedEntry struct {
	Tags map[string]string
	ARN  string
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL