From 67969e25a7bcb786fec82f79806123c7a95958cb Mon Sep 17 00:00:00 2001 From: AkhtarAmir Date: Thu, 7 Nov 2024 17:23:15 +0500 Subject: [PATCH] Revised enableDefenderForSqlSever function --- plugins/azure/defender/enableDefenderForSqlServers.js | 11 +---------- .../defender/enableDefenderForSqlServers.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/plugins/azure/defender/enableDefenderForSqlServers.js b/plugins/azure/defender/enableDefenderForSqlServers.js index 6b7e12c444..b529d9665f 100644 --- a/plugins/azure/defender/enableDefenderForSqlServers.js +++ b/plugins/azure/defender/enableDefenderForSqlServers.js @@ -50,16 +50,7 @@ module.exports = { return callback(null, results, source); } - - let pricingData = pricings.data.find((pricing) => pricing.name.toLowerCase() === serviceName); - - if (pricingData && pricingData.pricingTier && pricingData.pricingTier.toLowerCase() === 'standard') { - helpers.addResult(results, 0, - `Azure Defender is enabled for ${serviceDisplayName} at subscription level`, 'global', pricingData.id); - } else { - helpers.addResult(results, 2, - `Azure Defender is not enabled for ${serviceDisplayName} at subscription level`, 'global'); - } + helpers.checkMicrosoftDefender(pricings, serviceName, serviceDisplayName, results, 'global'); return callback(null, results, source); } diff --git a/plugins/azure/defender/enableDefenderForSqlServers.spec.js b/plugins/azure/defender/enableDefenderForSqlServers.spec.js index 2c43f00caa..fd4808c7b7 100644 --- a/plugins/azure/defender/enableDefenderForSqlServers.spec.js +++ b/plugins/azure/defender/enableDefenderForSqlServers.spec.js @@ -17,7 +17,7 @@ describe('enableDefenderForSqlServers', function() { plugin.run(cache, settings, (err, results) => { expect(results.length).to.equal(1); expect(results[0].status).to.equal(0); - expect(results[0].message).to.include('Azure Defender is enabled for SQL Servers at subscription level'); + expect(results[0].message).to.include('Azure Defender is enabled for SQL Servers'); done(); }); }); @@ -35,7 +35,7 @@ describe('enableDefenderForSqlServers', function() { plugin.run(cache, settings, (err, results) => { expect(results.length).to.equal(1); expect(results[0].status).to.equal(2); - expect(results[0].message).to.include('Azure Defender is not enabled for SQL Servers at subscription level'); + expect(results[0].message).to.include('Azure Defender is not enabled for SQL Servers'); done(); }); });