From cd462fba3bb29bacaeba2c592cc3a9bed2fb48db Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 2 Nov 2023 16:01:44 -0500 Subject: [PATCH] 2023-11-01 Website: Update script for Vanta integration (#14807) Closes: #14751 Changes: - Added new errors that are thrown if the response from the `/hosts/{id}` endpoint does not contain a `host` object. --- website/scripts/send-data-to-vanta.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/website/scripts/send-data-to-vanta.js b/website/scripts/send-data-to-vanta.js index 2e7e2a3407..d8dd0c4526 100644 --- a/website/scripts/send-data-to-vanta.js +++ b/website/scripts/send-data-to-vanta.js @@ -8,6 +8,7 @@ module.exports = { fn: async function () { + let util = require('util'); // Find all VantaConnection records with isConnectedToVanta: true let allActiveVantaConnections = await VantaConnection.find({isConnectedToVanta: true}); @@ -198,6 +199,10 @@ module.exports = { return new Error(`When sending a request to the Fleet instance's /hosts/${host.id} endpoint for a Vanta connection (id: ${connectionIdAsString}), an error occurred: ${err}`); }); + if(!detailedInformationAboutThisHost.host) { + throw new Error(`When sending a request to the Fleet instance's /hosts/${host.id} endpoint for a Vanta connection (id: ${connectionIdAsString}), the response from the Fleet API did not include a host. Response from the Fleet API: ${util.inspect(detailedInformationAboutThisHost)}`); + } + if (detailedInformationAboutThisHost.host.disk_encryption_enabled !== undefined && detailedInformationAboutThisHost.host.disk_encryption_enabled !== null) { // Build a drive object for this host, using the host's disk_encryption_enabled value to set the boolean values for `encrytped` and `filevaultEnabled` let driveInformationForThisHost = { @@ -283,6 +288,10 @@ module.exports = { return new Error(`When sending a request to the Fleet instance's /hosts/${host.id} endpoint for a Vanta connection (id: ${connectionIdAsString}), an error occurred: ${err}`); }); + if(!detailedInformationAboutThisHost.host){ + throw new Error(`When sending a request to the Fleet instance's /hosts/${host.id} endpoint for a Vanta connection (id: ${connectionIdAsString}), the response from the Fleet API did not include a host. Response from the Fleet API: ${util.inspect(detailedInformationAboutThisHost)}`); + } + if (detailedInformationAboutThisHost.host.disk_encryption_enabled !== undefined && detailedInformationAboutThisHost.host.disk_encryption_enabled !== null) { // Build a drive object for this host, using the host's disk_encryption_enabled value to set the boolean values for `encrytped` and `filevaultEnabled` let driveInformationForThisHost = {