Skip to content

Commit db0463a

Browse files
authored
Use consistent capability naming (#61)
1 parent fb342d8 commit db0463a

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

internal/capability/http/http.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ import (
1818
// Run HTTP API call
1919
// Return response
2020

21+
const (
22+
httpApiResultVariableName = "__soarca_http_api_result__"
23+
httpApiCapabilityName = "soarca-http-api"
24+
)
25+
2126
type HttpCapability struct {
2227
}
2328

@@ -31,7 +36,7 @@ func init() {
3136
}
3237

3338
func (httpCapability *HttpCapability) GetType() string {
34-
return "soarca-http-api"
39+
return httpApiCapabilityName
3540
}
3641

3742
// What to do if there is no agent or target?
@@ -97,7 +102,7 @@ func (httpCapability *HttpCapability) Execute(
97102
return cacao.NewVariables(), errors.New(respString)
98103
}
99104

100-
return cacao.NewVariables(cacao.Variable{Name: "__soarca_http_result__", Value: respString}), nil
105+
return cacao.NewVariables(cacao.Variable{Name: httpApiResultVariableName, Value: respString}), nil
101106

102107
}
103108

internal/capability/openc2/openc2.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type Empty struct{}
1717

1818
const (
1919
openc2ResultVariableName = "__soarca_openc2_http_result__"
20-
openc2capabilityName = "soarca-openc2-http"
20+
openc2CapabilityName = "soarca-openc2-http"
2121
)
2222

2323
var (
@@ -34,7 +34,7 @@ func New(httpRequest http.IHttpRequest) *OpenC2Capability {
3434
}
3535

3636
func (OpenC2Capability *OpenC2Capability) GetType() string {
37-
return openc2capabilityName
37+
return openc2CapabilityName
3838
}
3939

4040
func (OpenC2Capability *OpenC2Capability) Execute(

internal/capability/ssh/ssh.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import (
1313
"golang.org/x/crypto/ssh"
1414
)
1515

16+
const (
17+
sshResultVariableName = "__soarca_ssh_result__"
18+
sshCapabilityName = "soarca-ssh"
19+
)
20+
1621
type SshCapability struct {
1722
}
1823

@@ -24,7 +29,7 @@ func init() {
2429
}
2530

2631
func (sshCapability *SshCapability) GetType() string {
27-
return "soarca-ssh-capability"
32+
return sshCapabilityName
2833
}
2934

3035
func (sshCapability *SshCapability) Execute(metadata execution.Metadata,
@@ -94,7 +99,7 @@ func (sshCapability *SshCapability) Execute(metadata execution.Metadata,
9499
log.Error(err)
95100
return cacao.NewVariables(), err
96101
}
97-
results := cacao.NewVariables(cacao.Variable{Name: "__soarca_ssh_result__", Value: string(response)})
102+
results := cacao.NewVariables(cacao.Variable{Name: sshResultVariableName, Value: string(response)})
98103
log.Trace("Finished ssh execution will return the variables: ", results)
99104
return results, err
100105
}

test/unittest/decomposer/decomposer_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func TestExecutePlaybook(t *testing.T) {
6262

6363
expectedAgent := cacao.AgentTarget{
6464
Type: "soarca",
65-
Name: "soarca-ssh-capability",
65+
Name: "soarca-ssh",
6666
}
6767

6868
playbook := cacao.Playbook{
@@ -175,7 +175,7 @@ func TestExecutePlaybookMultiStep(t *testing.T) {
175175

176176
expectedAgent := cacao.AgentTarget{
177177
Type: "soarca",
178-
Name: "soarca-ssh-capability",
178+
Name: "soarca-ssh",
179179
}
180180

181181
playbook := cacao.Playbook{
@@ -245,7 +245,7 @@ func TestExecuteEmptyMultiStep(t *testing.T) {
245245

246246
expectedAgent := cacao.AgentTarget{
247247
Type: "soarca",
248-
Name: "soarca-ssh-capability",
248+
Name: "soarca-ssh",
249249
}
250250

251251
decomposer2 := decomposer.New(mock_executer2, uuid_mock2)

0 commit comments

Comments
 (0)