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 keyVaultSecretExpiry #2108

Merged
merged 4 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion plugins/azure/keyvaults/keyVaultSecretExpiry.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var async = require('async');
var helpers = require('../../../helpers/azure');

module.exports = {
title: 'Key Vault Secret Expiry',
title: 'Key Vault Secret Expiry RBAC',
category: 'Key Vaults',
domain: 'Application Integration',
severity: 'High',
Expand Down Expand Up @@ -46,6 +46,13 @@ module.exports = {
}

vaults.data.forEach(function(vault) {
// Check if vault is RBAC-enabled
if (!vault.properties || !vault.properties.enableRbacAuthorization) {
helpers.addResult(results, 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we skip the results for non rbac key?

'Key Vault is not RBAC-enabled', location, vault.id);
return;
}

var secrets = helpers.addSource(cache, source,
['vaults', 'getSecrets', location, vault.id]);

Expand Down
22 changes: 20 additions & 2 deletions plugins/azure/keyvaults/keyVaultSecretExpiry.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const listKeyVaults = [
"sku": {
"family": "A",
"name": "Standard"
},
"properties": {
"enableRbacAuthorization": true
}
},
{
Expand All @@ -31,6 +34,9 @@ const listKeyVaults = [
"sku": {
"family": "A",
"name": "Standard"
},
"properties": {
"enableRbacAuthorization": false
}
}
];
Expand Down Expand Up @@ -152,7 +158,19 @@ describe('keyVaultSecretExpiry', function() {
auth.run(createCache(null, [], {}), {}, callback);
});

it('should give passing result if secret expiration is not enabled', function(done) {
it('should give passing result if vault is not RBAC-enabled', function(done) {
const callback = (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(0);
expect(results[0].message).to.include('Key Vault is not RBAC-enabled');
expect(results[0].region).to.equal('eastus');
done()
};

auth.run(createCache(null, [listKeyVaults[1]], {}), {}, callback);
});

it('should give passing result if secret expiration is not enabled in RBAC vault', function(done) {
const callback = (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(0);
Expand All @@ -164,7 +182,7 @@ describe('keyVaultSecretExpiry', function() {
auth.run(createCache(null, [listKeyVaults[0]], getSecrets[0]), {}, callback);
});

it('should give passing result if secret expiry is not yet reached', function(done) {
it('should give passing result if secret expiry is not yet reached in RBAC vault', function(done) {
const callback = (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(0);
Expand Down
Loading