Describe the bug
If an unhandled error occurs within a probe scenario, then the step will pass since error is not caught.
Example: invalid memory address or nil pointer dereference
To Reproduce
Steps to reproduce the behavior:
Go to any probe
Add logic to access a pointer that have not been initialized
Run the test
In audit log, see the step result is Passed, however Function is panicmem
Expected behavior
Any unhandled error within a probe should be caught and step should fail.
The logic for deferred audit shall be update in all probe scenarios as follows:
// Standard auditing logic to ensures panics are also audited
stepTrace, payload, err := utils.AuditPlaceholders()
defer func() {
// Catching any errors from panic
if panicErr := recover(); panicErr != nil {
err = utils.ReformatError("Unexpected error occured: ", panicErr)
}
scenario.audit.AuditScenarioStep(scenario.currentStep, stepTrace.String(), payload, err)
}()
Describe the bug If an unhandled error occurs within a probe scenario, then the step will pass since error is not caught. Example: invalid memory address or nil pointer dereference
To Reproduce Steps to reproduce the behavior:
Expected behavior Any unhandled error within a probe should be caught and step should fail. The logic for deferred audit shall be update in all probe scenarios as follows:
Screenshots
Additional context https://www.digitalocean.com/community/tutorials/handling-panics-in-go