Skip to content

Commit 28e436c

Browse files
authored
Merge pull request #128 from cloudgraphdev/fix/CG-1329-aws-cis-140-221
Fix/cg 1329 aws cis 140 221
2 parents 6cb7d67 + 2bac2fd commit 28e436c

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
@@ -7,6 +7,7 @@ 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_1 from '../rules/aws-cis-1.4.0-2.1.5.1'
99
import 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'
1011
import Aws_CIS_140_231 from '../rules/aws-cis-1.4.0-2.3.1'
1112

1213
export 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+
}
5762
export 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

Comments
 (0)