Skip to content

Commit 41457c4

Browse files
author
James Zhou
committed
fix(CG-1329): fix aws cis 1.4.0 rule 2.2.1
1 parent 9949f41 commit 41457c4

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

src/aws/cis-1.4.0/rules/aws-cis-1.4.0-2.2.1.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,18 @@ export default {
5454
],
5555

5656
severity: 'medium',
57+
gql: `{
58+
queryawsEbs {
59+
id
60+
arn
61+
accountId
62+
__typename
63+
encrypted
64+
}
65+
}`,
66+
resource: 'queryawsEbs[*]',
67+
conditions: {
68+
path: '@.encrypted',
69+
equal: true,
70+
},
5771
}

src/aws/cis-1.4.0/tests/aws-cis-1.4.0-2.x.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Aws_CIS_140_211 from '../rules/aws-cis-1.4.0-2.1.1'
66
import Aws_CIS_140_212 from '../rules/aws-cis-1.4.0-2.1.2'
77
import Aws_CIS_140_213 from '../rules/aws-cis-1.4.0-2.1.3'
88
import Aws_CIS_140_215 from '../rules/aws-cis-1.4.0-2.1.5'
9+
import Aws_CIS_140_221 from '../rules/aws-cis-1.4.0-2.2.1'
910
import Aws_CIS_140_231 from '../rules/aws-cis-1.4.0-2.3.1'
1011

1112
export interface Condition {
@@ -49,8 +50,13 @@ export interface QueryawsS3 {
4950
encrypted?: string
5051
encryptionRules?: EncryptionRule[]
5152
}
53+
export interface QueryawsEbs {
54+
id: string
55+
encrypted: boolean
56+
}
5257
export interface CIS2xQueryResponse {
5358
queryawsS3?: QueryawsS3[]
59+
queryawsEbs?: QueryawsEbs[]
5460
queryawsRdsDbInstance?: QueryawsRdsDbInstance[]
5561
}
5662

@@ -358,6 +364,44 @@ describe('CIS Amazon Web Services Foundations: 1.4.0', () => {
358364
})
359365
})
360366

367+
describe('AWS CIS 2.2.1 Ensure EBS volume encryption is enabled', () => {
368+
const getTestRuleFixture = (encrypted: boolean): CIS2xQueryResponse => {
369+
return {
370+
queryawsEbs: [
371+
{
372+
id: cuid(),
373+
encrypted,
374+
},
375+
],
376+
}
377+
}
378+
379+
// Act
380+
const testRule = async (
381+
data: CIS2xQueryResponse,
382+
expectedResult: Result
383+
): Promise<void> => {
384+
// Act
385+
const [processedRule] = await rulesEngine.processRule(
386+
Aws_CIS_140_221 as Rule,
387+
{ ...data }
388+
)
389+
390+
// Asserts
391+
expect(processedRule.result).toBe(expectedResult)
392+
}
393+
394+
test('No Security Issue when EBS volume encryption is enabled', async () => {
395+
const data: CIS2xQueryResponse = getTestRuleFixture(true)
396+
await testRule(data, Result.PASS)
397+
})
398+
399+
test('Security Issue when EBS volume encryption is not enabled', async () => {
400+
const data: CIS2xQueryResponse = getTestRuleFixture(false)
401+
await testRule(data, Result.FAIL)
402+
})
403+
})
404+
361405
describe('AWS CIS 2.3.1 Ensure that encryption is enabled for RDS Instances', () => {
362406
const getTestRuleFixture = (encrypted: boolean): CIS2xQueryResponse => {
363407
return {

0 commit comments

Comments
 (0)