Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revised diskByokEncryptionEnabled #2103

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions plugins/azure/virtualmachines/diskByokEncryptionEnabled.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
var async = require('async');

var helpers = require('../../../helpers/azure/');
var helpers = require('../../../helpers/azure');

module.exports = {
title: 'Disk Volumes BYOK Encryption Enabled',
title: 'Attached Disk Volumes BYOK Encryption Enabled',
category: 'Virtual Machines',
domain: 'Compute',
severity: 'High',
description: 'Ensures that Azure virtual machine disks have BYOK (Customer-Managed Key) encryption enabled.',
description: 'Ensures that attached Azure virtual machine disks have BYOK (Customer-Managed Key) encryption enabled.',
more_info: 'Encrypting virtual machine disk volumes helps protect and safeguard your data to meet organizational security and compliance commitments.',
recommended_action: 'Ensure that virtual machine disks are created using BYOK encryption',
link: 'https://learn.microsoft.com/en-us/azure/virtual-machines/windows/disk-encryption-key-vault',
Expand Down Expand Up @@ -35,13 +35,15 @@ module.exports = {
}

async.each(disks.data, function(disk, scb) {
if (disk.encryption && disk.encryption.type &&
(disk.encryption.type === 'EncryptionAtRestWithCustomerKey' ||
disk.encryption.type === 'EncryptionAtRestWithPlatformAndCustomerKeys')) {
helpers.addResult(results, 0, 'Disk volume has BYOK encryption enabled', location, disk.id);
} else {
helpers.addResult(results, 2, 'Disk volume has BYOK encryption disabled', location, disk.id);
}
if (disk.diskState && disk.diskState.toLowerCase() === 'attached') {
if (disk.encryption && disk.encryption.type &&
(disk.encryption.type === 'EncryptionAtRestWithCustomerKey' ||
disk.encryption.type === 'EncryptionAtRestWithPlatformAndCustomerKeys')) {
helpers.addResult(results, 0, 'Disk volume has BYOK encryption enabled', location, disk.id);
} else {
helpers.addResult(results, 2, 'Disk volume has BYOK encryption disabled', location, disk.id);
}
}
scb();
}, function() {
rcb();
Expand Down
13 changes: 13 additions & 0 deletions plugins/azure/virtualmachines/diskByokEncryptionEnabled.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const disks = [
'id': '/subscriptions/123/resourceGroups/aqua-resource-group/providers/Microsoft.Compute/disks/test',
'type': 'Microsoft.Compute/disks',
'location': 'eastus',
'diskState': 'Attached',
'encryption': {
'type': 'EncryptionAtRestWithPlatformKey'
}
Expand All @@ -16,6 +17,7 @@ const disks = [
'id': '/subscriptions/123/resourceGroups/aqua-resource-group/providers/Microsoft.Compute/disks/test',
'type': 'Microsoft.Compute/disks',
'location': 'eastus',
'diskState': 'Attached',
'encryption': {
'type': 'EncryptionAtRestWithCustomerKey',
'diskEncryptionSetId': '/subscriptions/123/resourceGroups/AQUA-RESOURCE-GROUP/providers/Microsoft.Compute/diskEncryptionSets/test-encrypt-set'
Expand All @@ -26,10 +28,21 @@ const disks = [
'id': '/subscriptions/123/resourceGroups/aqua-resource-group/providers/Microsoft.Compute/disks/test',
'type': 'Microsoft.Compute/disks',
'location': 'eastus',
'diskState': 'Attached',
'encryption': {
'type': 'EncryptionAtRestWithPlatformAndCustomerKeys',
'diskEncryptionSetId': '/subscriptions/123/resourceGroups/AQUA-RESOURCE-GROUP/providers/Microsoft.Compute/diskEncryptionSets/test-encrypt-set'
}
},
{
'name': 'test',
'id': '/subscriptions/123/resourceGroups/aqua-resource-group/providers/Microsoft.Compute/disks/test',
'type': 'Microsoft.Compute/disks',
'location': 'eastus',
'diskState': 'Unattached',
'encryption': {
'type': 'EncryptionAtRestWithPlatformKey'
}
}
];

Expand Down
Loading