Skip to content

Commit

Permalink
chore: Remove Defender webhooks/lambda (#273)
Browse files Browse the repository at this point in the history
* chore: Init

* chore: Fix syntax

* chore: Remove module
  • Loading branch information
garethfuller authored Jun 3, 2024
1 parent 8871f4a commit 45a6d4c
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 3,045 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ The `{chainId}` in each endpoint is the chain/network number you wish to request
- `/check-wallet` - Used to perform sanctions checks with TRM.
- `/tenderly/contracts/encode-states` - Encodes state information with Tenderly
- `/tenderly/simulate` - Simulate a transaction with Tenderly
- `/hal-webhook` - Receives events from hal.xyz

### Update Pools Lambda

Expand Down
7 changes: 5 additions & 2 deletions cdk/waf.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { CfnWebACL, CfnWebACLProps } from 'aws-cdk-lib/aws-wafv2';

function createRule(name: string, searchString: string, limit: number): CfnWebACL.RuleProperty {
function createRule(
name: string,
searchString: string,
limit: number
): CfnWebACL.RuleProperty {
const rule = {
name,
priority: 0,
Expand Down Expand Up @@ -72,6 +76,5 @@ export const rateLimitSettings: CfnWebACLProps = {
createRule('BlockSpamForSor', '/sor', 10000),
createRule('BlockSpamForOrder', '/order', 10000),
createRule('BlockSpamForGraphQL', '/graphql', 500),
createRule('BlockSpamForHAL', '/hal', 100),
]),
};
52 changes: 1 addition & 51 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ const {
TENDERLY_PROJECT,
TENDERLY_ACCESS_KEY,
SENTRY_DSN,
GH_WEBHOOK_PAT,
ALLOWLIST_POOL_ENDPOINT,
ALLOWLIST_TOKEN_ENDPOINT,
DEBUG,
} = process.env;

Expand Down Expand Up @@ -374,29 +371,13 @@ export class BalancerPoolsAPI extends Stack {
const checkWalletLambda = new NodejsFunction(this, 'checkWalletFunction', {
entry: join(__dirname, 'src', 'lambdas', 'check-wallet.ts'),
environment: {
HYPERNATIVE_EMAIL: HYPERNATIVE_EMAIL || '',
HYPERNATIVE_EMAIL: HYPERNATIVE_EMAIL || '',
HYPERNATIVE_PASSWORD: HYPERNATIVE_PASSWORD || '',
},
runtime: Runtime.NODEJS_14_X,
timeout: Duration.seconds(15),
});

const defenderWebhookLambda = new NodejsFunction(
this,
'defenderWebhookFunction',
{
entry: join(__dirname, 'src', 'lambdas', 'defender-webhook.ts'),
environment: {
...nodeJsFunctionProps.environment,
GH_WEBHOOK_PAT: GH_WEBHOOK_PAT || '',
ALLOWLIST_POOL_ENDPOINT: ALLOWLIST_POOL_ENDPOINT || '',
ALLOWLIST_TOKEN_ENDPOINT: ALLOWLIST_TOKEN_ENDPOINT || '',
},
runtime: Runtime.NODEJS_14_X,
timeout: Duration.seconds(15),
}
);

/**
* Lambda Schedules
*/
Expand Down Expand Up @@ -534,9 +515,6 @@ export class BalancerPoolsAPI extends Stack {
'method.request.querystring.address',
},
});
const defenderWebhookIntegration = new LambdaIntegration(
defenderWebhookLambda
);

const apiGatewayLogGroup = new LogGroup(this, 'ApiGatewayLogs');

Expand Down Expand Up @@ -660,34 +638,6 @@ export class BalancerPoolsAPI extends Stack {
tenderlyEncodeStates.addMethod('POST', tenderlyEncodeStateIntegration);
addCorsOptions(tenderlyEncodeStates);

// const halWebhookLambda = new NodejsFunction(this, 'halWebhookFunction', {
// entry: join(__dirname, 'src', 'lambdas', 'hal-webhook.ts'),
// environment: {
// ...nodeJsFunctionProps.environment,
// GH_WEBHOOK_PAT: GH_WEBHOOK_PAT || '',
// ALLOWLIST_POOL_ENDPOINT: ALLOWLIST_POOL_ENDPOINT || '',
// ALLOWLIST_TOKEN_ENDPOINT: ALLOWLIST_TOKEN_ENDPOINT || '',
// },
// runtime: Runtime.NODEJS_14_X,
// timeout: Duration.seconds(15),
// });
// const halWebhookIntegration = new LambdaIntegration(halWebhookLambda, {
// proxy: true,
// requestParameters: {
// 'integration.request.path.chainId': 'method.request.path.chainId',
// },
// });
// const hal = api.root.addResource('hal');
// const halOnChain = hal.addResource('{chainId}');
// halOnChain.addMethod('POST', halWebhookIntegration, {
// requestParameters: {
// 'method.request.path.chainId': true,
// },
// });

const defender = api.root.addResource('defender');
defender.addMethod('POST', defenderWebhookIntegration);

/**
* Web Application Firewall
*/
Expand Down
76 changes: 0 additions & 76 deletions src/lambdas/defender-webhook.spec.ts

This file was deleted.

50 changes: 0 additions & 50 deletions src/lambdas/defender-webhook.ts

This file was deleted.

68 changes: 0 additions & 68 deletions src/lambdas/hal-webhook.spec.ts

This file was deleted.

63 changes: 0 additions & 63 deletions src/lambdas/hal-webhook.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/modules/defender/index.ts

This file was deleted.

Loading

0 comments on commit 45a6d4c

Please sign in to comment.