Skip to content

Commit

Permalink
[backend] No delete on endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelHassine committed Jun 18, 2024
1 parent 3c22da8 commit ae5f5ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void run() {
// This is NOT a standard behaviour, this is because we are using Caldera as an executor and we should not
// Will be replaced by the XTM agent
List<Agent> agents = this.client.agents().stream().filter(agent -> !agent.getExe_name().contains("implant")).toList();
List<Endpoint> endpoints = toEndpoint(agents).stream().filter(Asset::getActive).toList();
List<Endpoint> endpoints = toEndpoint(agents).stream().toList();
log.info("Caldera executor provisioning based on " + endpoints.size() + " assets");
endpoints.forEach(endpoint -> {
List<Endpoint> existingEndpoints = this.endpointService.findAssetsForInjectionByHostname(endpoint.getHostname()).stream().filter(endpoint1 -> Arrays.stream(endpoint1.getIps()).anyMatch(s -> Arrays.stream(endpoint.getIps()).toList().contains(s))).toList();
Expand All @@ -119,7 +119,8 @@ public void run() {
if (optionalExistingEndpoint.isPresent()) {
Endpoint existingEndpoint = optionalExistingEndpoint.get();
log.info("Found stale agent " + existingEndpoint.getName() + ", deleting it...");
this.endpointService.deleteEndpoint(existingEndpoint.getId());
// No delete the endpoint for the moment
// this.endpointService.deleteEndpoint(existingEndpoint.getId());
this.client.deleteAgent(existingEndpoint);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public TaniumExecutorService(
public void run() {
log.info("Running Tanium executor endpoints gathering...");
List<NodeEndpoint> nodeEndpoints = this.client.endpoints().getData().getEndpoints().getEdges().stream().toList();
List<Endpoint> endpoints = toEndpoint(nodeEndpoints).stream().filter(Asset::getActive).toList();
List<Endpoint> endpoints = toEndpoint(nodeEndpoints).stream().toList();
log.info("Tanium executor provisioning based on " + endpoints.size() + " assets");
endpoints.forEach(endpoint -> {
List<Endpoint> existingEndpoints = this.endpointService.findAssetsForInjectionByHostname(endpoint.getHostname()).stream().filter(endpoint1 -> Arrays.stream(endpoint1.getIps()).anyMatch(s -> Arrays.stream(endpoint.getIps()).toList().contains(s))).toList();
Expand All @@ -108,15 +108,6 @@ public void run() {
this.updateEndpoint(endpoint, existingEndpoints);
}
});
List<Endpoint> inactiveEndpoints = toEndpoint(nodeEndpoints).stream().filter(endpoint -> !endpoint.getActive()).toList();
inactiveEndpoints.forEach(endpoint -> {
Optional<Endpoint> optionalExistingEndpoint = this.endpointService.findByExternalReference(endpoint.getExternalReference());
if (optionalExistingEndpoint.isPresent()) {
Endpoint existingEndpoint = optionalExistingEndpoint.get();
log.info("Found stale endpoint " + existingEndpoint.getName() + ", deleting it...");
this.endpointService.deleteEndpoint(existingEndpoint.getId());
}
});
}

// -- PRIVATE --
Expand Down

0 comments on commit ae5f5ce

Please sign in to comment.