main
1package api
2
3import (
4 "context"
5 "fmt"
6 "mysh/pkg/mythic"
7)
8
9// FindActiveCallback looks up an active callback by its display ID
10func FindActiveCallback(ctx context.Context, client MythicClient, callbackID int) (*mythic.Callback, error) {
11 callbacks, err := client.GetActiveCallbacks(ctx)
12 if err != nil {
13 return nil, fmt.Errorf("failed to get callbacks: %w", err)
14 }
15
16 for _, callback := range callbacks {
17 if callback.DisplayID == callbackID {
18 return &callback, nil
19 }
20 }
21
22 return nil, fmt.Errorf("callback %d not found or not active", callbackID)
23}
24
25// ValidateCallbackExists verifies that a callback exists and is accessible
26func ValidateCallbackExists(ctx context.Context, client MythicClient, callbackID int) (*mythic.Callback, error) {
27 return FindActiveCallback(ctx, client, callbackID)
28}