Skip to content

Commit

Permalink
use cds03 cacao json schema and normalize test playbooks
Browse files Browse the repository at this point in the history
  • Loading branch information
lucamrgs committed Mar 11, 2024
1 parent e49318d commit 739c337
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions models/validator/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var log *logger.Log
var cacao_v1_csd01_http string = "https://raw.githubusercontent.com/cyentific-rni/cacao-json-schemas/cacao-v1.0-csd02/schemas/playbook.json"
var cacao_v2_csd01_http string = "https://raw.githubusercontent.com/cyentific-rni/cacao-json-schemas/cacao-v2.0-csd01/schemas/playbook.json"

//var cacao_v2_csd03_http string = "https://raw.githubusercontent.com/cyentific-rni/cacao-json-schemas/cacao-v2.0-csd03/schemas/playbook.json"
var cacao_v2_csd03_http string = "https://raw.githubusercontent.com/cyentific-rni/cacao-json-schemas/cacao-v2.0-csd03/schemas/playbook.json"

func init() {
log = logger.Logger(component, logger.Info, "", logger.Json)
Expand Down Expand Up @@ -73,7 +73,7 @@ func IsValidCacaoJson(data []byte) error {
// NOTE: CURRENTLY THERE IS AN INCONSISTENCY BETWEEN CDS01 AND CDS03
// The cds03 schema is bugged at the time being (13/11/2023)
// So we cannot validate checking authentication information
sch, err = compiler.Compile(cacao_v2_csd01_http)
sch, err = compiler.Compile(cacao_v2_csd03_http)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions test/unittest/cacao/playbooks/infinite_playbook.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"agent_definitions": {
"individual--6b23a237-ade8-4d00-9aa1-75999732d557": {
"name": "banana rama",
"type": "individual",
"banana": "rama"
}
}
Expand Down
1 change: 1 addition & 0 deletions test/unittest/cacao/playbooks/invalid_email_playbook.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
},
"individual--6b23a237-ade8-4d00-9aa1-75999732d557": {
"name": "banana rama",
"type": "individual",
"banana": "rama",
"contact" : {
"email" : {
Expand Down
3 changes: 2 additions & 1 deletion test/unittest/cacao/playbooks/invalid_playbook.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
"password": "super-secure-password"
}
},
"agents": {
"agent_definitions": {
"http-api--7e9174ec-a293-43df-a72d-471c79e276bf": {

"name": "Firewall 1",
"type": "banana",
"http_url": "hxxp://example.com/v1/",
"authentication_info": "http-basic--76c26f7f-9a15-40ff-a90a-7b19e23372ae",
"category": [
Expand Down
1 change: 1 addition & 0 deletions test/unittest/cacao/playbooks/missing_step_playbook.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"agent_definitions": {
"individual--6b23a237-ade8-4d00-9aa1-75999732d557": {
"name": "banana rama",
"type": "individual",
"banana": "rama"
}
}
Expand Down
1 change: 1 addition & 0 deletions test/unittest/cacao/playbooks/parallels_playbook.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"agent_definitions": {
"individual--6b23a237-ade8-4d00-9aa1-75999732d557": {
"name": "banana rama",
"type": "individual",
"banana": "rama"
}
}
Expand Down
1 change: 1 addition & 0 deletions test/unittest/cacao/playbooks/playbook.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
},
"individual--6b23a237-ade8-4d00-9aa1-75999732d557": {
"name": "banana rama",
"type": "individual",
"banana": "rama",
"contact": {
"email": {
Expand Down
4 changes: 4 additions & 0 deletions test/unittest/cacao/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ func TestNotValidCacaoJson(t *testing.T) {
fmt.Println(errValid)
t.Fail()
}
fmt.Println(errValid)
expected := "value must be \"http-api\""

assert.Equal(t, strings.Contains(fmt.Sprint(errValid), expected), true)
}

func TestValidCacaoJson(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions test/unittest/routes/playbook.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
},
"individual--6b23a237-ade8-4d00-9aa1-75999732d557": {
"name": "banana rama",
"type": "individual",
"banana": "rama"
}
},
Expand Down

0 comments on commit 739c337

Please sign in to comment.