Feat/waf evaluation window sec#710
Conversation
# Conflicts: # src/__tests__/__snapshots__/waf.test.ts.snap
📝 WalkthroughWalkthroughThis PR adds support for an optional ChangesWAF Throttle EvaluationWindowSec Feature
GitHub Issue and PR Template Improvements
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/types/common.ts (1)
26-26: ⚡ Quick winConsider using a literal union type for compile-time safety.
The
evaluationWindowSecfield acceptsnumberbut AWS WAF only supports specific values (60, 120, 300, 600). Using a literal union type would catch invalid values at compile time rather than relying solely on runtime validation.🔒 Proposed type improvement
- evaluationWindowSec?: number; + evaluationWindowSec?: 60 | 120 | 300 | 600;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/types/common.ts` at line 26, Change the evaluationWindowSec property from a plain number to a literal union of the allowed AWS WAF values (60 | 120 | 300 | 600) to enforce valid values at compile time; update the declaration of evaluationWindowSec in the relevant interface/type (the evaluationWindowSec field in src/types/common.ts) and adjust any call sites, defaults, or tests that pass other numeric values so they use one of the permitted literals.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/ISSUE_TEMPLATE/add-new-feature---behavior.md:
- Line 24: Two fenced code blocks in the add-new-feature---behavior template are
missing language identifiers (causing markdownlint MD040); update both code
fences referenced around the example text to use a language tag (e.g., change
``` to ```text) so the blocks read as fenced with language identifiers, ensuring
the first example ("Currently, AWS RDS Postgresql is not supported as
datasource.") and the second example ("AWS RDS Postgresql is supported as
datasource for queries or mutations.") are both prefixed by ```text.
---
Nitpick comments:
In `@src/types/common.ts`:
- Line 26: Change the evaluationWindowSec property from a plain number to a
literal union of the allowed AWS WAF values (60 | 120 | 300 | 600) to enforce
valid values at compile time; update the declaration of evaluationWindowSec in
the relevant interface/type (the evaluationWindowSec field in
src/types/common.ts) and adjust any call sites, defaults, or tests that pass
other numeric values so they use one of the permitted literals.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bd3c883b-c92c-4028-a207-86ea638c45c6
⛔ Files ignored due to path filters (2)
src/__tests__/__snapshots__/waf.test.ts.snapis excluded by!**/*.snapsrc/__tests__/validation/__snapshots__/base.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (12)
.github/ISSUE_TEMPLATE/add-new-feature---behavior.md.github/ISSUE_TEMPLATE/report-bug.md.github/PULL_REQUEST_TEMPLATE.mddoc/WAF.mde2e/waf.e2e.test.tsexamples/waf/serverless.ymlsrc/__tests__/validation/base.test.tssrc/__tests__/waf.test.tssrc/resources/Waf.tssrc/types/cloudFormation.tssrc/types/common.tssrc/validation.ts
💤 Files with no reviewable changes (1)
- .github/ISSUE_TEMPLATE/report-bug.md
|
|
||
| **Example:** | ||
|
|
||
| ``` |
There was a problem hiding this comment.
Add language identifiers to fenced code blocks to satisfy markdownlint (MD040).
Two example fences are missing a language tag, which can fail markdown lint checks.
Suggested patch
-```
+```text
Currently, AWS RDS Postgresql is not supported as datasource.@@
- +text
AWS RDS Postgresql is supported as datasource for queries or mutations.
Also applies to: 35-35
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 24-24: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/ISSUE_TEMPLATE/add-new-feature---behavior.md at line 24, Two fenced
code blocks in the add-new-feature---behavior template are missing language
identifiers (causing markdownlint MD040); update both code fences referenced
around the example text to use a language tag (e.g., change ``` to ```text) so
the blocks read as fenced with language identifiers, ensuring the first example
("Currently, AWS RDS Postgresql is not supported as datasource.") and the second
example ("AWS RDS Postgresql is supported as datasource for queries or
mutations.") are both prefixed by ```text.
Title:
feat(waf): support evaluationWindowSec on throttle rulesSupersedes #651. Original implementation by @timo92 — rebased onto current
masterand extended. (Their commit is preserved in history, so authorship is retained.)What
Adds an optional
evaluationWindowSecto WAFthrottlerules, mapping to the AWS WAFv2RateBasedStatement.EvaluationWindowSecproperty — the look-back window, in seconds, over which AWS WAF counts requests for a rate-based rule. Valid values are60 | 120 | 300 | 600; AWS defaults to300.Changes made on top of #651
300and wrote it into every throttle rule'sRateBasedStatement— including the barethrottle: 200shorthand. Because AWS resets a rate-based rule's request counts whenever one of its settings changes on a live rule, that would have caused an unsolicited WebACL update (and a brief rate-limiting pause) on every existing user's next deploy, even though300matches AWS's own default. It's now leftundefinedunless the user sets it, so the generated CloudFormation is byte-identical for existing stacks and AWS applies its native default. This mirrors howpriority,forwardedIPConfig, andscopeDownStatementare already handled.60 | 120 | 300 | 600) to the throttle schema so invalid values are rejected atserverlessconfig validation instead of failing at deploy time.master, including the jest 27 → 30 bump and the e2e CFN-synthesis harness that postdated the original branch.Tests
src/__tests__): added valid (300) and invalid (301)evaluationWindowSecvalidation cases; WAF snapshots updated.e2e/waf.e2e.test.ts, offline):examples/wafnow exercises both paths — a defaultthrottle: 200rule (asserts the synthesized template contains noEvaluationWindowSec) and an explicitevaluationWindowSec: 60rule (asserts it's emitted with the right value).npm run lintclean,npm test(289 passing),npm run test:e2e(86 passing).Reviewer notes / not covered here
serverless deployagainst a stack that already has athrottleWAF rule should confirm the upgrade produces a no-op WebACL diff.Summary by CodeRabbit
New Features
Documentation