Skip to content

Commit d0c1fc5

Browse files
authored
Merge pull request #130 from cloudgraphdev/fix/CG-1331-aws-pci-asg-1
fix(CG-1331): fix aws pci asg rule
2 parents 63ad0a6 + 34f894f commit d0c1fc5

2 files changed

Lines changed: 34 additions & 13 deletions

File tree

src/aws/pci-dss-3.2.1/rules/pci-dss-3.2.1-autoscaling-check-1.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,17 @@ export default {
4343
resource: 'queryawsAsg[*]',
4444
severity: 'low',
4545
conditions: {
46-
and: [
47-
{
48-
path: '@.healthCheckType',
49-
equal: 'ELB',
50-
},
51-
{
52-
path: '@.loadBalancerNames',
53-
isEmpty: false,
54-
},
55-
],
46+
not: {
47+
and: [
48+
{
49+
path: '@.healthCheckType',
50+
equal: 'EC2',
51+
},
52+
{
53+
path: '@.loadBalancerNames',
54+
isEmpty: false,
55+
},
56+
]
57+
},
5658
},
5759
}

src/aws/pci-dss-3.2.1/tests/pci-dss-3.2.1-autoscaling-checks.test.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('PCI Data Security Standard: 3.2.1', () => {
1010
rulesEngine = initRuleEngine('aws', 'PCI')
1111
})
1212
describe('Autoscaling Check 1: Auto Scaling groups associated with a load balancer should use health checks', () => {
13-
test('Should fail when it contains an invalid health check type and zero load balancers', async () => {
13+
test('Should pass when it contains an invalid health check type and zero load balancers', async () => {
1414
const data = {
1515
queryawsAsg: [
1616
{
@@ -26,10 +26,29 @@ describe('PCI Data Security Standard: 3.2.1', () => {
2626
{ ...data } as any
2727
)
2828

29+
expect(processedRule.result).toBe(Result.PASS)
30+
})
31+
32+
test('Should fail when it contains an invalid health check type and at least one load balancer', async () => {
33+
const data = {
34+
queryawsAsg: [
35+
{
36+
id: cuid(),
37+
loadBalancerNames: ['alb_1', 'alb2'],
38+
healthCheckType: 'EC2',
39+
},
40+
],
41+
}
42+
43+
const [processedRule] = await rulesEngine.processRule(
44+
Aws_PCI_DSS_321_Autoscaling_1 as Rule,
45+
{ ...data } as any
46+
)
47+
2948
expect(processedRule.result).toBe(Result.FAIL)
3049
})
3150

32-
test('Should fail when it contains a valid health check type and zero load balancers', async () => {
51+
test('Should pass when it contains a valid health check type and zero load balancers', async () => {
3352
const data = {
3453
queryawsAsg: [
3554
{
@@ -45,7 +64,7 @@ describe('PCI Data Security Standard: 3.2.1', () => {
4564
{ ...data } as any
4665
)
4766

48-
expect(processedRule.result).toBe(Result.FAIL)
67+
expect(processedRule.result).toBe(Result.PASS)
4968
})
5069

5170
test('Should pass when it contains a valid health check type and at least one load balancer', async () => {

0 commit comments

Comments
 (0)