Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: alphadev4 <113519745+alphadev4@users.noreply.github.com>
  • Loading branch information
AkhtarAmir and alphadev4 authored Nov 1, 2022
1 parent e8c22e8 commit 0787a00
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion helpers/aws/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2067,7 +2067,6 @@ var postcalls = [
reliesOnCall: 'listUserPools',
override: true
}

},
GuardDuty: {
getDetector: {
Expand Down
10 changes: 6 additions & 4 deletions plugins/aws/cognito/cognitoHasWafEnabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ var helpers = require('../../../helpers/aws');
module.exports = {
title: 'Cognito User Pool Has WAF Enabled',
category: 'Cognito',
domain: 'Identity Service Provider',
domain: 'Identity and Access Management',
description: 'Ensure that Cognito User Pool has WAF enabled.',
more_info: 'Enabling WAF allows control over unwanted requests to your hosted UI and Amazon Cognito API service endpoints, allowing or denying traffic based off rules in the Web ACL.',
link: 'https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-waf.html',
recommended_action: '1. Enter the Cognito service. 2. Enter user pools and enable WAF from properties',
recommended_action: '1. Enter the Cognito service. 2. Enter user pools and enable WAF from properties.',
apis: ['CognitoIdentityServiceProvider:listUserPools', 'WAFV2:getWebACLForCognitoUserPool', 'STS:getCallerIdentity'],

run: function(cache, settings, callback) {
Expand All @@ -30,10 +30,12 @@ module.exports = {
helpers.addResult(results, 3, 'Unable to query Cognito user pools: ' + helpers.addError(userPools), region);
return rcb();
}

if (!userPools.data.length){
helpers.addResult(results, 0, 'No Cognito user pools found', region);
return rcb();
}

for (let userPool of userPools.data) {
if (!userPool.Id) continue;

Expand All @@ -48,9 +50,9 @@ module.exports = {
continue;
}
if (webACLResource.data.WebACL){
helpers.addResult(results, 0, 'Cognito User pool has WAFV2 enabled', region, arn);
helpers.addResult(results, 0, 'User pool has WAFV2 enabled', region, arn);
} else {
helpers.addResult(results, 2, 'Cognito User pool does not have WAFV2 enabled', region, arn);
helpers.addResult(results, 2, 'User pool does not have WAFV2 enabled', region, arn);
}
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/aws/cognito/cognitoHasWafEnabled.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('cognitoHasWafEnabled', function () {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(0);
expect(results[0].region).to.equal('us-east-1');
expect(results[0].message).to.include('Cognito User pool has WAFV2 enabled');
expect(results[0].message).to.include('User pool has WAFV2 enabled');
done();
};

Expand All @@ -98,7 +98,7 @@ describe('cognitoHasWafEnabled', function () {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(2);
expect(results[0].region).to.equal('us-east-1');
expect(results[0].message).to.include('Cognito User pool does not have WAFV2 enabled');
expect(results[0].message).to.include('User pool does not have WAFV2 enabled');
done();
};

Expand Down

0 comments on commit 0787a00

Please sign in to comment.