@@ -7,6 +7,7 @@ import Aws_CIS_140_212 from '../rules/aws-cis-1.4.0-2.1.2'
77import Aws_CIS_140_213 from '../rules/aws-cis-1.4.0-2.1.3'
88import Aws_CIS_140_215_1 from '../rules/aws-cis-1.4.0-2.1.5.1'
99import Aws_CIS_140_215_2 from '../rules/aws-cis-1.4.0-2.1.5.2'
10+ import Aws_CIS_140_221 from '../rules/aws-cis-1.4.0-2.2.1'
1011import Aws_CIS_140_231 from '../rules/aws-cis-1.4.0-2.3.1'
1112
1213export interface Condition {
@@ -54,8 +55,13 @@ export interface QueryawsS3 {
5455 encrypted ?: string
5556 encryptionRules ?: EncryptionRule [ ]
5657}
58+ export interface QueryawsEbs {
59+ id : string
60+ encrypted : boolean
61+ }
5762export interface CIS2xQueryResponse {
5863 queryawsS3 ?: QueryawsS3 [ ]
64+ queryawsEbs ?: QueryawsEbs [ ]
5965 queryawsRdsDbInstance ?: QueryawsRdsDbInstance [ ]
6066}
6167
@@ -459,6 +465,44 @@ describe('CIS Amazon Web Services Foundations: 1.4.0', () => {
459465 } )
460466 } )
461467
468+ describe ( 'AWS CIS 2.2.1 Ensure EBS volume encryption is enabled' , ( ) => {
469+ const getTestRuleFixture = ( encrypted : boolean ) : CIS2xQueryResponse => {
470+ return {
471+ queryawsEbs : [
472+ {
473+ id : cuid ( ) ,
474+ encrypted,
475+ } ,
476+ ] ,
477+ }
478+ }
479+
480+ // Act
481+ const testRule = async (
482+ data : CIS2xQueryResponse ,
483+ expectedResult : Result
484+ ) : Promise < void > => {
485+ // Act
486+ const [ processedRule ] = await rulesEngine . processRule (
487+ Aws_CIS_140_221 as Rule ,
488+ { ...data }
489+ )
490+
491+ // Asserts
492+ expect ( processedRule . result ) . toBe ( expectedResult )
493+ }
494+
495+ test ( 'No Security Issue when EBS volume encryption is enabled' , async ( ) => {
496+ const data : CIS2xQueryResponse = getTestRuleFixture ( true )
497+ await testRule ( data , Result . PASS )
498+ } )
499+
500+ test ( 'Security Issue when EBS volume encryption is not enabled' , async ( ) => {
501+ const data : CIS2xQueryResponse = getTestRuleFixture ( false )
502+ await testRule ( data , Result . FAIL )
503+ } )
504+ } )
505+
462506 describe ( 'AWS CIS 2.3.1 Ensure that encryption is enabled for RDS Instances' , ( ) => {
463507 const getTestRuleFixture = ( encrypted : boolean ) : CIS2xQueryResponse => {
464508 return {
0 commit comments