Skip to content

Commit

Permalink
fix: AthenaWorkgroupEncryptedQueryResults property deprecation errors (
Browse files Browse the repository at this point in the history
  • Loading branch information
dontirun authored Apr 23, 2022
1 parent d91aaef commit bb23593
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 117 deletions.
74 changes: 18 additions & 56 deletions src/rules/athena/AthenaWorkgroupEncryptedQueryResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,62 +17,24 @@ export default Object.defineProperty(
const workGroupConfiguration = Stack.of(node).resolve(
node.workGroupConfiguration
);
if (workGroupConfiguration == undefined) {
const workGroupConfigurationUpdates = Stack.of(node).resolve(
node.workGroupConfigurationUpdates
);
if (workGroupConfigurationUpdates == undefined) {
return NagRuleCompliance.NON_COMPLIANT;
}
const resultConfigurationUpdates = Stack.of(node).resolve(
workGroupConfigurationUpdates.resultConfigurationUpdates
);
if (resultConfigurationUpdates != undefined) {
const removeEncryptionConfiguration = NagRules.resolveIfPrimitive(
node,
resultConfigurationUpdates.removeEncryptionConfiguration
);
const encryptionConfiguration = Stack.of(node).resolve(
resultConfigurationUpdates.encryptionConfiguration
);
const enforceWorkGroupConfiguration = NagRules.resolveIfPrimitive(
node,
workGroupConfigurationUpdates.enforceWorkGroupConfiguration
);
if (
removeEncryptionConfiguration &&
encryptionConfiguration == undefined
) {
return NagRuleCompliance.NON_COMPLIANT;
} else if (
encryptionConfiguration != undefined &&
!enforceWorkGroupConfiguration
) {
return NagRuleCompliance.NON_COMPLIANT;
}
}
} else {
const enforceWorkGroupConfiguration = NagRules.resolveIfPrimitive(
node,
workGroupConfiguration.enforceWorkGroupConfiguration
);
if (!enforceWorkGroupConfiguration) {
return NagRuleCompliance.NON_COMPLIANT;
}
const resultConfiguration = Stack.of(node).resolve(
workGroupConfiguration.resultConfiguration
);

if (resultConfiguration == undefined) {
return NagRuleCompliance.NON_COMPLIANT;
}
const encryptionConfiguration = Stack.of(node).resolve(
resultConfiguration.encryptionConfiguration
);

if (encryptionConfiguration == undefined) {
return NagRuleCompliance.NON_COMPLIANT;
}
const enforceWorkGroupConfiguration = NagRules.resolveIfPrimitive(
node,
workGroupConfiguration?.enforceWorkGroupConfiguration
);
if (!enforceWorkGroupConfiguration) {
return NagRuleCompliance.NON_COMPLIANT;
}
const resultConfiguration = Stack.of(node).resolve(
workGroupConfiguration.resultConfiguration
);
if (resultConfiguration === undefined) {
return NagRuleCompliance.NON_COMPLIANT;
}
const encryptionConfiguration = Stack.of(node).resolve(
resultConfiguration.encryptionConfiguration
);
if (encryptionConfiguration === undefined) {
return NagRuleCompliance.NON_COMPLIANT;
}
return NagRuleCompliance.COMPLIANT;
} else {
Expand Down
61 changes: 0 additions & 61 deletions test/rules/Athena.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,43 +60,6 @@ describe('Amazon Athena', () => {
});
validateStack(stack, ruleId, TestType.NON_COMPLIANCE);
});
test('Noncompliance 5', () => {
new CfnWorkGroup(stack, 'rWorkgroup', {
name: 'foo',
workGroupConfigurationUpdates: {
enforceWorkGroupConfiguration: false,
resultConfigurationUpdates: {
removeEncryptionConfiguration: true,
},
},
});
validateStack(stack, ruleId, TestType.NON_COMPLIANCE);
});
test('Noncompliance 6', () => {
new CfnWorkGroup(stack, 'rWorkgroup', {
name: 'foo',
workGroupConfigurationUpdates: {
enforceWorkGroupConfiguration: true,
resultConfigurationUpdates: {
removeEncryptionConfiguration: true,
},
},
});
validateStack(stack, ruleId, TestType.NON_COMPLIANCE);
});
test('Noncompliance 7', () => {
new CfnWorkGroup(stack, 'rWorkgroup', {
name: 'foo',
workGroupConfigurationUpdates: {
resultConfigurationUpdates: {
encryptionConfiguration: {
encryptionOption: 'SSE_S3',
},
},
},
});
validateStack(stack, ruleId, TestType.NON_COMPLIANCE);
});
test('Compliance', () => {
new CfnWorkGroup(stack, 'rWorkgroup', {
name: 'foo',
Expand All @@ -109,30 +72,6 @@ describe('Amazon Athena', () => {
},
},
});
new CfnWorkGroup(stack, 'rWorkgroup2', {
name: 'foo',
workGroupConfigurationUpdates: {
enforceWorkGroupConfiguration: true,
resultConfigurationUpdates: {
encryptionConfiguration: {
encryptionOption: 'SSE_S3',
},
},
},
});
new CfnWorkGroup(stack, 'rWorkgroup3', {
name: 'foo',
workGroupConfigurationUpdates: {
requesterPaysEnabled: true,
},
});
new CfnWorkGroup(stack, 'rWorkgroup4', {
name: 'foo',
workGroupConfigurationUpdates: {
enforceWorkGroupConfiguration: true,
requesterPaysEnabled: true,
},
});
validateStack(stack, ruleId, TestType.COMPLIANCE);
});
});
Expand Down

0 comments on commit bb23593

Please sign in to comment.