Skip to content

Commit

Permalink
Website: Update Vanta script for Fleet's integration (#23514)
Browse files Browse the repository at this point in the history
Related to: #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 <[email protected]>
  • Loading branch information
eashaw and iansltx authored Nov 5, 2024
1 parent 2f54879 commit 3bfbc56
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions website/scripts/send-data-to-vanta.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const userAgent = 'Fleet/Vanta Updater';

module.exports = {


Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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';
});
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 3bfbc56

Please sign in to comment.