@@ -224,15 +224,19 @@ public List<Asset> syncAgentsEndpoints(
224
224
Arrays .asList (input .getMacAddresses ()).contains (macAddress )))
225
225
.findFirst ();
226
226
if (optionalInputToSave .isPresent ()) {
227
- final AgentRegisterInput inputToSave = optionalInputToSave .get ();
228
- setUpdatedEndpointAttributes (endpointToUpdate , inputToSave );
229
- agentToSave = new Agent ();
230
- setNewAgentAttributes (inputToSave , agentToSave );
231
- setUpdatedAgentAttributes (agentToSave , inputToSave , endpointToUpdate );
232
- endpointsToSave .add (endpointToUpdate );
233
- agentsToSave .add (agentToSave );
234
- inputs .removeIf (
235
- input -> Arrays .equals (input .getMacAddresses (), inputToSave .getMacAddresses ()));
227
+ // If no existing agent Crowdstrike in this endpoint, add to it
228
+ if (existingAgents .stream ()
229
+ .noneMatch (agent -> agent .getAsset ().getId ().equals (endpointToUpdate .getId ()))) {
230
+ final AgentRegisterInput inputToSave = optionalInputToSave .get ();
231
+ setUpdatedEndpointAttributes (endpointToUpdate , inputToSave );
232
+ agentToSave = new Agent ();
233
+ setNewAgentAttributes (inputToSave , agentToSave );
234
+ setUpdatedAgentAttributes (agentToSave , inputToSave , endpointToUpdate );
235
+ endpointsToSave .add (endpointToUpdate );
236
+ agentsToSave .add (agentToSave );
237
+ inputs .removeIf (
238
+ input -> Arrays .equals (input .getMacAddresses (), inputToSave .getMacAddresses ()));
239
+ }
236
240
}
237
241
}
238
242
}
0 commit comments