-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial thehive reporting setup (#237)
- Loading branch information
Showing
11 changed files
with
1,110 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package thehive | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// ############################### Playbook to TheHive ID mappings | ||
|
||
type SOARCATheHiveMap struct { | ||
executionsCaseMaps map[string]ExecutionCaseMap | ||
} | ||
type ExecutionCaseMap struct { | ||
caseId string | ||
stepsTasksMap map[string]string | ||
} | ||
|
||
// TODO: Change to using observables instead of updating the tasks descriptions | ||
|
||
func (soarcaTheHiveMap *SOARCATheHiveMap) checkExecutionCaseExists(executionId string) error { | ||
if _, ok := soarcaTheHiveMap.executionsCaseMaps[executionId]; !ok { | ||
return fmt.Errorf("case not found for execution id %s", executionId) | ||
} | ||
return nil | ||
} | ||
func (soarcaTheHiveMap *SOARCATheHiveMap) checkExecutionStepTaskExists(executionId string, stepId string) error { | ||
if _, ok := soarcaTheHiveMap.executionsCaseMaps[executionId].stepsTasksMap[stepId]; !ok { | ||
return fmt.Errorf("task not found for execution id %s for step id %s", executionId, stepId) | ||
} | ||
return nil | ||
} | ||
|
||
func (soarcaTheHiveMap *SOARCATheHiveMap) registerExecutionInCase(executionId string, caseId string) error { | ||
soarcaTheHiveMap.executionsCaseMaps[executionId] = ExecutionCaseMap{ | ||
caseId: caseId, | ||
stepsTasksMap: map[string]string{}, | ||
} | ||
log.Info(fmt.Sprintf("registering execution: %s, case id: %s", executionId, caseId)) | ||
|
||
return nil | ||
} | ||
func (soarcaTheHiveMap *SOARCATheHiveMap) registerStepTaskInCase(executionId string, stepId string, taskId string) { | ||
soarcaTheHiveMap.executionsCaseMaps[executionId].stepsTasksMap[stepId] = taskId | ||
} | ||
|
||
func (soarcaTheHiveMap *SOARCATheHiveMap) retrieveCaseId(executionId string) (string, error) { | ||
err := soarcaTheHiveMap.checkExecutionCaseExists(executionId) | ||
if err != nil { | ||
return "", err | ||
} | ||
return soarcaTheHiveMap.executionsCaseMaps[executionId].caseId, nil | ||
} | ||
|
||
func (soarcaTheHiveMap *SOARCATheHiveMap) retrieveTaskId(executionId string, stepId string) (string, error) { | ||
err := soarcaTheHiveMap.checkExecutionCaseExists(executionId) | ||
if err != nil { | ||
return "", err | ||
} | ||
err = soarcaTheHiveMap.checkExecutionStepTaskExists(executionId, stepId) | ||
if err != nil { | ||
return "", err | ||
} | ||
return soarcaTheHiveMap.executionsCaseMaps[executionId].stepsTasksMap[stepId], nil | ||
} | ||
|
||
// func (soarcaTheHiveMap *SOARCATheHiveMap) clearCase(executionId string) error { | ||
// err := soarcaTheHiveMap.checkExecutionCaseExists(executionId) | ||
// if err != nil { | ||
// return err | ||
// } | ||
// return nil | ||
// } | ||
|
||
// func (soarcaTheHiveMap *SOARCATheHiveMap) clearMap(executionId string) error |
Oops, something went wrong.