Skip to content

Commit

Permalink
validate if twitter services are more than one before accessing it. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
abmussani authored Nov 6, 2024
1 parent 944d5dc commit d073ad6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions pkg/analyzer/analyzers/twilio/twilio.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,28 @@ func (a *Analyzer) Analyze(ctx context.Context, credentialInfo map[string]string
}
}

var bindings []analyzers.Binding
parentAccountSID := info.ServicesRes.Services[0].AccountSID
parentAccountFriendlyName := info.ServicesRes.Services[0].FriendlyName
var (
bindings []analyzers.Binding
parentAccountSID = ""
parentAccountFriendlyName = ""
)

if len(info.ServicesRes.Services) > 0 {
parentAccountSID = info.ServicesRes.Services[0].AccountSID
parentAccountFriendlyName = info.ServicesRes.Services[0].FriendlyName
}

for _, account := range accounts {
accountType := "Account"
if account.SID != parentAccountSID {
if parentAccountSID != "" && account.SID != parentAccountSID {
accountType = "SubAccount"
}
resource := analyzers.Resource{
Name: account.FriendlyName,
FullyQualifiedName: "twilio.com/account/" + account.SID,
Type: accountType,
}
if account.SID != parentAccountSID {
if parentAccountSID != "" && account.SID != parentAccountSID {
resource.Parent = &analyzers.Resource{
Name: parentAccountFriendlyName,
FullyQualifiedName: "twilio.com/account/" + parentAccountSID,
Expand Down

0 comments on commit d073ad6

Please sign in to comment.