Skip to content

Commit

Permalink
fix(validation): Validate WAF throtle limit
Browse files Browse the repository at this point in the history
  • Loading branch information
bboure committed Jun 15, 2022
1 parent 1a5f81b commit 8c286fb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/__tests__/validation/__snapshots__/base.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ exports[`Valdiation Waf Invalid should validate a Invalid 1`] = `
/waf/rules/2: must be a valid WAF rule"
`;

exports[`Valdiation Waf Invalid should validate a Throttle limit 1`] = `
"/waf/rules/0: must be a valid WAF rule
/waf/rules/1: must be a valid WAF rule"
`;

exports[`Valdiation should validate 1`] = `
": must have required property 'name'
: must have required property 'authentication'
Expand Down
17 changes: 17 additions & 0 deletions src/__tests__/validation/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,23 @@ describe('Valdiation', () => {
},
},
},
{
name: 'Throttle limit',
config: {
...basicConfig,
waf: {
rules: [
{ throttle: 99 },
{
throttle: {
name: 'Throttle',
limit: 99,
},
},
],
},
},
},
];

assertions.forEach((config) => {
Expand Down
4 changes: 2 additions & 2 deletions src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export const appSyncSchema = {
properties: {
throttle: {
oneOf: [
{ type: 'integer' },
{ type: 'integer', minimum: 100 },
{
type: 'object',
properties: {
Expand All @@ -200,7 +200,7 @@ export const appSyncSchema = {
type: 'string',
enum: ['IP', 'FORWARDED_IP'],
},
limit: { type: 'integer' },
limit: { type: 'integer', minimum: 100 },
priority: { type: 'integer' },
scopeDownStatement: { type: 'object' },
forwardedIPConfig: {
Expand Down

0 comments on commit 8c286fb

Please sign in to comment.