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

Bed 4262 az panic recovery #73

Merged
merged 26 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
725178a
fix: initial panicRecovery
benwaples Mar 14, 2024
835bb7f
panic recovery via channels
benwaples Mar 15, 2024
523da7a
stop context when panic happens
benwaples Mar 15, 2024
b4c1634
initial channel panic recovery pattern
benwaples Mar 15, 2024
716217c
list-devices
benwaples Mar 15, 2024
360c355
list-device-owners
benwaples Mar 15, 2024
5176782
list-group list-group-owners list-group-members
benwaples Mar 15, 2024
647e887
list-service-principles list-service-principalOwners list-tenants lis…
benwaples Mar 15, 2024
3ca490f
listUsers
benwaples Mar 15, 2024
62d141d
list-roles list-role-assignments
benwaples Mar 15, 2024
8866740
listAzureRm
benwaples Mar 15, 2024
96995de
listAzureRM group 2
benwaples Mar 15, 2024
edb629b
listAzureRM group 3
benwaples Mar 15, 2024
a2652c4
panicChan to a couple strays
benwaples Mar 18, 2024
c081074
chore: add comments per util
benwaples Mar 18, 2024
79c0e8a
fix: handle loops of go routines
benwaples Mar 18, 2024
285841e
fix: move handleBubbledPanic and ctx to root
benwaples Mar 19, 2024
96518b3
fix: add panicChan to tests
benwaples Mar 19, 2024
02f40d4
chore: CmdImpl only open panicChan if its going to get used
benwaples Mar 19, 2024
8151b0b
fix: white-space formatting
benwaples Mar 19, 2024
b23eee5
fix: panic recovery from top level goroutine
benwaples Mar 20, 2024
c7bebc7
feature: use panicrecovery package between channels
benwaples Mar 20, 2024
e1bc856
remove extra log
benwaples Mar 20, 2024
e2a6fda
plumb into client package
benwaples Mar 20, 2024
232bf83
move up panic recovery to handle root panics
benwaples Mar 20, 2024
6c5e745
remove hardcoded panic
benwaples Mar 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/app_role_assignments.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/constants"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -56,6 +57,7 @@ func (s *azureClient) ListAzureADAppRoleAssignments(ctx context.Context, service
out := make(chan azure.AppRoleAssignmentResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
4 changes: 4 additions & 0 deletions client/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/constants"
"github.com/bloodhoundad/azurehound/v2/enums"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -105,6 +106,7 @@ func (s *azureClient) ListAzureADApps(ctx context.Context, filter, search, order
out := make(chan azure.ApplicationResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down Expand Up @@ -169,6 +171,7 @@ func (s *azureClient) ListAzureADAppOwners(ctx context.Context, objectId string,
out := make(chan azure.AppOwnerResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down Expand Up @@ -239,6 +242,7 @@ func (s *azureClient) ListAzureADAppMemberObjects(ctx context.Context, objectId
out := make(chan azure.MemberObjectResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
2 changes: 2 additions & 0 deletions client/automation_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/query"
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -65,6 +66,7 @@ func (s *azureClient) ListAzureAutomationAccounts(ctx context.Context, subscript
out := make(chan azure.AutomationAccountResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
2 changes: 2 additions & 0 deletions client/container_registries.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/query"
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -65,6 +66,7 @@ func (s *azureClient) ListAzureContainerRegistries(ctx context.Context, subscrip
out := make(chan azure.ContainerRegistryResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
3 changes: 3 additions & 0 deletions client/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/constants"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -86,6 +87,7 @@ func (s *azureClient) ListAzureDevices(ctx context.Context, filter, search, orde
out := make(chan azure.DeviceResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down Expand Up @@ -150,6 +152,7 @@ func (s *azureClient) ListAzureDeviceRegisteredOwners(ctx context.Context, objec
out := make(chan azure.DeviceRegisteredOwnerResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
2 changes: 2 additions & 0 deletions client/function_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/query"
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -65,6 +66,7 @@ func (s *azureClient) ListAzureFunctionApps(ctx context.Context, subscriptionId
out := make(chan azure.FunctionAppResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
4 changes: 4 additions & 0 deletions client/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/constants"
"github.com/bloodhoundad/azurehound/v2/enums"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -102,6 +103,7 @@ func (s *azureClient) ListAzureADGroups(ctx context.Context, filter, search, ord
out := make(chan azure.GroupResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down Expand Up @@ -166,6 +168,7 @@ func (s *azureClient) ListAzureADGroupOwners(ctx context.Context, objectId strin
out := make(chan azure.GroupOwnerResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down Expand Up @@ -236,6 +239,7 @@ func (s *azureClient) ListAzureADGroupMembers(ctx context.Context, objectId stri
out := make(chan azure.MemberObjectResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
2 changes: 2 additions & 0 deletions client/keyvaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/query"
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -65,6 +66,7 @@ func (s *azureClient) ListAzureKeyVaults(ctx context.Context, subscriptionId str
out := make(chan azure.KeyVaultResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
2 changes: 2 additions & 0 deletions client/logic_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/query"
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -65,6 +66,7 @@ func (s *azureClient) ListAzureLogicApps(ctx context.Context, subscriptionId str
out := make(chan azure.LogicAppResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
2 changes: 2 additions & 0 deletions client/managed_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/query"
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -65,6 +66,7 @@ func (s *azureClient) ListAzureManagedClusters(ctx context.Context, subscription
out := make(chan azure.ManagedClusterResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
3 changes: 3 additions & 0 deletions client/management_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/query"
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -82,6 +83,7 @@ func (s *azureClient) ListAzureManagementGroups(ctx context.Context) <-chan azur
out := make(chan azure.ManagementGroupResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down Expand Up @@ -146,6 +148,7 @@ func (s *azureClient) ListAzureManagementGroupDescendants(ctx context.Context, g
out := make(chan azure.DescendantInfoResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
2 changes: 2 additions & 0 deletions client/resource_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/query"
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -65,6 +66,7 @@ func (s *azureClient) ListAzureResourceGroups(ctx context.Context, subscriptionI
out := make(chan azure.ResourceGroupResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
4 changes: 4 additions & 0 deletions client/role_assignments.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/constants"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -71,6 +72,7 @@ func (s *azureClient) ListAzureADRoleAssignments(ctx context.Context, filter, se
out := make(chan azure.UnifiedRoleAssignmentResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down Expand Up @@ -153,6 +155,7 @@ func (s *azureClient) ListRoleAssignmentsForResource(ctx context.Context, resour
out := make(chan azure.RoleAssignmentResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down Expand Up @@ -240,6 +243,7 @@ func (s *azureClient) ListResourceRoleAssignments(ctx context.Context, subscript
out := make(chan azure.RoleAssignmentResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
2 changes: 2 additions & 0 deletions client/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/constants"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -65,6 +66,7 @@ func (s *azureClient) ListAzureADRoles(ctx context.Context, filter, expand strin
out := make(chan azure.RoleResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
3 changes: 3 additions & 0 deletions client/service_principals.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/constants"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -86,6 +87,7 @@ func (s *azureClient) ListAzureADServicePrincipals(ctx context.Context, filter,
out := make(chan azure.ServicePrincipalResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down Expand Up @@ -150,6 +152,7 @@ func (s *azureClient) ListAzureADServicePrincipalOwners(ctx context.Context, obj
out := make(chan azure.ServicePrincipalOwnerResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
3 changes: 3 additions & 0 deletions client/storage_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/query"
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -64,6 +65,7 @@ func (s *azureClient) ListAzureStorageAccounts(ctx context.Context, subscription
out := make(chan azure.StorageAccountResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down Expand Up @@ -169,6 +171,7 @@ func (s *azureClient) ListAzureStorageContainers(ctx context.Context, subscripti
out := make(chan azure.StorageContainerResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
2 changes: 2 additions & 0 deletions client/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/query"
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -65,6 +66,7 @@ func (s *azureClient) ListAzureSubscriptions(ctx context.Context) <-chan azure.S
out := make(chan azure.SubscriptionResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
2 changes: 2 additions & 0 deletions client/tenants.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/constants"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -65,6 +66,7 @@ func (s *azureClient) ListAzureADTenants(ctx context.Context, includeAllTenantCa
out := make(chan azure.TenantResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
2 changes: 2 additions & 0 deletions client/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/constants"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -71,6 +72,7 @@ func (s *azureClient) ListAzureADUsers(ctx context.Context, filter string, searc
out := make(chan azure.UserResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
2 changes: 2 additions & 0 deletions client/virtual_machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/bloodhoundad/azurehound/v2/client/query"
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

Expand Down Expand Up @@ -65,6 +66,7 @@ func (s *azureClient) ListAzureVirtualMachines(ctx context.Context, subscription
out := make(chan azure.VirtualMachineResult)

go func() {
defer panicrecovery.PanicRecovery()
defer close(out)

var (
Expand Down
Loading
Loading