fixed crash issue if data array is empty (#3091)

This commit is contained in:
Abdul Basit
2024-07-23 09:36:27 -07:00
committed by GitHub
parent c01428d107
commit 7c0c2e9ff3
+4 -4
View File
@@ -2,10 +2,10 @@ package atlassian
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"encoding/json"
regexp "github.com/wasilibs/go-re2"
@@ -71,7 +71,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
isVerified, orgResponse, verificationErr := verifyMatch(ctx, client, match)
s1.Verified = isVerified
if orgResponse != nil {
if orgResponse != nil && len(orgResponse.Data) > 0 {
s1.ExtraData["Organization"] = orgResponse.Data[0].Attributes.Name
}
s1.SetVerificationError(verificationErr, match)
@@ -88,8 +88,8 @@ func verifyMatch(ctx context.Context, client *http.Client, token string) (bool,
if err != nil {
return false, nil, nil
}
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
res, err := client.Do(req)
if err != nil {
return false, nil, err