From 3bfbc5654c41e661bf44caaf4124db375b705c03 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 5 Nov 2024 11:02:27 -0600 Subject: [PATCH] Website: Update Vanta script for Fleet's integration (#23514) Related to: https://github.com/fleetdm/fleet/issues/19312 Changes: - Updated the send-data-to-vanta script to exclude hosts on a specific team when it runs for Fleet's Vanta integration. --------- Co-authored-by: Ian Littman --- website/scripts/send-data-to-vanta.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/website/scripts/send-data-to-vanta.js b/website/scripts/send-data-to-vanta.js index 46798b8d6f22..0128a6c59cf8 100644 --- a/website/scripts/send-data-to-vanta.js +++ b/website/scripts/send-data-to-vanta.js @@ -1,3 +1,5 @@ +const userAgent = 'Fleet/Vanta Updater'; + module.exports = { @@ -63,7 +65,7 @@ module.exports = { responseFromUserEndpoint = await sails.helpers.http.get( updatedRecord.fleetInstanceUrl + '/api/v1/fleet/users', {}, - {'Authorization': 'Bearer '+updatedRecord.fleetApiKey } + {'Authorization': 'Bearer '+updatedRecord.fleetApiKey, 'User-Agent': userAgent } ) .retry() .tolerate((err)=>{// If an error occurs while sending a request to the Fleet instance, we'll add the error to the errorReportById object, with this connections ID set as the key. @@ -136,7 +138,7 @@ module.exports = { let getHostsResponse = await sails.helpers.http.get( `${updatedRecord.fleetInstanceUrl}/api/v1/fleet/hosts?per_page=${numberOfHostsPerRequest}&page=${pageNumberForPossiblePaginatedResults}`, {}, - {'Authorization': 'bearer '+updatedRecord.fleetApiKey}, + {'Authorization': 'bearer '+updatedRecord.fleetApiKey, 'User-Agent': userAgent}, ) .retry(); // Add the results to the allHostsOnThisFleetInstance array. @@ -154,6 +156,14 @@ module.exports = { return; } + // If this is Fleet's Vanta connection, exclude hosts on the "Compliance exclusions" team. + // See https://github.com/fleetdm/fleet/issues/19312 for more information. + if(vantaConnection.id === 3){ + allHostsOnThisFleetInstance = allHostsOnThisFleetInstance.filter((host)=>{ + return host.team_id !== 178;// Compliance exclusions team + }); + } + let macOsHosts = allHostsOnThisFleetInstance.filter((host)=>{ return host.platform === 'darwin'; }); @@ -203,7 +213,7 @@ module.exports = { let detailedInformationAboutThisHost = await sails.helpers.http.get( updatedRecord.fleetInstanceUrl + '/api/v1/fleet/hosts/'+encodeURIComponent(hostIdAsString), {}, - {'Authorization': 'bearer '+updatedRecord.fleetApiKey} + {'Authorization': 'bearer '+updatedRecord.fleetApiKey, 'User-Agent': userAgent} ) .retry() .intercept((err)=>{// If an error occurs while sending a request to the Fleet instance, we'll throw an error. @@ -291,7 +301,7 @@ module.exports = { let detailedInformationAboutThisHost = await sails.helpers.http.get( updatedRecord.fleetInstanceUrl + '/api/v1/fleet/hosts/'+encodeURIComponent(hostIdAsString), {}, - {'Authorization': 'bearer '+updatedRecord.fleetApiKey} + {'Authorization': 'bearer '+updatedRecord.fleetApiKey, 'User-Agent': userAgent} ) .retry() .intercept((err)=>{// If an error occurs while sending a request to the Fleet instance, we'll throw an error.