diff --git a/x-pack/plugins/ingest_manager/server/services/agents/acks.ts b/x-pack/plugins/ingest_manager/server/services/agents/acks.ts index e9464e7a62c7..892d8cdbe657 100644 --- a/x-pack/plugins/ingest_manager/server/services/agents/acks.ts +++ b/x-pack/plugins/ingest_manager/server/services/agents/acks.ts @@ -36,7 +36,7 @@ export async function acknowledgeAgentActions( const matchedUpdatedActions: AgentAction[] = []; agentEvents.forEach(agentEvent => { - if (ALLOWED_ACKNOWLEDGEMENT_TYPE.indexOf(agentEvent.type) < 0) { + if (!isAllowedType(agentEvent.type)) { throw Boom.badRequest(`${agentEvent.type} not allowed for acknowledgment only ACTION_RESULT`); } if (agentActionMap.has(agentEvent.action_id!)) { @@ -59,6 +59,10 @@ export async function acknowledgeAgentActions( return matchedUpdatedActions; } +function isAllowedType(eventType: string): boolean { + return ALLOWED_ACKNOWLEDGEMENT_TYPE.indexOf(eventType) >= 0; +} + export async function saveAgentEvents( soClient: SavedObjectsClientContract, events: AgentEvent[]