diff --git a/pkg/core/capability/capability.go b/pkg/core/capability/capability.go index 25eeb72d..d9090b14 100644 --- a/pkg/core/capability/capability.go +++ b/pkg/core/capability/capability.go @@ -6,7 +6,7 @@ import ( ) type Context struct { - Command cacao.Command + CommandData cacao.CommandData Step cacao.Step Authentication cacao.AuthenticationInformation Target cacao.AgentTarget diff --git a/pkg/core/capability/fin/fin.go b/pkg/core/capability/fin/fin.go index ad89a57c..841b748a 100644 --- a/pkg/core/capability/fin/fin.go +++ b/pkg/core/capability/fin/fin.go @@ -34,7 +34,7 @@ func (finCapability *FinCapability) Execute( context capability.Context) (cacao.Variables, error) { finCommand := finModel.NewCommand() - finCommand.CommandSubstructure.Command = context.Command.Command + finCommand.CommandSubstructure.Command = context.CommandData.Command finCommand.CommandSubstructure.Authentication = context.Authentication finCommand.CommandSubstructure.Variables = context.Variables finCommand.CommandSubstructure.Context.ExecutionId = metadata.ExecutionId.String() diff --git a/pkg/core/capability/fin/fin_test.go b/pkg/core/capability/fin/fin_test.go index 05e7ce05..ea6631e9 100644 --- a/pkg/core/capability/fin/fin_test.go +++ b/pkg/core/capability/fin/fin_test.go @@ -23,7 +23,7 @@ func TestFinExecution(t *testing.T) { var metadata = execution.Metadata{ExecutionId: executionId, PlaybookId: playbookId.String(), StepId: stepId.String()} - command := cacao.Command{Type: "soarca-fin", Command: "test command"} + command := cacao.CommandData{Type: "soarca-fin", Command: "test command"} auth := cacao.AuthenticationInformation{} auth.Name = "some auth" auth.Username = "user" @@ -52,7 +52,7 @@ func TestFinExecution(t *testing.T) { expectedVariableMap := cacao.NewVariables(variable1) data := capability.Context{ - Command: command, + CommandData: command, Authentication: auth, Target: target, Variables: inputVariable, diff --git a/pkg/core/capability/http/http.go b/pkg/core/capability/http/http.go index e9133a21..ace6f560 100644 --- a/pkg/core/capability/http/http.go +++ b/pkg/core/capability/http/http.go @@ -46,7 +46,7 @@ func (httpCapability *HttpCapability) Execute( soarca_http_options := http.HttpOptions{ Target: &context.Target, - Command: &context.Command, + Command: &context.CommandData, Auth: &context.Authentication, } diff --git a/pkg/core/capability/http/http_test.go b/pkg/core/capability/http/http_test.go index c2b60283..1976855a 100644 --- a/pkg/core/capability/http/http_test.go +++ b/pkg/core/capability/http/http_test.go @@ -30,7 +30,7 @@ func TestHTTPOptionsCorrectlyGenerated(t *testing.T) { target := cacao.AgentTarget{Address: map[cacao.NetAddressType][]string{ "url": {"https://httpbin.org/post"}, }} - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -58,7 +58,7 @@ func TestHTTPOptionsCorrectlyGenerated(t *testing.T) { mock_http_request.On("Request", httpOptions).Return(payload_byte, nil) data := capability.Context{ - Command: command, + CommandData: command, Authentication: oauth2_info, Target: target, Variables: cacao.NewVariables(variable1), @@ -84,7 +84,7 @@ func TestHTTPOptionsEmptyAuth(t *testing.T) { target := cacao.AgentTarget{Address: map[cacao.NetAddressType][]string{ "url": {"https://httpbin.org/post"}, }} - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -113,7 +113,7 @@ func TestHTTPOptionsEmptyAuth(t *testing.T) { mock_http_request.On("Request", httpOptions).Return(payload_byte, nil) data := capability.Context{ - Command: command, + CommandData: command, Authentication: *empty_auth, Target: target, Variables: cacao.NewVariables(variable1), @@ -139,7 +139,7 @@ func TestHTTPOptionsEmptyCommand(t *testing.T) { target := cacao.AgentTarget{Address: map[cacao.NetAddressType][]string{ "url": {"https://httpbin.org/post"}, }} - empty_command := new(cacao.Command) + empty_command := new(cacao.CommandData) var oauth2_info = cacao.AuthenticationInformation{ ID: "6ba7b810-9dad-11d1-80b4-00c04fd430c9", @@ -168,7 +168,7 @@ func TestHTTPOptionsEmptyCommand(t *testing.T) { mock_http_request.On("Request", httpOptions).Return([]byte{}, expected_error) data := capability.Context{ - Command: *empty_command, + CommandData: *empty_command, Authentication: oauth2_info, Target: target, Variables: cacao.NewVariables(variable1), diff --git a/pkg/core/capability/openc2/openc2.go b/pkg/core/capability/openc2/openc2.go index 9ace5057..0713ed31 100644 --- a/pkg/core/capability/openc2/openc2.go +++ b/pkg/core/capability/openc2/openc2.go @@ -45,7 +45,7 @@ func (OpenC2Capability *OpenC2Capability) Execute( log.Trace(metadata.ExecutionId) httpOptions := http.HttpOptions{ - Command: &context.Command, + Command: &context.CommandData, Target: &context.Target, Auth: &context.Authentication, } diff --git a/pkg/core/capability/openc2/openc2_test.go b/pkg/core/capability/openc2/openc2_test.go index 2f94df05..a3e27d28 100644 --- a/pkg/core/capability/openc2/openc2_test.go +++ b/pkg/core/capability/openc2/openc2_test.go @@ -35,7 +35,7 @@ func TestOpenC2Request(t *testing.T) { Token: "this-is-a-test", } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -65,7 +65,7 @@ func TestOpenC2Request(t *testing.T) { mockHttp.On("Request", httpOptions).Return(payloadBytes, nil) - data := capability.Context{Command: command, + data := capability.Context{CommandData: command, Authentication: auth, Target: target, Variables: cacao.NewVariables(cacaoVariable)} diff --git a/pkg/core/capability/powershell/powershell.go b/pkg/core/capability/powershell/powershell.go index f3093b18..c54220eb 100644 --- a/pkg/core/capability/powershell/powershell.go +++ b/pkg/core/capability/powershell/powershell.go @@ -73,14 +73,14 @@ func (capability *PowershellCapability) Execute( defer cancel() effectiveCommand := "" - if capabilityContext.Command.CommandB64 != "" { - bytes, err := base64.StdEncoding.DecodeString(capabilityContext.Command.CommandB64) + if capabilityContext.CommandData.CommandB64 != "" { + bytes, err := base64.StdEncoding.DecodeString(capabilityContext.CommandData.CommandB64) if err != nil { return cacao.NewVariables(), err } effectiveCommand = string(bytes) } else { - effectiveCommand = capabilityContext.Command.Command + effectiveCommand = capabilityContext.CommandData.Command } result, stdErr, _, err := client.RunPSWithContext(ctx, effectiveCommand) diff --git a/pkg/core/capability/ssh/ssh.go b/pkg/core/capability/ssh/ssh.go index 2e27372d..a3ded7f2 100644 --- a/pkg/core/capability/ssh/ssh.go +++ b/pkg/core/capability/ssh/ssh.go @@ -37,10 +37,10 @@ func (sshCapability *SshCapability) Execute(metadata execution.Metadata, context capability.Context) (cacao.Variables, error) { log.Trace(metadata.ExecutionId) - return execute(context.Command, context.Authentication, context.Target) + return execute(context.CommandData, context.Authentication, context.Target) } -func execute(command cacao.Command, +func execute(command cacao.CommandData, authentication cacao.AuthenticationInformation, target cacao.AgentTarget) (cacao.Variables, error) { @@ -64,7 +64,7 @@ func execute(command cacao.Command, } func executeCommand(session *ssh.Session, - command cacao.Command) (cacao.Variables, error) { + command cacao.CommandData) (cacao.Variables, error) { response, err := session.Output(StripSshPrepend(command.Command)) diff --git a/pkg/core/decomposer/decomposer_test.go b/pkg/core/decomposer/decomposer_test.go index ac0923ab..4fcff38a 100644 --- a/pkg/core/decomposer/decomposer_test.go +++ b/pkg/core/decomposer/decomposer_test.go @@ -28,7 +28,7 @@ func TestExecutePlaybook(t *testing.T) { mock_reporter := new(mock_reporter.Mock_Reporter) mock_time := new(mock_time.MockTime) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -51,7 +51,7 @@ func TestExecutePlaybook(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", @@ -137,12 +137,12 @@ func TestExecutePlaybookMultiStep(t *testing.T) { mock_reporter := new(mock_reporter.Mock_Reporter) mock_time := new(mock_time.MockTime) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } - expectedCommand2 := cacao.Command{ + expectedCommand2 := cacao.CommandData{ Type: "ssh2", Command: "ssh pwd", } @@ -171,7 +171,7 @@ func TestExecutePlaybookMultiStep(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "action--test2", Agent: "agent1", @@ -184,7 +184,7 @@ func TestExecutePlaybookMultiStep(t *testing.T) { ID: "action--test2", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables2), - Commands: []cacao.Command{expectedCommand2}, + Commands: []cacao.CommandData{expectedCommand2}, Cases: map[string]string{}, Agent: "agent1", Targets: []string{"target1"}, @@ -195,7 +195,7 @@ func TestExecutePlaybookMultiStep(t *testing.T) { ID: "action--test3", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables2), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Agent: "agent1", // Targets: []string{"target1"}, } @@ -293,7 +293,7 @@ func TestExecuteEmptyMultiStep(t *testing.T) { mock_reporter := new(mock_reporter.Mock_Reporter) mock_time := new(mock_time.MockTime) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -327,7 +327,7 @@ func TestExecuteEmptyMultiStep(t *testing.T) { Name: "ssh-tests", Agent: "agent1", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "", // Empty } @@ -375,17 +375,17 @@ func TestFailingStepResultsInFailingPlaybook(t *testing.T) { mock_reporter := new(mock_reporter.Mock_Reporter) mock_time := new(mock_time.MockTime) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } - expectedCommand2 := cacao.Command{ + expectedCommand2 := cacao.CommandData{ Type: "ssh", Command: "ssh pwd", } - expectedCommand3 := cacao.Command{ + expectedCommand3 := cacao.CommandData{ Type: "ssh", Command: "ssh breakeverything.exe", } @@ -420,7 +420,7 @@ func TestFailingStepResultsInFailingPlaybook(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "action--test2", Agent: "agent1", @@ -432,7 +432,7 @@ func TestFailingStepResultsInFailingPlaybook(t *testing.T) { ID: "action--test2", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables2), - Commands: []cacao.Command{expectedCommand2}, + Commands: []cacao.CommandData{expectedCommand2}, Cases: map[string]string{}, Agent: "agent1", Targets: []string{"target1"}, @@ -443,7 +443,7 @@ func TestFailingStepResultsInFailingPlaybook(t *testing.T) { ID: "action--test3", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables2), - Commands: []cacao.Command{expectedCommand3}, + Commands: []cacao.CommandData{expectedCommand3}, Agent: "agent1", Targets: []string{"target1"}, OnCompletion: "end--test", @@ -554,7 +554,7 @@ func TestExecuteIllegalMultiStep(t *testing.T) { mock_reporter := new(mock_reporter.Mock_Reporter) mock_time := new(mock_time.MockTime) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -577,7 +577,7 @@ func TestExecuteIllegalMultiStep(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "action-some-non-existing", } @@ -705,7 +705,7 @@ func TestExecuteIfCondition(t *testing.T) { Value: "testing2", } - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -743,7 +743,7 @@ func TestExecuteIfCondition(t *testing.T) { Type: cacao.StepTypeAction, ID: "action--step-true", Name: "ssh-tests", - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Targets: []string{expectedTarget.ID}, StepVariables: cacao.NewVariables(expectedVariables), OnCompletion: endTrue.ID, @@ -759,7 +759,7 @@ func TestExecuteIfCondition(t *testing.T) { Type: cacao.StepTypeAction, ID: "action--step-false", Name: "ssh-tests", - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Targets: []string{expectedTarget.ID}, StepVariables: cacao.NewVariables(expectedVariables), OnCompletion: endFalse.ID, @@ -769,7 +769,7 @@ func TestExecuteIfCondition(t *testing.T) { Type: cacao.StepTypeAction, ID: "action--step-completion", Name: "ssh-tests", - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Targets: []string{expectedTarget.ID}, StepVariables: cacao.NewVariables(expectedVariables), OnCompletion: end.ID, @@ -877,7 +877,7 @@ func TestDelayStepExecution(t *testing.T) { mock_reporter := new(mock_reporter.Mock_Reporter) mock_time := new(mock_time.MockTime) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -893,7 +893,7 @@ func TestDelayStepExecution(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", @@ -931,7 +931,7 @@ func TestDelayStepNegativeTimeExecution(t *testing.T) { mock_reporter := new(mock_reporter.Mock_Reporter) mock_time := new(mock_time.MockTime) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -947,7 +947,7 @@ func TestDelayStepNegativeTimeExecution(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", diff --git a/pkg/core/executors/action/action.go b/pkg/core/executors/action/action.go index 7406a76c..4386c54b 100644 --- a/pkg/core/executors/action/action.go +++ b/pkg/core/executors/action/action.go @@ -40,7 +40,7 @@ type Executor struct { } type data struct { - command cacao.Command + command cacao.CommandData authentication cacao.AuthenticationInformation target cacao.AgentTarget variables cacao.Variables @@ -109,7 +109,7 @@ func (executor *Executor) executeCommandFromArray(meta execution.Metadata, return returnVariables, nil } -func interpolateCommand(command cacao.Command, variables cacao.Variables) cacao.Command { +func interpolateCommand(command cacao.CommandData, variables cacao.Variables) cacao.CommandData { command.Command = variables.Interpolate(command.Command) command.Content = variables.Interpolate(command.Content) command.ContentB64 = variables.Interpolate(command.ContentB64) @@ -152,7 +152,7 @@ func (executor *Executor) executeCommands(metadata execution.Metadata, context := capability.Context{} if capability, ok := executor.capabilities[data.agent.Name]; ok { - context.Command = interpolateCommand(data.command, data.variables) + context.CommandData = interpolateCommand(data.command, data.variables) context.Target = interpolatedTarget(data.target, data.variables) context.Authentication = interpolateAuthentication(data.authentication, data.variables) context.Variables = data.variables diff --git a/pkg/core/executors/action/action_executor_test.go b/pkg/core/executors/action/action_executor_test.go index 653569cc..6d41a9c8 100644 --- a/pkg/core/executors/action/action_executor_test.go +++ b/pkg/core/executors/action/action_executor_test.go @@ -32,7 +32,7 @@ func TestExecuteStep(t *testing.T) { metadata := execution.Metadata{ExecutionId: executionId, PlaybookId: playbookId, StepId: stepId} - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -65,7 +65,7 @@ func TestExecuteStep(t *testing.T) { ID: stepId, Description: "", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Agent: "mock-ssh", Targets: []string{"target1"}, } @@ -79,7 +79,7 @@ func TestExecuteStep(t *testing.T) { } context1 := capability.Context{ - Command: expectedCommand, + CommandData: expectedCommand, Authentication: expectedAuth, Target: expectedTarget, Variables: cacao.NewVariables(expectedVariables), @@ -123,7 +123,7 @@ func TestExecuteActionStep(t *testing.T) { metadata := execution.Metadata{ExecutionId: executionId, PlaybookId: playbookId, StepId: stepId} - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -148,7 +148,7 @@ func TestExecuteActionStep(t *testing.T) { } context1 := capability.Context{ - Command: expectedCommand, + CommandData: expectedCommand, Authentication: expectedAuth, Target: expectedTarget, Variables: cacao.NewVariables(expectedVariables), @@ -189,7 +189,7 @@ func TestNonExistingCapabilityStep(t *testing.T) { metadata := execution.Metadata{ExecutionId: executionId, PlaybookId: playbookId, StepId: stepId} - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -239,12 +239,12 @@ func TestVariableInterpolation(t *testing.T) { metadata := execution.Metadata{ExecutionId: executionId, PlaybookId: playbookId, StepId: stepId} - inputCommand := cacao.Command{ + inputCommand := cacao.CommandData{ Type: "ssh", Command: "ssh __var1__:value", } - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -366,7 +366,7 @@ func TestVariableInterpolation(t *testing.T) { Name: "cap1", } - context1 := capability.Context{Command: expectedCommand, + context1 := capability.Context{CommandData: expectedCommand, Authentication: expectedAuth, Target: expectedTarget, Variables: cacao.NewVariables(var1, var2, var3, varUser, varPassword, varOauth, varPrivateKey, varToken, varUserId, varheader1, varheader2)} @@ -390,7 +390,7 @@ func TestVariableInterpolation(t *testing.T) { mock_capability1.AssertExpectations(t) assert.Equal(t, inputCommand.Command, "ssh __var1__:value") - httpCommand := cacao.Command{ + httpCommand := cacao.CommandData{ Type: "http-api", Command: "GET / HTTP1.1", Content: "__http-api-content__:value", @@ -398,7 +398,7 @@ func TestVariableInterpolation(t *testing.T) { Headers: inputHeaders, } - expectedHttpCommand := cacao.Command{ + expectedHttpCommand := cacao.CommandData{ Type: "http-api", Command: "GET / HTTP1.1", Content: "some content of the body", @@ -407,7 +407,7 @@ func TestVariableInterpolation(t *testing.T) { } metadataHttp := execution.Metadata{ExecutionId: executionId, PlaybookId: playbookId, StepId: stepId} - contextHttp := capability.Context{Command: expectedHttpCommand, + contextHttp := capability.Context{CommandData: expectedHttpCommand, Authentication: expectedAuth, Target: expectedTarget, Variables: cacao.NewVariables(varHttpContent, varheader1, varheader2)} diff --git a/pkg/models/cacao/cacao.go b/pkg/models/cacao/cacao.go index 74b781c4..b6d1b174 100644 --- a/pkg/models/cacao/cacao.go +++ b/pkg/models/cacao/cacao.go @@ -195,7 +195,7 @@ type ExtensionDefinition struct { ExternalReferences []ExternalReferences `bson:"external_references,omitempty" json:"external_references,omitempty"` } -type Command struct { +type CommandData struct { Type string `bson:"type" json:"type" validate:"required"` Command string `bson:"command" json:"command" validate:"required"` Description string `bson:"description,omitempty" json:"description,omitempty"` @@ -220,7 +220,7 @@ type Step struct { OnCompletion string `bson:"on_completion,omitempty" json:"on_completion,omitempty"` OnSuccess string `bson:"on_success,omitempty" json:"on_success,omitempty"` OnFailure string `bson:"on_failure,omitempty" json:"on_failure,omitempty"` - Commands []Command `bson:"commands,omitempty" json:"commands,omitempty"` + Commands []CommandData `bson:"commands,omitempty" json:"commands,omitempty"` Agent string `bson:"agent,omitempty" json:"agent,omitempty"` Targets []string `bson:"targets,omitempty" json:"targets,omitempty"` InArgs []string `bson:"in_args,omitempty" json:"in_args,omitempty"` diff --git a/pkg/reporter/downstream_reporter/cache/cache_test.go b/pkg/reporter/downstream_reporter/cache/cache_test.go index e71b340d..2cfc42b2 100644 --- a/pkg/reporter/downstream_reporter/cache/cache_test.go +++ b/pkg/reporter/downstream_reporter/cache/cache_test.go @@ -18,7 +18,7 @@ func TestReportWorkflowStartFirst(t *testing.T) { mock_time := new(mock_time.MockTime) cacheReporter := New(mock_time, 10) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -35,7 +35,7 @@ func TestReportWorkflowStartFirst(t *testing.T) { Name: "ssh-tests", Description: "test step", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", @@ -150,7 +150,7 @@ func TestReportWorkflowStartFifo(t *testing.T) { mock_time := new(mock_time.MockTime) cacheReporter := New(mock_time, 3) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -167,7 +167,7 @@ func TestReportWorkflowStartFifo(t *testing.T) { Name: "ssh-tests", Description: "step description", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", @@ -296,7 +296,7 @@ func TestReportWorkflowEnd(t *testing.T) { mock_time := new(mock_time.MockTime) cacheReporter := New(mock_time, 10) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -313,7 +313,7 @@ func TestReportWorkflowEnd(t *testing.T) { Name: "ssh-tests", Description: "step 1", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", @@ -399,7 +399,7 @@ func TestReportStepStartAndEnd(t *testing.T) { mock_time := new(mock_time.MockTime) cacheReporter := New(mock_time, 10) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -415,7 +415,7 @@ func TestReportStepStartAndEnd(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", @@ -523,11 +523,11 @@ func TestReportStepStartCommandsEncoding(t *testing.T) { mock_time := new(mock_time.MockTime) cacheReporter := New(mock_time, 10) - expectedCommand1 := cacao.Command{ + expectedCommand1 := cacao.CommandData{ Type: "manual", CommandB64: b64.StdEncoding.EncodeToString([]byte("do ssh ls -la in the terminal")), } - expectedCommand2 := cacao.Command{ + expectedCommand2 := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -543,7 +543,7 @@ func TestReportStepStartCommandsEncoding(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand1, expectedCommand2}, + Commands: []cacao.CommandData{expectedCommand1, expectedCommand2}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", @@ -663,7 +663,7 @@ func TestReportStepStartManualCommand(t *testing.T) { mock_time := new(mock_time.MockTime) cacheReporter := New(mock_time, 10) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "manual", Command: "do ssh ls -la in the terminal", } @@ -679,7 +679,7 @@ func TestReportStepStartManualCommand(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", @@ -793,7 +793,7 @@ func TestInvalidStepReportAfterStepEnd(t *testing.T) { mock_time := new(mock_time.MockTime) cacheReporter := New(mock_time, 10) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -809,7 +809,7 @@ func TestInvalidStepReportAfterStepEnd(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", @@ -883,7 +883,7 @@ func TestAcceptedStepReportAfterExecutionEnd(t *testing.T) { mock_time := new(mock_time.MockTime) cacheReporter := New(mock_time, 10) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -899,7 +899,7 @@ func TestAcceptedStepReportAfterExecutionEnd(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", diff --git a/pkg/reporter/reporter_test.go b/pkg/reporter/reporter_test.go index ce0de15a..b71bed7d 100644 --- a/pkg/reporter/reporter_test.go +++ b/pkg/reporter/reporter_test.go @@ -42,7 +42,7 @@ func TestReportWorkflowStart(t *testing.T) { reporter := New([]ds_reporter.IDownStreamReporter{&mock_ds_reporter}) mock_time := new(mock_time.MockTime) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -58,7 +58,7 @@ func TestReportWorkflowStart(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", @@ -121,7 +121,7 @@ func TestReportWorkflowEnd(t *testing.T) { reporter := New([]ds_reporter.IDownStreamReporter{&mock_ds_reporter}) mock_time := new(mock_time.MockTime) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -137,7 +137,7 @@ func TestReportWorkflowEnd(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", @@ -200,7 +200,7 @@ func TestReportStepStart(t *testing.T) { reporter := New([]ds_reporter.IDownStreamReporter{&mock_ds_reporter}) mock_time := new(mock_time.MockTime) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -216,7 +216,7 @@ func TestReportStepStart(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", @@ -244,7 +244,7 @@ func TestReportStepEnd(t *testing.T) { reporter := New([]ds_reporter.IDownStreamReporter{&mock_ds_reporter}) mock_time := new(mock_time.MockTime) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -260,7 +260,7 @@ func TestReportStepEnd(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", @@ -290,7 +290,7 @@ func TestMultipleDownstreamReporters(t *testing.T) { reporter := New([]ds_reporter.IDownStreamReporter{&mock_ds_reporter1, &mock_ds_reporter2}) mock_time := new(mock_time.MockTime) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -306,7 +306,7 @@ func TestMultipleDownstreamReporters(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", diff --git a/pkg/utils/http/http.go b/pkg/utils/http/http.go index 79a2782e..28b401d4 100644 --- a/pkg/utils/http/http.go +++ b/pkg/utils/http/http.go @@ -29,7 +29,7 @@ func init() { type HttpOptions struct { Target *cacao.AgentTarget - Command *cacao.Command + Command *cacao.CommandData Auth *cacao.AuthenticationInformation } @@ -319,19 +319,19 @@ func validatePort(port string) error { return nil } -func GetMethodFrom(command *cacao.Command) (string, error) { +func GetMethodFrom(command *cacao.CommandData) (string, error) { return extractCommandFieldByIndex(command, 0) } -func GetPathFrom(command *cacao.Command) (string, error) { +func GetPathFrom(command *cacao.CommandData) (string, error) { return extractCommandFieldByIndex(command, 1) } -func GetVersionFrom(command *cacao.Command) (string, error) { +func GetVersionFrom(command *cacao.CommandData) (string, error) { return extractCommandFieldByIndex(command, 2) } -func extractCommandFieldByIndex(command *cacao.Command, index int) (string, error) { +func extractCommandFieldByIndex(command *cacao.CommandData, index int) (string, error) { if command == nil { return "", errors.New("command pointer is empty") } diff --git a/pkg/utils/http/http_test.go b/pkg/utils/http/http_test.go index ff715902..cc6316df 100644 --- a/pkg/utils/http/http_test.go +++ b/pkg/utils/http/http_test.go @@ -42,7 +42,7 @@ func TestHttpGetConnection(t *testing.T) { "url": {"https://httpbin.org/get"}, }, } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "GET / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -70,7 +70,7 @@ func TestHttpPostConnection(t *testing.T) { "url": {"https://httpbin.org/post"}, }, } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -97,7 +97,7 @@ func TestHttpPutConnection(t *testing.T) { "url": {"https://httpbin.org/put"}, }, } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "PUT / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -123,7 +123,7 @@ func TestHttpDeleteConnection(t *testing.T) { "url": {"https://httpbin.org/delete"}, }, } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "DELETE / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -151,7 +151,7 @@ func TestHttpStatus200(t *testing.T) { "url": {"https://httpbin.org/status/200"}, }, } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "GET / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -184,7 +184,7 @@ func TestHttpBearerToken(t *testing.T) { Token: bearerToken, ID: "d0c7e6a0-f7fe-464e-9935-e6b3443f5b91", } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "GET / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -232,7 +232,7 @@ func TestHttpBasicAuth(t *testing.T) { ID: "d0c7e6a0-f7fe-464e-9935-e6b3443f5b91", } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "GET / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -279,7 +279,7 @@ func TestHttpPostWithContentConnection(t *testing.T) { }, } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -325,7 +325,7 @@ func TestHttpPostWithBase64ContentConnection(t *testing.T) { }, } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -362,7 +362,7 @@ func TestHttpPathDnameParser(t *testing.T) { addresses["dname"] = []string{"soarca.tno.nl"} target := cacao.AgentTarget{Address: addresses, Port: strconv.Itoa(80)} - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST /url HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -384,7 +384,7 @@ func TestHttpPathDnamePortParser(t *testing.T) { addresses["dname"] = []string{"soarca.tno.nl"} target := cacao.AgentTarget{Address: addresses, Port: strconv.Itoa(8080)} - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST /url HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -406,7 +406,7 @@ func TestHttpPathDnameRandomPortParser(t *testing.T) { addresses["dname"] = []string{"soarca.tno.nl"} target := cacao.AgentTarget{Address: addresses, Port: strconv.Itoa(6464)} - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST /url HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -428,7 +428,7 @@ func TestHttpPathIpv4Parser(t *testing.T) { addresses["ipv4"] = []string{"127.0.0.1"} target := cacao.AgentTarget{Address: addresses, Port: strconv.Itoa(443)} - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -452,7 +452,7 @@ func TestHttpPathParser(t *testing.T) { }, } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -476,7 +476,7 @@ func TestHttpPathUrlComposition(t *testing.T) { }, } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST /isp/cst HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -502,7 +502,7 @@ func TestHttpPathBreakingParser(t *testing.T) { }, } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -520,7 +520,7 @@ func TestHttpPathBreakingParser(t *testing.T) { } func TestMethodExtract(t *testing.T) { - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST /api1/newObject HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -533,7 +533,7 @@ func TestMethodExtract(t *testing.T) { } func TestPathExtract(t *testing.T) { - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST /api1/newObject HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -546,7 +546,7 @@ func TestPathExtract(t *testing.T) { } func TestVersionExtract(t *testing.T) { - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST /api1/newObject HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -559,7 +559,7 @@ func TestVersionExtract(t *testing.T) { } func TestCommandFailedExtract(t *testing.T) { - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST /api1/newObject", Headers: map[string][]string{"accept": {"application/json"}}, @@ -576,7 +576,7 @@ func TestDnameWithInvalidPathParser(t *testing.T) { addresses["dname"] = []string{"soarca.tno.nl/this/path/shouldnt/be/used"} target := cacao.AgentTarget{Address: addresses, Port: strconv.Itoa(6464)} - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST /url HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -598,7 +598,7 @@ func TestHttpPathIpv4WithRandomPort(t *testing.T) { addresses["ipv4"] = []string{"127.0.0.1"} target := cacao.AgentTarget{Address: addresses, Port: strconv.Itoa(6464)} - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST /url HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -620,7 +620,7 @@ func TestInvalidDname(t *testing.T) { addresses["dname"] = []string{"https://soarca.tno.nl"} target := cacao.AgentTarget{Address: addresses, Port: strconv.Itoa(6464)} - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST /url HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -643,7 +643,7 @@ func TestInvalidIpv4(t *testing.T) { addresses["ipv4"] = []string{"https://127.0.0.1"} target := cacao.AgentTarget{Address: addresses, Port: strconv.Itoa(6464)} - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "POST /url HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, diff --git a/test/integration/api/routes/reporter_api/reporter_api_test.go b/test/integration/api/routes/reporter_api/reporter_api_test.go index ac2945ac..b084d603 100644 --- a/test/integration/api/routes/reporter_api/reporter_api_test.go +++ b/test/integration/api/routes/reporter_api/reporter_api_test.go @@ -25,7 +25,7 @@ func TestGetExecutions(t *testing.T) { mock_time := new(mock_time.MockTime) cacheReporter := cache.New(mock_time, 10) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -41,7 +41,7 @@ func TestGetExecutions(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", @@ -166,7 +166,7 @@ func TestGetExecutionReport(t *testing.T) { mock_time := new(mock_time.MockTime) cacheReporter := cache.New(mock_time, 10) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -182,7 +182,7 @@ func TestGetExecutionReport(t *testing.T) { ID: "action--test", Name: "ssh-tests", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1", diff --git a/test/integration/capability/http/http_integration_test.go b/test/integration/capability/http/http_integration_test.go index c0f81a46..90b66560 100644 --- a/test/integration/capability/http/http_integration_test.go +++ b/test/integration/capability/http/http_integration_test.go @@ -23,7 +23,7 @@ func TestHttpConnection(t *testing.T) { "url": {"https://httpbin.org/get"}, }, } - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "http-api", Command: "GET / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -41,9 +41,9 @@ func TestHttpConnection(t *testing.T) { metadata := execution.Metadata{ExecutionId: executionId, PlaybookId: playbookId.String(), StepId: stepId.String()} data := capability.Context{ - Command: expectedCommand, - Target: target, - Variables: cacao.NewVariables(variable1), + CommandData: expectedCommand, + Target: target, + Variables: cacao.NewVariables(variable1), } // But what to do if there is no target and no AuthInfo? results, err := httpCapability.Execute( @@ -73,7 +73,7 @@ func TestHttpOAuth2(t *testing.T) { Token: bearerToken, ID: "d0c7e6a0-f7fe-464e-9935-e6b3443f5b91", } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "GET / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -84,7 +84,7 @@ func TestHttpOAuth2(t *testing.T) { stepId, _ := uuid.Parse("81eff59f-d084-4324-9e0a-59e353dbd28f") metadata := execution.Metadata{ExecutionId: executionId, PlaybookId: playbookId.String(), StepId: stepId.String()} data := capability.Context{ - Command: command, + CommandData: command, Target: target, Authentication: auth, Variables: cacao.NewVariables(), @@ -120,7 +120,7 @@ func TestHttpBasicAuth(t *testing.T) { ID: "d0c7e6a0-f7fe-464e-9935-e6b3443f5b91", } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "GET / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -130,7 +130,7 @@ func TestHttpBasicAuth(t *testing.T) { stepId, _ := uuid.Parse("81eff59f-d084-4324-9e0a-59e353dbd28f") metadata := execution.Metadata{ExecutionId: executionId, PlaybookId: playbookId.String(), StepId: stepId.String()} data := capability.Context{ - Command: command, + CommandData: command, Target: target, Authentication: auth, Variables: cacao.NewVariables(), @@ -153,7 +153,7 @@ func TestInsecureHTTPConnection(t *testing.T) { "url": {"https://localhost/get"}, }, } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "GET / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, @@ -180,7 +180,7 @@ func TestInsecureHTTPConnectionWithFailure(t *testing.T) { "url": {"https://localhost/get"}, }, } - command := cacao.Command{ + command := cacao.CommandData{ Type: "http-api", Command: "GET / HTTP/1.1", Headers: map[string][]string{"accept": {"application/json"}}, diff --git a/test/integration/capability/ssh/ssh_integration_test.go b/test/integration/capability/ssh/ssh_integration_test.go index 02188ba6..507e5482 100644 --- a/test/integration/capability/ssh/ssh_integration_test.go +++ b/test/integration/capability/ssh/ssh_integration_test.go @@ -15,7 +15,7 @@ import ( func TestSshConnection(t *testing.T) { sshCapability := new(ssh.SshCapability) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ls -la", } @@ -44,7 +44,7 @@ func TestSshConnection(t *testing.T) { var stepId = "step--81eff59f-d084-4324-9e0a-59e353dbd28f" var metadata = execution.Metadata{ExecutionId: executionId, PlaybookId: playbookId, StepId: stepId} data := capability.Context{ - Command: expectedCommand, + CommandData: expectedCommand, Target: expectedTarget, Authentication: expectedAuthenticationInformation, Variables: cacao.NewVariables(expectedVariables), @@ -63,7 +63,7 @@ func TestSshConnection(t *testing.T) { func TestSshConnectionToNonExistingServer(t *testing.T) { sshCapability := new(ssh.SshCapability) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ls -la", } @@ -92,7 +92,7 @@ func TestSshConnectionToNonExistingServer(t *testing.T) { var stepId = "step--81eff59f-d084-4324-9e0a-59e353dbd28f" var metadata = execution.Metadata{ExecutionId: executionId, PlaybookId: playbookId, StepId: stepId} data := capability.Context{ - Command: expectedCommand, + CommandData: expectedCommand, Target: expectedTarget, Authentication: expectedAuthenticationInformation, Variables: cacao.NewVariables(expectedVariables), diff --git a/test/manual/powershell/powershell_test.go b/test/manual/powershell/powershell_test.go index c56d9511..2af6daa8 100644 --- a/test/manual/powershell/powershell_test.go +++ b/test/manual/powershell/powershell_test.go @@ -14,7 +14,7 @@ import ( func TestPowershellConnection(t *testing.T) { powershell := powershell.New() - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "powershell", Command: "Get-Acl", } @@ -37,7 +37,7 @@ func TestPowershellConnection(t *testing.T) { var stepId = "step--81eff59f-d084-4324-9e0a-59e353dbd28f" var metadata = execution.Metadata{ExecutionId: executionId, PlaybookId: playbookId, StepId: stepId} var data = capability.Context{ - Command: expectedCommand, + CommandData: expectedCommand, Authentication: expectedAuthenticationInformation, Target: expectedTarget, } diff --git a/test/manual/thehive_reporter/thehive_test.go b/test/manual/thehive_reporter/thehive_test.go index 59c2d69e..2377c4db 100644 --- a/test/manual/thehive_reporter/thehive_test.go +++ b/test/manual/thehive_reporter/thehive_test.go @@ -64,7 +64,7 @@ func TestTheHiveReporting(t *testing.T) { } thr := thehive.NewReporter(thehive.NewConnector(thehive_api_base_uri, thehive_api_tkn)) - expectedCommand := cacao.Command{ + expectedCommand := cacao.CommandData{ Type: "ssh", Command: "ssh ls -la", } @@ -88,7 +88,7 @@ func TestTheHiveReporting(t *testing.T) { Name: "ssh-tests", Description: "test step", StepVariables: cacao.NewVariables(expectedVariables), - Commands: []cacao.Command{expectedCommand}, + Commands: []cacao.CommandData{expectedCommand}, Cases: map[string]string{}, OnCompletion: "end--test", Agent: "agent1",