hashicorp / vault-plugin-secrets-azure

Vault Azure Secrets plugin
Mozilla Public License 2.0
26 stars 20 forks source link

Fix segmentation fault when unassigning role assignments #213

Closed vinay-gopalan closed 2 months ago

vinay-gopalan commented 2 months ago

Overview

The error handling case in unassignRoles was misconstrued, and was causing a panic when unassigning role assignments would fail during a WAL Rollback. This PR appropriately parses the received error from Azure and fixes the if cases to remove the panic case.

A unit test with a mock provider was added to confirm that the plugin can correctly

Related Issues/Pull Requests

[x] [Issue #190] [x] [PR #210]

Contributor Checklist

[x] Add relevant docs to upstream Vault repository, or sufficient reasoning why docs won’t be added yet My Docs PR Link Example [x] Add output for any tests not ran in CI to the PR description (eg, acceptance tests) [x] Backwards compatible

test output without fix:

=== RUN   TestUnassignRoleFailures
=== RUN   TestUnassignRoleFailures/Role_unassign_fail
--- FAIL: TestUnassignRoleFailures (0.00s)
    --- FAIL: TestUnassignRoleFailures/Role_unassign_fail (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x3b4b916]

test output with fix:

=== RUN   TestUnassignRoleFailures
=== RUN   TestUnassignRoleFailures/Role_unassign_fail
=== RUN   TestUnassignRoleFailures/Role_unassign_error_handled
--- PASS: TestUnassignRoleFailures (0.00s)
    --- PASS: TestUnassignRoleFailures/Role_unassign_fail (0.00s)
    --- PASS: TestUnassignRoleFailures/Role_unassign_error_handled (0.00s)
PASS