Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reporter api #137

Merged
merged 40 commits into from
May 15, 2024
Merged

Conversation

lucamrgs
Copy link
Collaborator

@lucamrgs lucamrgs commented May 1, 2024

Defines the initial API endpoints and route logic for reporting

@lucamrgs lucamrgs linked an issue May 1, 2024 that may be closed by this pull request
@lucamrgs lucamrgs changed the title add first reporter api reporter api May 2, 2024
@lucamrgs lucamrgs force-pushed the feature/136-reporter-api-definition branch from c5244cc to 267d3d5 Compare May 7, 2024 12:19
@lucamrgs lucamrgs marked this pull request as ready for review May 7, 2024 12:44
@RabbITCybErSeC RabbITCybErSeC force-pushed the feature/136-reporter-api-definition branch from 3364acd to df53e97 Compare May 8, 2024 12:23
Copy link
Collaborator

@MaartendeKruijf MaartendeKruijf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice start on the api we need to refine a bit but looks good already


```plantuml
@startjson
[
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just return a list of all executions not only the id's, we could use the /reporter/meta to return the execution-id and playbook-id.

##### Step execution data
|field |content |type | description |
| ----------------- | --------------------- | ----------------- | ----------- |
|execution_id |UUID |string |The id of the execution of the playbook where the step resides
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is redundant in combination with the execution_id of the response. Internally it's included during reporting so it can be matched with the correct execution

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me forever but now it's done

@@ -47,6 +49,8 @@ type Controller struct {

var mainController = Controller{}

var mainCache = cache.New(&timeUtil.Time{})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to discuss mutex for coroutines

Cache map[string]report.ExecutionEntry // Cached up to max
fifoRegister []string // Used for O(1) FIFO cache management
Cache map[string]cache_report.ExecutionEntry // Cached up to max
fifoRegister []string // Used for O(1) FIFO cache management
}

func New(timeUtil itime.ITime) *Cache {
maxExecutions, _ := strconv.Atoi(utils.GetEnv("MAX_EXECUTIONS", strconv.Itoa(MaxExecutions)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this and intject it

type Status uint8

const (
SuccessfullyExecuted = "successfully_executed"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe include a link to the execution status repo in a comment

Comment on lines 34 to 42
func (reporter *Mock_Downstream_Reporter) GetExecutionsIds() []string {
args := reporter.Called()
return args.Get(0).([]string)
}

func (reporter *Mock_Downstream_Reporter) GetExecutionReport(executionKey uuid.UUID) (cache_report.ExecutionEntry, error) {
args := reporter.Called(executionKey)
return args.Get(0).(cache_report.ExecutionEntry), args.Error(1)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be in a separate mock as they are not in the cache interface

@@ -4,7 +4,7 @@ import (
"errors"
"soarca/internal/reporter/downstream_reporter/cache"
"soarca/models/cacao"
"soarca/models/report"
report "soarca/models/cache"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a mismatch between models and naming

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Place this in the unittest folder as it's an unittest


##### Step execution data
|field |content |type | description |
| ----------------- | --------------------- | ----------------- | ----------- |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated execution field is missing here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also see what other fields would make sense to include

| successfully_executed | The workflow step was executed successfully (completed). |
|failed| The workflow step failed. |
|ongoing| The workflow step is in progress. |
|server_side_error| A server-side error occurred. |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've sugested await_user_input cyentific-rni/workflow-status#3 if that goes true we need to add that here


##### Step execution data
|field |content |type | description |
| ----------------- | --------------------- | ----------------- | ----------- |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also see what other fields would make sense to include

@lucamrgs lucamrgs force-pushed the feature/136-reporter-api-definition branch from acc6ba6 to 9990771 Compare May 15, 2024 09:58
ExecutionId string
StepId string
Started string
Ended string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type time

Ended: expectedEnded,
StepResults: map[string]cache_model.StepResult{},
Error: nil,
Status: 2,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status 2 is an enum right?

@MaartendeKruijf MaartendeKruijf merged commit 332d515 into development May 15, 2024
9 checks passed
@MaartendeKruijf MaartendeKruijf deleted the feature/136-reporter-api-definition branch May 15, 2024 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reporter API definition
2 participants