Skip to content

Commit ad3f2e2

Browse files
authored
Merge pull request #135 from cloudgraphdev/fix/CG-1335-aws-pci-iam-1
fix(CG-1335): AWS PCI IAM 1 rule fix
2 parents 2ff7f32 + f6c9f40 commit ad3f2e2

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,19 @@ export default {
3434
'https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-pci-controls.html',
3535
],
3636
gql: `{
37-
queryawsIamUser {
37+
queryawsIamUser(filter: { name: { eq: "root" } }) {
3838
id
3939
arn
4040
accountId
41-
__typename
42-
name
41+
__typename
42+
accessKeysActive
4343
}
4444
}`,
45+
exclude: { not: { path: '@.name', equal: 'root' } },
4546
resource: 'queryawsIamUser[*]',
4647
severity: 'high',
4748
conditions: {
48-
path: '@.name',
49-
notEqual: 'root',
49+
path: '@.accessKeysActive',
50+
equal: false,
5051
},
5152
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ describe('PCI Data Security Standard: 3.2.1', () => {
1818
})
1919

2020
describe('IAM Check 1: IAM root user access key should not exist', () => {
21-
test('Should fail when it finds a user called root', async () => {
21+
test('Should fail when root account has at least one access key active', async () => {
2222
const data = {
2323
queryawsIamUser: [
2424
{
2525
id: cuid(),
2626
name: 'root',
27+
accessKeysActive: true,
2728
},
2829
],
2930
}
@@ -36,12 +37,13 @@ describe('PCI Data Security Standard: 3.2.1', () => {
3637
expect(processedRule.result).toBe(Result.FAIL)
3738
})
3839

39-
test('Should pass when it does not find a user called root', async () => {
40+
test('Should pass when a root account does not have any access key active', async () => {
4041
const data = {
4142
queryawsIamUser: [
4243
{
4344
id: cuid(),
44-
name: 'user',
45+
name: 'root',
46+
accessKeysActive: false,
4547
},
4648
],
4749
}

0 commit comments

Comments
 (0)