Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ipv6 support for block list #1213

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion packages/graphql-mesh-server/lib/fargate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,23 @@ export interface MeshServiceProps {
*/
secrets?: { [key: string]: ssm.IStringParameter | ssm.IStringListParameter };
/**
* List of IP addresses to block (currently only support IPv4)
* List of IPv4 addresses to block
*/
blockedIps?: string[];
/**
* The waf rule priority.
* Defaults to 2
*/
blockedIpPriority?: number;
/**
* List of IPv6 addresses to block
*/
blockedIpv6s?: string[];
/**
* The waf rule priority.
* Defaults to 3
*/
blockedIpv6Priority?: number;
/**
* List of AWS Managed rules to add to the WAF
*/
Expand Down Expand Up @@ -220,6 +229,13 @@ export class MeshService extends Construct {
description: "List of IPs blocked by WAF",
});

const blockedIpv6List = new CfnIPSet(this, "BlockedIpv6List", {
addresses: props.blockedIpv6s || [],
ipAddressVersion: "IPV6",
scope: "REGIONAL",
description: "List of IPv6s blocked by WAF",
});

const defaultRules: CfnWebACL.RuleProperty[] = [
{
name: "IPBlockList",
Expand All @@ -238,6 +254,23 @@ export class MeshService extends Construct {
block: {},
},
},
{
name: "IPv6BlockList",
priority: 3 || props.blockedIpPriority,
statement: {
ipSetReferenceStatement: {
arn: blockedIpv6List.attrArn,
},
},
visibilityConfig: {
cloudWatchMetricsEnabled: true,
metricName: "IPv6BlockList",
sampledRequestsEnabled: true,
},
action: {
block: {},
},
},
];

if (props.rateLimit) {
Expand Down
11 changes: 10 additions & 1 deletion packages/graphql-mesh-server/lib/graphql-mesh-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,23 @@ export type MeshHostingProps = {
*/
notificationArn?: string;
/**
* List of IP addresses to block (currently only support IPv4)
* List of IPv4 addresses to block
*/
blockedIps?: string[];
/**
* The waf rule priority.
* Defaults to 2
*/
blockedIpPriority?: number;
/**
* List of IPv6 addresses to block
*/
blockedIpv6s?: string[];
/**
* The waf rule priority.
* Defaults to 3
*/
blockedIpv6Priority?: number;
/**
* List of AWS Managed rules to add to the WAF
*/
Expand Down
Loading