Skip to content

Commit

Permalink
add statementtype to console.log
Browse files Browse the repository at this point in the history
  • Loading branch information
daknhh committed Apr 12, 2024
1 parent 748a1d5 commit 7640350
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- Save chars on ManagedServiceData FMS prop. The ManagedServiceData has a hard limit of 8192 characters. I've asked AWS about raising it and they said that this is a hard limit and they can't raise it. This commit is for saving as much chars as we can out of the ManagedServiceData prop, for squeezing in our rules (even if they have a ton of RuleActionOverrides on them)
- Values: allow async code. This adds a dynamic import of the firewall config for enabling people that want to run async code on then, ensuring that all async code will run during the import
- [Issue#317](https://github.com/globaldatanet/aws-firewall-factory/issues/317) Evaluation time windows for request aggregation with rate-based rules. You can now select time windows of 1 minute, 2 minutes or 10 minutes, in addition to the previously supported 5 minutes.

- CustomRule StatementType is now part of the log Capacity Table
### Fixed
- RateBasedStatement.CustomKeys is a array of objects, not a object
- Recursive code for adding RateBasedStatement.ScopeDownStatement. The prop ScopeDownStatement of RateBasedStatements can have And, Or and Not statements, just like any other Statement. Without this fix, deploying RateBasedStatements with complex ScopeDownStatements fails on capacity checking.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ function filterStatements(statement: wafv2.CfnWebACL.StatementProperty){
async function calculateCustomRulesCapacities(customRules: FmsRule[], deploymentRegion: string, scope: "REGIONAL" | "CLOUDFRONT", runtimeProperties: RuntimeProperties) {
const capacities = [];
const capacitieslog = [];
capacitieslog.push(["🔺 Priority", "➕ RuleName", "Capacity"]);
capacitieslog.push(["🔺 Priority", "➕ RuleName", "🧮 Capacity", "ℹ StatementType"]);
for (const customRule of customRules) {
// Manually calculate and return capacity if rule has a ipset statements with a logical ID entry (e.g. ${IPsString.Arn})
// This means the IPSet will be created by this repo, maybe it doesn't exists yet. That fails this function. That's why the code below is needed.
Expand Down Expand Up @@ -553,13 +553,14 @@ async function calculateCustomRulesCapacities(customRules: FmsRule[], deployment
else {
capacities.push(await calculateCustomRuleStatementsCapacity(customRule, deploymentRegion, scope, runtimeProperties));
}
capacitieslog.push([customRule.priority, customRule.name,capacities[capacities.length-1]]);
capacitieslog.push([customRule.priority, customRule.name,capacities[capacities.length-1], Object.keys(customRule.statement)[0].charAt(0).toUpperCase()+ Object.keys(customRule.statement)[0].slice(1)]);
}
capacitieslog.sort((a, b) => parseInt(a[0] as string,10) - parseInt(b[0] as string,10));
console.log(table(capacitieslog));
return capacities;
}


function calculateRatebasedStatementwithoutScopeDownStatement(customRule: FmsRule, rateBasedStatement: wafv2.CfnWebACL.RateBasedStatementProperty): FmsRule {
// Remove scopedDownStatement if it exists
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down

0 comments on commit 7640350

Please sign in to comment.