Skip to content

Commit aa09314

Browse files
hidde-janMaartendeKruijf
authored andcommitted
Resolve "Improve naming"
1 parent bda3283 commit aa09314

File tree

19 files changed

+76
-75
lines changed

19 files changed

+76
-75
lines changed

application/core.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/gin-gonic/gin"
1212
)
1313

14-
func InitialiseCore(app *gin.Engine) error {
14+
func InitializeCore(app *gin.Engine) error {
1515
ssh := new(ssh.SshCapability)
1616
capabilities := map[string]capability.ICapability{ssh.GetType(): ssh}
1717
executer := executer.New(capabilities)

application/database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/gin-gonic/gin"
1212
)
1313

14-
func InitialliseDatabase(app *gin.Engine) error {
14+
func InitializeDatabase(app *gin.Engine) error {
1515
mongo.LoadComponent()
1616

1717
log.Info("SOARCA API Trying to start")

application/setup.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ import (
66
"github.com/gin-gonic/gin"
77
)
88

9-
func InitialiseAppComponents() error {
9+
func InitializeAppComponents() error {
1010
app := gin.New()
11+
log.Info("Testing if this works")
1112

1213
initDatabase := utils.GetEnv("DATABASE", "false")
1314
if initDatabase == "true" {
14-
errDatabase := InitialliseDatabase(app)
15+
errDatabase := InitializeDatabase(app)
1516
if errDatabase != nil {
1617
log.Error("Failed to init core")
1718
return errDatabase
1819
}
1920
}
20-
errCore := InitialiseCore(app)
21+
errCore := InitializeCore(app)
2122

2223
if errCore != nil {
2324
log.Error("Failed to init core")

docs/docs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ const docTemplate = `{
710710
"playbook_variables": {
711711
"type": "object",
712712
"additionalProperties": {
713-
"$ref": "#/definitions/cacao.Variables"
713+
"$ref": "#/definitions/cacao.Variable"
714714
}
715715
},
716716
"playbook_version": {
@@ -733,7 +733,7 @@ const docTemplate = `{
733733
}
734734
}
735735
},
736-
"cacao.Variables": {
736+
"cacao.Variable": {
737737
"type": "object",
738738
"properties": {
739739
"constant": {

docs/swagger.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@
699699
"playbook_variables": {
700700
"type": "object",
701701
"additionalProperties": {
702-
"$ref": "#/definitions/cacao.Variables"
702+
"$ref": "#/definitions/cacao.Variable"
703703
}
704704
},
705705
"playbook_version": {
@@ -722,7 +722,7 @@
722722
}
723723
}
724724
},
725-
"cacao.Variables": {
725+
"cacao.Variable": {
726726
"type": "object",
727727
"properties": {
728728
"constant": {

docs/swagger.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ definitions:
345345
type: string
346346
playbook_variables:
347347
additionalProperties:
348-
$ref: '#/definitions/cacao.Variables'
348+
$ref: '#/definitions/cacao.Variable'
349349
type: object
350350
playbook_version:
351351
type: string
@@ -360,7 +360,7 @@ definitions:
360360
type:
361361
type: string
362362
type: object
363-
cacao.Variables:
363+
cacao.Variable:
364364
properties:
365365
constant:
366366
type: boolean

internal/capability/capability.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ type ICapability interface {
1111
command cacao.Command,
1212
authentication cacao.AuthenticationInformation,
1313
target cacao.AgentTarget,
14-
variables map[string]cacao.Variables) (map[string]cacao.Variables, error)
14+
variables map[string]cacao.Variable) (map[string]cacao.Variable, error)
1515
GetType() string
1616
}

internal/capability/http/http.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ func (httpCapability *HttpCapability) Execute(
3939
command cacao.Command,
4040
authentication cacao.AuthenticationInformation,
4141
target cacao.AgentTarget,
42-
variables map[string]cacao.Variables) (map[string]cacao.Variables, error) {
42+
variables map[string]cacao.Variable) (map[string]cacao.Variable, error) {
4343

4444
// Get request data and handle errors
4545
method, url, errmethod := ObtainHttpMethodAndUrlFromCommand(command)
4646
if errmethod != nil {
4747
log.Error(errmethod)
48-
return map[string]cacao.Variables{}, errmethod
48+
return map[string]cacao.Variable{}, errmethod
4949
}
5050
content_data, errcontent := ObtainHttpRequestContentDataFromCommand(command)
5151
if errcontent != nil {
@@ -57,7 +57,7 @@ func (httpCapability *HttpCapability) Execute(
5757
request, err := http.NewRequest(method, url, bytes.NewBuffer(content_data))
5858
if err != nil {
5959
log.Error(err)
60-
return map[string]cacao.Variables{}, err
60+
return map[string]cacao.Variable{}, err
6161
}
6262

6363
for key, httpCapability := range command.Headers {
@@ -66,12 +66,12 @@ func (httpCapability *HttpCapability) Execute(
6666
if target.ID != "" {
6767
if err := verifyAuthInfoMatchesAgentTarget(&target, &authentication); err != nil {
6868
log.Error(err)
69-
return map[string]cacao.Variables{}, err
69+
return map[string]cacao.Variable{}, err
7070
}
7171

7272
if err := setupAuthHeaders(request, &authentication); err != nil {
7373
log.Error(err)
74-
return map[string]cacao.Variables{}, err
74+
return map[string]cacao.Variable{}, err
7575
}
7676
}
7777

@@ -80,22 +80,22 @@ func (httpCapability *HttpCapability) Execute(
8080
response, err := client.Do(request)
8181
if err != nil {
8282
log.Error(err)
83-
return map[string]cacao.Variables{}, err
83+
return map[string]cacao.Variable{}, err
8484
}
8585
defer response.Body.Close()
8686

8787
responseBytes, err := io.ReadAll(response.Body)
8888
if err != nil {
8989
log.Error(err)
90-
return map[string]cacao.Variables{}, err
90+
return map[string]cacao.Variable{}, err
9191
}
9292
respString := string(responseBytes)
9393
sc := response.StatusCode
9494
if sc < 200 || sc > 299 {
95-
return map[string]cacao.Variables{}, errors.New(respString)
95+
return map[string]cacao.Variable{}, errors.New(respString)
9696
}
9797

98-
return map[string]cacao.Variables{
98+
return map[string]cacao.Variable{
9999
"__soarca_http_result__": {Name: "result", Value: respString}}, nil
100100

101101
}

internal/capability/ssh/ssh.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (sshCapability *SshCapability) Execute(executionId uuid.UUID,
3131
command cacao.Command,
3232
authentication cacao.AuthenticationInformation,
3333
target cacao.AgentTarget,
34-
variables map[string]cacao.Variables) (map[string]cacao.Variables, error) {
34+
variables map[string]cacao.Variable) (map[string]cacao.Variable, error) {
3535
log.Trace(executionId)
3636

3737
host := CombinePortAndAddress(target.Address, target.Port)
@@ -40,7 +40,7 @@ func (sshCapability *SshCapability) Execute(executionId uuid.UUID,
4040

4141
if errAuth != nil {
4242
log.Error(errAuth)
43-
return map[string]cacao.Variables{}, errAuth
43+
return map[string]cacao.Variable{}, errAuth
4444
} else {
4545
log.Trace(host)
4646
}
@@ -60,7 +60,7 @@ func (sshCapability *SshCapability) Execute(executionId uuid.UUID,
6060
signer, errKey := ssh.ParsePrivateKey([]byte(authentication.PrivateKey))
6161
if errKey != nil || authentication.Password == "" {
6262
log.Error("no valid authentication information: ", errKey)
63-
return map[string]cacao.Variables{}, errKey
63+
return map[string]cacao.Variable{}, errKey
6464
}
6565
config = ssh.ClientConfig{
6666
User: authentication.Username,
@@ -78,23 +78,23 @@ func (sshCapability *SshCapability) Execute(executionId uuid.UUID,
7878
conn, err := ssh.Dial("tcp", host, &config)
7979
if err != nil {
8080
log.Error(err)
81-
return map[string]cacao.Variables{}, err
81+
return map[string]cacao.Variable{}, err
8282
}
8383
var session *ssh.Session
8484
session, err = conn.NewSession()
8585
if err != nil {
8686
log.Error(err)
87-
return map[string]cacao.Variables{}, err
87+
return map[string]cacao.Variable{}, err
8888
}
8989

9090
response, err := session.Output(StripSshPrepend(command.Command))
9191
defer session.Close()
9292

9393
if err != nil {
9494
log.Error(err)
95-
return map[string]cacao.Variables{"__soarca_ssh_result__": {Name: "result", Value: string(response)}}, err
95+
return map[string]cacao.Variable{"__soarca_ssh_result__": {Name: "result", Value: string(response)}}, err
9696
}
97-
results := map[string]cacao.Variables{"__soarca_ssh_result__": {Name: "result", Value: string(response)}}
97+
results := map[string]cacao.Variable{"__soarca_ssh_result__": {Name: "result", Value: string(response)}}
9898
log.Trace("Finished ssh execution will return the variables: ", results)
9999
return results, err
100100
}

internal/decomposer/decomposer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type Decomposer struct {
4848
guid guid.IGuid
4949
}
5050

51-
func Callback(executionId uuid.UUID, outputVariables map[string]cacao.Variables) {
51+
func Callback(executionId uuid.UUID, outputVariables map[string]cacao.Variable) {
5252

5353
}
5454

0 commit comments

Comments
 (0)