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 <iansltx@gmail.com>
This commit is contained in:
Eric
2024-11-05 11:02:27 -06:00
committed by GitHub
co-authored by Ian Littman
parent 2f54879f2a
commit 3bfbc5654c
+14 -4
View File
@@ -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.