From 800c527b95d248fe550b02c20eab6f5632ab5b17 Mon Sep 17 00:00:00 2001 From: lucamrgs <39555424+lucamrgs@users.noreply.github.com> Date: Mon, 20 Jan 2025 15:01:52 +0100 Subject: [PATCH] slight improvement unit interface --- pkg/api/manual/manual_api.go | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/pkg/api/manual/manual_api.go b/pkg/api/manual/manual_api.go index 85fb1670..eb33e96c 100644 --- a/pkg/api/manual/manual_api.go +++ b/pkg/api/manual/manual_api.go @@ -10,6 +10,7 @@ import ( "soarca/internal/logger" "soarca/pkg/core/capability/manual/interaction" "soarca/pkg/models/api" + "soarca/pkg/models/cacao" "soarca/pkg/models/execution" "soarca/pkg/models/manual" @@ -166,15 +167,8 @@ func (manualHandler *ManualHandler) PostContinue(g *gin.Context) { return } - for varName, variable := range outArgsUpdate.ResponseOutArgs { - if varName != variable.Name { - log.Error("variable name mismatch") - apiError.SendErrorResponse(g, http.StatusBadRequest, - "Variable name mismatch", - "POST /manual/continue", "") - return - } - } + // Check if variable names match + manualHandler.postContinueVariableNamesMatchCheck(outArgsUpdate.ResponseOutArgs, g) // Create object to pass to interaction capability executionId, err := uuid.Parse(outArgsUpdate.ExecutionId) @@ -246,3 +240,15 @@ func (manualHandler *ManualHandler) parseCommandInfoToResponse(commandInfo manua return response } + +func (ManualHandler *ManualHandler) postContinueVariableNamesMatchCheck(outArgs cacao.Variables, g *gin.Context) { + for varName, variable := range outArgs { + if varName != variable.Name { + log.Error("variable name mismatch") + apiError.SendErrorResponse(g, http.StatusBadRequest, + "Variable name mismatch", + "POST /manual/continue", "") + return + } + } +}