Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
Normalize UID to Uid in Postman Code (#4125)
Martin Locklearc4764085c5f2
diff --git a/pkg/sources/postman/postman.go b/pkg/sources/postman/postman.goindex a499b12c9..8de762754 100644--- a/pkg/sources/postman/postman.go+++ b/pkg/sources/postman/postman.go@@ -318,13 +318,13 @@ func (s *Source) scanWorkspace(ctx context.Context, chunksChan chan *sources.Chu// scanCollection scans a collection and all its items, folders, and requests.// locally scoped Metadata is updated as we drill down into the collection.func (s *Source) scanCollection(ctx context.Context, chunksChan chan *sources.Chunk, metadata Metadata, collection Collection) {- ctx.Logger().V(2).Info("starting to scan collection", "collection_name", collection.Info.Name, "collection_uuid", collection.Info.UID)+ ctx.Logger().V(2).Info("starting to scan collection", "collection_name", collection.Info.Name, "collection_uuid", collection.Info.Uid)metadata.CollectionInfo = collection.Infometadata.Type = COLLECTION_TYPEs.attemptToAddKeyword(collection.Info.Name)if !metadata.fromLocal {- metadata.FullID = metadata.CollectionInfo.UID+ metadata.FullID = metadata.CollectionInfo.Uidmetadata.Link = LINK_BASE_URL + COLLECTION_TYPE + "/" + metadata.FullID}@@ -361,20 +361,20 @@ func (s *Source) scanItem(ctx context.Context, chunksChan chan *sources.Chunk, cmetadata.FolderName = item.Name}- if item.UID != "" {- metadata.FullID = item.UID+ if item.Uid != "" {+ metadata.FullID = item.Uidmetadata.Link = LINK_BASE_URL + FOLDER_TYPE + "/" + metadata.FullID}// recurse through the foldersfor _, subItem := range item.Items {- s.scanItem(ctx, chunksChan, collection, metadata, subItem, item.UID)+ s.scanItem(ctx, chunksChan, collection, metadata, subItem, item.Uid)}// The assignment of the folder ID to be the current item UID is due to wanting to assume that your current item is a folder unless you have request data inside of your item.// If your current item is a folder, you will want the folder ID to match the UID of the current item.// If your current item is a request, you will want the folder ID to match the UID of the parent folder.// If the request is at the root of a collection and has no parent folder, the folder ID will be empty.- metadata.FolderID = item.UID+ metadata.FolderID = item.Uid// check if there are any requests in the folderif item.Request.Method != "" {metadata.FolderName = strings.Replace(metadata.FolderName, (" > " + item.Name), "", -1)@@ -382,13 +382,13 @@ func (s *Source) scanItem(ctx context.Context, chunksChan chan *sources.Chunk, cif metadata.FolderID == "" {metadata.FolderName = ""}- metadata.RequestID = item.UID+ metadata.RequestID = item.Uidmetadata.RequestName = item.Namemetadata.Type = REQUEST_TYPE- if item.UID != "" {+ if item.Uid != "" {// Route to API endpoint- metadata.FullID = item.UID- metadata.Link = LINK_BASE_URL + REQUEST_TYPE + "/" + item.UID+ metadata.FullID = item.Uid+ metadata.Link = LINK_BASE_URL + REQUEST_TYPE + "/" + item.Uid} else {// Route to collection.jsonmetadata.FullID = item.ID@@ -624,9 +624,9 @@ func (s *Source) scanRequestBody(ctx context.Context, chunksChan chan *sources.C}func (s *Source) scanHTTPResponse(ctx context.Context, chunksChan chan *sources.Chunk, m Metadata, response Response) {- if response.UID != "" {- m.Link = LINK_BASE_URL + "example/" + response.UID- m.FullID = response.UID+ if response.Uid != "" {+ m.Link = LINK_BASE_URL + "example/" + response.Uid+ m.FullID = response.Uid}originalType := m.Type@@ -720,7 +720,7 @@ func (s *Source) scanData(ctx context.Context, chunksChan chan *sources.Chunk, dLink: metadata.Link,WorkspaceUuid: metadata.WorkspaceUUID,WorkspaceName: metadata.WorkspaceName,- CollectionId: metadata.CollectionInfo.UID,+ CollectionId: metadata.CollectionInfo.Uid,CollectionName: metadata.CollectionInfo.Name,EnvironmentId: metadata.EnvironmentID,EnvironmentName: metadata.EnvironmentName,diff --git a/pkg/sources/postman/postman_client.go b/pkg/sources/postman/postman_client.goindex 87f26f9f8..440329fb1 100644--- a/pkg/sources/postman/postman_client.go+++ b/pkg/sources/postman/postman_client.go@@ -99,7 +99,7 @@ type Info struct {Description string `json:"description"`Schema string `json:"schema"`UpdatedAt time.Time `json:"updatedAt"`- UID string `json:"uid"` //Need to use this to get the collection via API+ Uid string `json:"uid"` //Need to use this to get the collection via API}type Item struct {@@ -112,7 +112,7 @@ type Item struct {Request Request `json:"request,omitempty"`Response []Response `json:"response,omitempty"`Description string `json:"description,omitempty"`- UID string `json:"uid,omitempty"` //Need to use this to get the collection via API. The UID is a concatenation of the ID and the user ID of whoever created the item.+ Uid string `json:"uid,omitempty"` //Need to use this to get the collection via API. The UID is a concatenation of the ID and the user ID of whoever created the item.}type Auth struct {@@ -180,7 +180,7 @@ type Response struct {HeaderKeyValue []KeyValueHeaderString []stringBody string `json:"body,omitempty"`- UID string `json:"uid,omitempty"`+ Uid string `json:"uid,omitempty"`}// A Client manages communication with the Postman API.