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

soarca-initialized variable properties overwrite playbook variable properties #211

Closed
lucamrgs opened this issue Aug 8, 2024 · 1 comment

Comments

@lucamrgs
Copy link
Collaborator

lucamrgs commented Aug 8, 2024

Describe the bug
Noticeable in trigger/id API calls. Payload-provided variables unspecified fields are initialised to default values, and variables are then completely substituting the playbook variables (playbook.PlaybookVariables.Merge(payload_variables) at the end of func MergeVariablesInPlaybook(playbook *cacao.Playbook, body []byte) (bool, string), in trigger_api.go).

Hence, variables inside the playbook will have their properties changed.

To Reproduce provide details logs and steps
To reproduce, you can add a print before trigger.execute(&playbook, context) in func (trigger *TriggerApi) ExecuteById(context *gin.Context) in trigger_api.go, and run the test func TestExecutionOfPlaybookByIdWithPayloadValidVariables(t *testing.T) in unittest/routes.trigger_api/trigger_api_test.go

Expected behavior
The variable in the playbook remains exactly the same except for the values provided by the properties in the payload-specified variables.

Additional context
As solution, we should implement a function that receiving a variable in input from a payload (not marshalled to a cacao.Variable object), marshals it in a cacao.Variable object but also taking into account the variable it will substitute the values of. This will also allow us to e.g. prevent payload-provided variables from overwriting the "external" property.

Then, we should also implement a property-by-property merge function for the cacao.Variables which accounts for initialisation-provided values, diffs between payload-provided and playbook-present variables, and prevents overwriting of meta properties e.g. bool, and const (modifying these fields should pertain to playbook editing tasks. It's surely not a within-execution task).

@lucamrgs
Copy link
Collaborator Author

lucamrgs commented Aug 8, 2024

This is solved in #206

@lucamrgs lucamrgs closed this as completed Aug 8, 2024
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

No branches or pull requests

1 participant