Skip to content

Commit

Permalink
fix: haittaava WAF-sääntö pois. Cloudfrontiin logitukset päälle. (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
haapamakim authored Feb 2, 2023
1 parent c56d330 commit 9dceb47
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
30 changes: 28 additions & 2 deletions deployment/lib/hassu-waf.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { CfnRegexPatternSet, CfnWebACL, CfnWebACLProps } from "aws-cdk-lib/aws-wafv2";
import { CfnLoggingConfiguration, CfnRegexPatternSet, CfnWebACL, CfnWebACLProps } from "aws-cdk-lib/aws-wafv2";
import { Config, EnvName } from "./config";
import { Construct } from "constructs";
import { CfnOutput, Stack } from "aws-cdk-lib";
import { ArnFormat, CfnOutput, Stack } from "aws-cdk-lib";
import { BaseConfig } from "../../common/BaseConfig";
import { LogGroup } from "aws-cdk-lib/aws-logs";

export class FrontendWafStack extends Stack {
constructor(scope: Construct) {
Expand Down Expand Up @@ -83,6 +84,25 @@ export class FrontendWafStack extends Stack {
};

const cfnWebACL = new CfnWebACL(this, "frontendWAF", props);

const webAclLogGroup = new LogGroup(this, "awsWafLogs", {
logGroupName: `aws-waf-logs-hassu`,
});

// Create logging configuration with log group as destination
new CfnLoggingConfiguration(this, "webAclLoggingConfiguration", {
logDestinationConfigs: [
// Construct the different ARN format from the logGroupName
Stack.of(this).formatArn({
arnFormat: ArnFormat.COLON_RESOURCE_NAME,
service: "logs",
resource: "log-group",
resourceName: webAclLogGroup.logGroupName,
}),
],
resourceArn: cfnWebACL.attrArn,
});

new CfnOutput(this, "frontendWAFArn", {
value: cfnWebACL.attrArn,
exportName: "frontendWAFArn",
Expand Down Expand Up @@ -159,6 +179,12 @@ const managedRules: CfnWebACL.RuleProperty[] = [
allow: {},
},
},
{
name: "CrossSiteScripting_COOKIE",
actionToUse: {
allow: {},
},
},
],
},
},
Expand Down
3 changes: 0 additions & 3 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@
"groupSlug": "all-patch"
},
{
"matchPackagePatterns": [
"*"
],
"matchPackageNames": [
"@types/react"
],
Expand Down

0 comments on commit 9dceb47

Please sign in to comment.