Skip to content

Find, verify, and analyze leaked credentials

Postman Source (#2579)

Zachary Riceb11ce7233850
diff --git a/main.go b/main.go
index 574c1574c..1d451f078 100644
--- a/main.go
+++ b/main.go
@@ -153,6 +153,20 @@ var (
travisCiScan = cli.Command("travisci", "Scan TravisCI")
travisCiScanToken = travisCiScan.Flag("token", "TravisCI token. Can also be provided with environment variable").Envar("TRAVISCI_TOKEN").Required().String()
+
+ // Postman is hidden for now until we get more feedback from the community.
+ postmanScan = cli.Command("postman", "Scan Postman").Hidden()
+ postmanToken = postmanScan.Flag("token", "Postman token. Can also be provided with environment variable").Envar("POSTMAN_TOKEN").String()
+ postmanWorkspaces = postmanScan.Flag("workspace", "Postman workspace to scan. You can repeat this flag.").Strings()
+ postmanCollections = postmanScan.Flag("collection", "Postman collection to scan. You can repeat this flag.").Strings()
+ postmanEnvironments = postmanScan.Flag("environment", "Postman environment to scan. You can repeat this flag.").Strings()
+ postmanIncludeCollections = postmanScan.Flag("include-collections", "Collections to include in scan. You can repeat this flag.").Strings()
+ postmanIncludeEnvironments = postmanScan.Flag("include-environments", "Environments to include in scan. You can repeat this flag.").Strings()
+ postmanExcludeCollections = postmanScan.Flag("exclude-collections", "Collections to exclude from scan. You can repeat this flag.").Strings()
+ postmanExcludeEnvironments = postmanScan.Flag("exclude-environments", "Environments to exclude from scan. You can repeat this flag.").Strings()
+ postmanWorkspacePaths = postmanScan.Flag("workspace-paths", "Path to Postman workspaces.").Strings()
+ postmanCollectionPaths = postmanScan.Flag("collection-paths", "Path to Postman collections.").Strings()
+ postmanEnvironmentPaths = postmanScan.Flag("environment-paths", "Path to Postman environments.").Strings()
)
func init() {
@@ -577,6 +591,23 @@ func run(state overseer.State) {
if err := e.ScanDocker(ctx, anyConn); err != nil {
logFatal(err, "Failed to scan Docker.")
}
+ case postmanScan.FullCommand():
+ cfg := sources.PostmanConfig{
+ Token: *postmanToken,
+ Workspaces: *postmanWorkspaces,
+ Collections: *postmanCollections,
+ Environments: *postmanEnvironments,
+ IncludeCollections: *postmanIncludeCollections,
+ IncludeEnvironments: *postmanIncludeEnvironments,
+ ExcludeCollections: *postmanExcludeCollections,
+ ExcludeEnvironments: *postmanExcludeEnvironments,
+ CollectionPaths: *postmanCollectionPaths,
+ WorkspacePaths: *postmanWorkspacePaths,
+ EnvironmentPaths: *postmanEnvironmentPaths,
+ }
+ if err := e.ScanPostman(ctx, cfg); err != nil {
+ logFatal(err, "Failed to scan Postman.")
+ }
}
// Wait for all workers to finish.
diff --git a/pkg/engine/ahocorasick/ahocorasickcore.go b/pkg/engine/ahocorasick/ahocorasickcore.go
index e5eb3f60d..ab1f3eeb6 100644
--- a/pkg/engine/ahocorasick/ahocorasickcore.go
+++ b/pkg/engine/ahocorasick/ahocorasickcore.go
@@ -123,3 +123,7 @@ func CreateDetectorKey(d detectors.Detector) DetectorKey {
}
return DetectorKey{detectorType: detectorType, version: version, customDetectorName: customDetectorName}
}
+
+func (ac *AhoCorasickCore) KeywordsToDetectors() map[string][]DetectorKey {
+ return ac.keywordsToDetectors
+}
diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go
index 9d6e1d609..1a3405343 100644
--- a/pkg/engine/engine.go
+++ b/pkg/engine/engine.go
@@ -887,8 +887,10 @@ func (e *Engine) notifyResults(ctx context.Context) {
// want to include duplicate results with the same decoder type.
// Duplicate results with the same decoder type SHOULD have their own entry in the
// results list, this would happen if the same secret is found multiple times.
+ // Note: If the source type is postman, we dedupe the results regardless of decoder type.
key := fmt.Sprintf("%s%s%s%+v", r.DetectorType.String(), r.Raw, r.RawV2, r.SourceMetadata)
- if val, ok := e.dedupeCache.Get(key); ok && val != r.DecoderType {
+ if val, ok := e.dedupeCache.Get(key); ok && (val != r.DecoderType ||
+ r.SourceType == sourcespb.SourceType_SOURCE_TYPE_POSTMAN) {
continue
}
e.dedupeCache.Add(key, r.DecoderType)
diff --git a/pkg/engine/postman.go b/pkg/engine/postman.go
new file mode 100644
index 000000000..59e8a69b6
--- /dev/null
+++ b/pkg/engine/postman.go
@@ -0,0 +1,66 @@
+package engine
+
+import (
+ "errors"
+
+ "google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/anypb"
+
+ "github.com/trufflesecurity/trufflehog/v3/pkg/context"
+ "github.com/trufflesecurity/trufflehog/v3/pkg/pb/sourcespb"
+ "github.com/trufflesecurity/trufflehog/v3/pkg/sources"
+ "github.com/trufflesecurity/trufflehog/v3/pkg/sources/postman"
+)
+
+// ScanGitHub scans Postman with the provided options.
+func (e *Engine) ScanPostman(ctx context.Context, c sources.PostmanConfig) error {
+ connection := sourcespb.Postman{
+ Workspaces: c.Workspaces,
+ Collections: c.Collections,
+ Environments: c.Environments,
+ IncludeCollections: c.IncludeCollections,
+ IncludeEnvironments: c.IncludeEnvironments,
+ ExcludeCollections: c.ExcludeCollections,
+ ExcludeEnvironments: c.ExcludeEnvironments,
+ WorkspacePaths: c.WorkspacePaths,
+ CollectionPaths: c.CollectionPaths,
+ EnvironmentPaths: c.EnvironmentPaths,
+ }
+ if len(c.Token) > 0 {
+ connection.Credential = &sourcespb.Postman_Token{
+ Token: c.Token,
+ }
+ } else {
+ connection.Credential = &sourcespb.Postman_Unauthenticated{}
+ }
+
+ if len(c.Workspaces) == 0 && len(c.Collections) == 0 && len(c.Environments) == 0 && len(c.Token) == 0 && len(c.WorkspacePaths) == 0 && len(c.CollectionPaths) == 0 && len(c.EnvironmentPaths) == 0 {
+ ctx.Logger().Error(errors.New("no postman workspaces, collections, environments or API token provided"), "failed to scan postman")
+ return nil
+ }
+
+ // Turn AhoCorasick keywordsToDetectors into a map of keywords
+ keywords := make(map[string]struct{})
+ for key := range e.ahoCorasickCore.KeywordsToDetectors() {
+ keywords[key] = struct{}{}
+ }
+
+ var conn anypb.Any
+ err := anypb.MarshalFrom(&conn, &connection, proto.MarshalOptions{})
+ if err != nil {
+ ctx.Logger().Error(err, "failed to marshal Postman connection")
+ return err
+ }
+
+ sourceName := "trufflehog - postman"
+ sourceID, jobID, _ := e.sourceManager.GetIDs(ctx, sourceName, postman.SourceType)
+
+ postmanSource := &postman.Source{
+ DetectorKeywords: keywords,
+ }
+ if err := postmanSource.Init(ctx, sourceName, jobID, sourceID, true, &conn, c.Concurrency); err != nil {
+ return err
+ }
+ _, err = e.sourceManager.Run(ctx, sourceName, postmanSource)
+ return err
+}
diff --git a/pkg/pb/source_metadatapb/source_metadata.pb.go b/pkg/pb/source_metadatapb/source_metadata.pb.go
index e130b4414..c9fe6356f 100644
--- a/pkg/pb/source_metadatapb/source_metadata.pb.go
+++ b/pkg/pb/source_metadatapb/source_metadata.pb.go
@@ -2645,6 +2645,165 @@ func (x *AzureRepos) GetOrganization() string {
return ""
}
+type Postman struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Link string `protobuf:"bytes,1,opt,name=link,proto3" json:"link,omitempty"`
+ WorkspaceUuid string `protobuf:"bytes,2,opt,name=workspace_uuid,json=workspaceUuid,proto3" json:"workspace_uuid,omitempty"`
+ WorkspaceName string `protobuf:"bytes,3,opt,name=workspace_name,json=workspaceName,proto3" json:"workspace_name,omitempty"`
+ GlobalsId string `protobuf:"bytes,4,opt,name=globals_id,json=globalsId,proto3" json:"globals_id,omitempty"`
+ CollectionId string `protobuf:"bytes,5,opt,name=collection_id,json=collectionId,proto3" json:"collection_id,omitempty"`
+ CollectionName string `protobuf:"bytes,6,opt,name=collection_name,json=collectionName,proto3" json:"collection_name,omitempty"`
+ EnvironmentId string `protobuf:"bytes,7,opt,name=environment_id,json=environmentId,proto3" json:"environment_id,omitempty"`
+ EnvironmentName string `protobuf:"bytes,8,opt,name=environment_name,json=environmentName,proto3" json:"environment_name,omitempty"`
+ RequestId string `protobuf:"bytes,9,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
+ RequestName string `protobuf:"bytes,10,opt,name=request_name,json=requestName,proto3" json:"request_name,omitempty"`
+ FolderId string `protobuf:"bytes,11,opt,name=folder_id,json=folderId,proto3" json:"folder_id,omitempty"`
+ FolderName string `protobuf:"bytes,12,opt,name=folder_name,json=folderName,proto3" json:"folder_name,omitempty"`
+ FieldType string `protobuf:"bytes,13,opt,name=field_type,json=fieldType,proto3" json:"field_type,omitempty"`
+ FieldName string `protobuf:"bytes,14,opt,name=field_name,json=fieldName,proto3" json:"field_name,omitempty"`
+ VariableType string `protobuf:"bytes,15,opt,name=variable_type,json=variableType,proto3" json:"variable_type,omitempty"`
+}
+
+func (x *Postman) Reset() {
+ *x = Postman{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_source_metadata_proto_msgTypes[28]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *Postman) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Postman) ProtoMessage() {}
+
+func (x *Postman) ProtoReflect() protoreflect.Message {
+ mi := &file_source_metadata_proto_msgTypes[28]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use Postman.ProtoReflect.Descriptor instead.
+func (*Postman) Descriptor() ([]byte, []int) {
+ return file_source_metadata_proto_rawDescGZIP(), []int{28}
+}
+
+func (x *Postman) GetLink() string {
+ if x != nil {
+ return x.Link
+ }
+ return ""
+}
+
+func (x *Postman) GetWorkspaceUuid() string {
+ if x != nil {
+ return x.WorkspaceUuid
+ }
+ return ""
+}
+
+func (x *Postman) GetWorkspaceName() string {
+ if x != nil {
+ return x.WorkspaceName
+ }
+ return ""
+}
+
+func (x *Postman) GetGlobalsId() string {
+ if x != nil {
+ return x.GlobalsId
+ }
+ return ""
+}
+
+func (x *Postman) GetCollectionId() string {
+ if x != nil {
+ return x.CollectionId
+ }
+ return ""
+}
+
+func (x *Postman) GetCollectionName() string {
+ if x != nil {
+ return x.CollectionName
+ }
+ return ""
+}
+
+func (x *Postman) GetEnvironmentId() string {
+ if x != nil {
+ return x.EnvironmentId
+ }
+ return ""
+}
+
+func (x *Postman) GetEnvironmentName() string {
+ if x != nil {
+ return x.EnvironmentName
+ }
+ return ""
+}
+
+func (x *Postman) GetRequestId() string {
+ if x != nil {
+ return x.RequestId
+ }
+ return ""
+}
+
+func (x *Postman) GetRequestName() string {
+ if x != nil {
+ return x.RequestName
+ }
+ return ""
+}
+
+func (x *Postman) GetFolderId() string {
+ if x != nil {
+ return x.FolderId
+ }
+ return ""
+}
+
+func (x *Postman) GetFolderName() string {
+ if x != nil {
+ return x.FolderName
+ }
+ return ""
+}
+
+func (x *Postman) GetFieldType() string {
+ if x != nil {
+ return x.FieldType
+ }
+ return ""
+}
+
+func (x *Postman) GetFieldName() string {
+ if x != nil {
+ return x.FieldName
+ }
+ return ""
+}
+
+func (x *Postman) GetVariableType() string {
+ if x != nil {
+ return x.VariableType
+ }
+ return ""
+}
+
type MetaData struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -2680,13 +2839,14 @@ type MetaData struct {
// *MetaData_GoogleDrive
// *MetaData_AzureRepos
// *MetaData_TravisCI
+ // *MetaData_Postman
Data isMetaData_Data `protobuf_oneof:"data"`
}
func (x *MetaData) Reset() {
*x = MetaData{}
if protoimpl.UnsafeEnabled {
- mi := &file_source_metadata_proto_msgTypes[28]
+ mi := &file_source_metadata_proto_msgTypes[29]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2699,7 +2859,7 @@ func (x *MetaData) String() string {
func (*MetaData) ProtoMessage() {}
func (x *MetaData) ProtoReflect() protoreflect.Message {
- mi := &file_source_metadata_proto_msgTypes[28]
+ mi := &file_source_metadata_proto_msgTypes[29]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2712,7 +2872,7 @@ func (x *MetaData) ProtoReflect() protoreflect.Message {
// Deprecated: Use MetaData.ProtoReflect.Descriptor instead.
func (*MetaData) Descriptor() ([]byte, []int) {
- return file_source_metadata_proto_rawDescGZIP(), []int{28}
+ return file_source_metadata_proto_rawDescGZIP(), []int{29}
}
func (m *MetaData) GetData() isMetaData_Data {
@@ -2918,6 +3078,13 @@ func (x *MetaData) GetTravisCI() *TravisCI {
return nil
}
+func (x *MetaData) GetPostman() *Postman {
+ if x, ok := x.GetData().(*MetaData_Postman); ok {
+ return x.Postman
+ }
+ return nil
+}
+
type isMetaData_Data interface {
isMetaData_Data()
}
@@ -3034,6 +3201,10 @@ type MetaData_TravisCI struct {
TravisCI *TravisCI `protobuf:"bytes,28,opt,name=travisCI,proto3,oneof"`
}
+type MetaData_Postman struct {
+ Postman *Postman `protobuf:"bytes,29,opt,name=postman,proto3,oneof"`
+}
+
func (*MetaData_Azure) isMetaData_Data() {}
func (*MetaData_Bitbucket) isMetaData_Data() {}
@@ -3090,6 +3261,8 @@ func (*MetaData_AzureRepos) isMetaData_Data() {}
func (*MetaData_TravisCI) isMetaData_Data() {}
+func (*MetaData_Postman) isMetaData_Data() {}
+
var File_source_metadata_proto protoreflect.FileDescriptor
var file_source_metadata_proto_rawDesc = []byte{
@@ -3409,7 +3582,40 @@ var file_source_metadata_proto_rawDesc = []byte{
0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x22,
0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0b,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69,
- 0x6f, 0x6e, 0x22, 0xcd, 0x0b, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x44, 0x61, 0x74, 0x61, 0x12,
+ 0x6f, 0x6e, 0x22, 0x8d, 0x04, 0x0a, 0x07, 0x50, 0x6f, 0x73, 0x74, 0x6d, 0x61, 0x6e, 0x12, 0x12,
+ 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x69,
+ 0x6e, 0x6b, 0x12, 0x25, 0x0a, 0x0e, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f,
+ 0x75, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x77, 0x6f, 0x72, 0x6b,
+ 0x73, 0x70, 0x61, 0x63, 0x65, 0x55, 0x75, 0x69, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x77, 0x6f, 0x72,
+ 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
+ 0x09, 0x52, 0x0d, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65,
+ 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x04,
+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x49, 0x64, 0x12,
+ 0x23, 0x0a, 0x0d, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64,
+ 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63,
+ 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a,
+ 0x0e, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18,
+ 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65,
+ 0x6e, 0x74, 0x49, 0x64, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d,
+ 0x65, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f,
+ 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12,
+ 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x09, 0x20,
+ 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x21,
+ 0x0a, 0x0c, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0a,
+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4e, 0x61, 0x6d,
+ 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x0b,
+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1f,
+ 0x0a, 0x0b, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0c, 0x20,
+ 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12,
+ 0x1d, 0x0a, 0x0a, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0d, 0x20,
+ 0x01, 0x28, 0x09, 0x52, 0x09, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d,
+ 0x0a, 0x0a, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0e, 0x20, 0x01,
+ 0x28, 0x09, 0x52, 0x09, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a,
+ 0x0d, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0f,
+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x79,
+ 0x70, 0x65, 0x22, 0x83, 0x0c, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x44, 0x61, 0x74, 0x61, 0x12,
0x2e, 0x0a, 0x05, 0x61, 0x7a, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16,
0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61,
0x2e, 0x41, 0x7a, 0x75, 0x72, 0x65, 0x48, 0x00, 0x52, 0x05, 0x61, 0x7a, 0x75, 0x72, 0x65, 0x12,
@@ -3501,16 +3707,20 @@ var file_source_metadata_proto_rawDesc = []byte{
0x73, 0x12, 0x37, 0x0a, 0x08, 0x74, 0x72, 0x61, 0x76, 0x69, 0x73, 0x43, 0x49, 0x18, 0x1c, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74,
0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x72, 0x61, 0x76, 0x69, 0x73, 0x43, 0x49, 0x48, 0x00,
- 0x52, 0x08, 0x74, 0x72, 0x61, 0x76, 0x69, 0x73, 0x43, 0x49, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61,
- 0x74, 0x61, 0x2a, 0x3e, 0x0a, 0x0a, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79,
- 0x12, 0x0a, 0x0a, 0x06, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07,
- 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x73, 0x68, 0x61,
- 0x72, 0x65, 0x64, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x75, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e,
- 0x10, 0x03, 0x42, 0x43, 0x5a, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
- 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79,
- 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x68, 0x6f, 0x67, 0x2f, 0x76, 0x33, 0x2f, 0x70,
- 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74,
- 0x61, 0x64, 0x61, 0x74, 0x61, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x52, 0x08, 0x74, 0x72, 0x61, 0x76, 0x69, 0x73, 0x43, 0x49, 0x12, 0x34, 0x0a, 0x07, 0x70, 0x6f,
+ 0x73, 0x74, 0x6d, 0x61, 0x6e, 0x18, 0x1d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x73, 0x6f,
+ 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x50, 0x6f,
+ 0x73, 0x74, 0x6d, 0x61, 0x6e, 0x48, 0x00, 0x52, 0x07, 0x70, 0x6f, 0x73, 0x74, 0x6d, 0x61, 0x6e,
+ 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x2a, 0x3e, 0x0a, 0x0a, 0x56, 0x69, 0x73, 0x69,
+ 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x0a, 0x0a, 0x06, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63,
+ 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x10, 0x01, 0x12,
+ 0x0a, 0x0a, 0x06, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x75,
+ 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x03, 0x42, 0x43, 0x5a, 0x41, 0x67, 0x69, 0x74, 0x68,
+ 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x73, 0x65,
+ 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x68, 0x6f,
+ 0x67, 0x2f, 0x76, 0x33, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x73, 0x6f, 0x75, 0x72,
+ 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x70, 0x62, 0x62, 0x06, 0x70,
+ 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -3526,7 +3736,7 @@ func file_source_metadata_proto_rawDescGZIP() []byte {
}
var file_source_metadata_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
-var file_source_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 29)
+var file_source_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 30)
var file_source_metadata_proto_goTypes = []interface{}{
(Visibility)(0), // 0: source_metadata.Visibility
(*Azure)(nil), // 1: source_metadata.Azure
@@ -3557,7 +3767,8 @@ var file_source_metadata_proto_goTypes = []interface{}{
(*SharePoint)(nil), // 26: source_metadata.SharePoint
(*GoogleDrive)(nil), // 27: source_metadata.GoogleDrive
(*AzureRepos)(nil), // 28: source_metadata.AzureRepos
- (*MetaData)(nil), // 29: source_metadata.MetaData
+ (*Postman)(nil), // 29: source_metadata.Postman
+ (*MetaData)(nil), // 30: source_metadata.MetaData
}
var file_source_metadata_proto_depIdxs = []int32{
0, // 0: source_metadata.Github.visibility:type_name -> source_metadata.Visibility
@@ -3594,11 +3805,12 @@ var file_source_metadata_proto_depIdxs = []int32{
27, // 31: source_metadata.MetaData.googleDrive:type_name -> source_metadata.GoogleDrive
28, // 32: source_metadata.MetaData.azureRepos:type_name -> source_metadata.AzureRepos
5, // 33: source_metadata.MetaData.travisCI:type_name -> source_metadata.TravisCI
- 34, // [34:34] is the sub-list for method output_type
- 34, // [34:34] is the sub-list for method input_type
- 34, // [34:34] is the sub-list for extension type_name
- 34, // [34:34] is the sub-list for extension extendee
- 0, // [0:34] is the sub-list for field type_name
+ 29, // 34: source_metadata.MetaData.postman:type_name -> source_metadata.Postman
+ 35, // [35:35] is the sub-list for method output_type
+ 35, // [35:35] is the sub-list for method input_type
+ 35, // [35:35] is the sub-list for extension type_name
+ 35, // [35:35] is the sub-list for extension extendee
+ 0, // [0:35] is the sub-list for field type_name
}
func init() { file_source_metadata_proto_init() }
@@ -3944,6 +4156,18 @@ func file_source_metadata_proto_init() {
}
}
file_source_metadata_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*Postman); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_source_metadata_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MetaData); i {
case 0:
return &v.state
@@ -3961,7 +4185,7 @@ func file_source_metadata_proto_init() {
(*Forager_Npm)(nil),
(*Forager_Pypi)(nil),
}
- file_source_metadata_proto_msgTypes[28].OneofWrappers = []interface{}{
+ file_source_metadata_proto_msgTypes[29].OneofWrappers = []interface{}{
(*MetaData_Azure)(nil),
(*MetaData_Bitbucket)(nil),
(*MetaData_Circleci)(nil),
@@ -3990,6 +4214,7 @@ func file_source_metadata_proto_init() {
(*MetaData_GoogleDrive)(nil),
(*MetaData_AzureRepos)(nil),
(*MetaData_TravisCI)(nil),
+ (*MetaData_Postman)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{
@@ -3997,7 +4222,7 @@ func file_source_metadata_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_source_metadata_proto_rawDesc,
NumEnums: 1,
- NumMessages: 29,
+ NumMessages: 30,
NumExtensions: 0,
NumServices: 0,
},
diff --git a/pkg/pb/source_metadatapb/source_metadata.pb.validate.go b/pkg/pb/source_metadatapb/source_metadata.pb.validate.go
index 6e5dd394a..f1d498c80 100644
--- a/pkg/pb/source_metadatapb/source_metadata.pb.validate.go
+++ b/pkg/pb/source_metadatapb/source_metadata.pb.validate.go
@@ -3240,6 +3240,134 @@ var _ interface {
ErrorName() string
} = AzureReposValidationError{}
+// Validate checks the field values on Postman with the rules defined in the
+// proto definition for this message. If any rules are violated, the first
+// error encountered is returned, or nil if there are no violations.
+func (m *Postman) Validate() error {
+ return m.validate(false)
+}
+
+// ValidateAll checks the field values on Postman with the rules defined in the
+// proto definition for this message. If any rules are violated, the result is
+// a list of violation errors wrapped in PostmanMultiError, or nil if none found.
+func (m *Postman) ValidateAll() error {
+ return m.validate(true)
+}
+
+func (m *Postman) validate(all bool) error {
+ if m == nil {
+ return nil
+ }
+
+ var errors []error
+
+ // no validation rules for Link
+
+ // no validation rules for WorkspaceUuid
+
+ // no validation rules for WorkspaceName
+
+ // no validation rules for GlobalsId
+
+ // no validation rules for CollectionId
+
+ // no validation rules for CollectionName
+
+ // no validation rules for EnvironmentId
+
+ // no validation rules for EnvironmentName
+
+ // no validation rules for RequestId
+
+ // no validation rules for RequestName
+
+ // no validation rules for FolderId
+
+ // no validation rules for FolderName
+
+ // no validation rules for FieldType
+
+ // no validation rules for FieldName
+
+ // no validation rules for VariableType
+
+ if len(errors) > 0 {
+ return PostmanMultiError(errors)
+ }
+
+ return nil
+}
+
+// PostmanMultiError is an error wrapping multiple validation errors returned
+// by Postman.ValidateAll() if the designated constraints aren't met.
+type PostmanMultiError []error
+
+// Error returns a concatenation of all the error messages it wraps.
+func (m PostmanMultiError) Error() string {
+ var msgs []string
+ for _, err := range m {
+ msgs = append(msgs, err.Error())
+ }
+ return strings.Join(msgs, "; ")
+}
+
+// AllErrors returns a list of validation violation errors.
+func (m PostmanMultiError) AllErrors() []error { return m }
+
+// PostmanValidationError is the validation error returned by Postman.Validate
+// if the designated constraints aren't met.
+type PostmanValidationError struct {
+ field string
+ reason string
+ cause error
+ key bool
+}
+
+// Field function returns field value.
+func (e PostmanValidationError) Field() string { return e.field }
+
+// Reason function returns reason value.
+func (e PostmanValidationError) Reason() string { return e.reason }
+
+// Cause function returns cause value.
+func (e PostmanValidationError) Cause() error { return e.cause }
+
+// Key function returns key value.
+func (e PostmanValidationError) Key() bool { return e.key }
+
+// ErrorName returns error name.
+func (e PostmanValidationError) ErrorName() string { return "PostmanValidationError" }
+
+// Error satisfies the builtin error interface
+func (e PostmanValidationError) Error() string {
+ cause := ""
+ if e.cause != nil {
+ cause = fmt.Sprintf(" | caused by: %v", e.cause)
+ }
+
+ key := ""
+ if e.key {
+ key = "key for "
+ }
+
+ return fmt.Sprintf(
+ "invalid %sPostman.%s: %s%s",
+ key,
+ e.field,
+ e.reason,
+ cause)
+}
+
+var _ error = PostmanValidationError{}
+
+var _ interface {
+ Field() string
+ Reason() string
+ Key() bool
+ Cause() error
+ ErrorName() string
+} = PostmanValidationError{}
+
// Validate checks the field values on MetaData with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
@@ -4132,6 +4260,37 @@ func (m *MetaData) validate(all bool) error {
}
}
+ case *MetaData_Postman:
+
+ if all {
+ switch v := interface{}(m.GetPostman()).(type) {
+ case interface{ ValidateAll() error }:
+ if err := v.ValidateAll(); err != nil {
+ errors = append(errors, MetaDataValidationError{
+ field: "Postman",
+ reason: "embedded message failed validation",
+ cause: err,
+ })
+ }
+ case interface{ Validate() error }:
+ if err := v.Validate(); err != nil {
+ errors = append(errors, MetaDataValidationError{
+ field: "Postman",
+ reason: "embedded message failed validation",
+ cause: err,
+ })
+ }
+ }
+ } else if v, ok := interface{}(m.GetPostman()).(interface{ Validate() error }); ok {
+ if err := v.Validate(); err != nil {
+ return MetaDataValidationError{
+ field: "Postman",
+ reason: "embedded message failed validation",
+ cause: err,
+ }
+ }
+ }
+
}
if len(errors) > 0 {
diff --git a/pkg/pb/sourcespb/sources.pb.go b/pkg/pb/sourcespb/sources.pb.go
index 5adbbed28..9941dc963 100644
--- a/pkg/pb/sourcespb/sources.pb.go
+++ b/pkg/pb/sourcespb/sources.pb.go
@@ -61,6 +61,7 @@ const (
SourceType_SOURCE_TYPE_GCS_UNAUTHED SourceType = 30
SourceType_SOURCE_TYPE_AZURE_REPOS SourceType = 31
SourceType_SOURCE_TYPE_TRAVISCI SourceType = 32
+ SourceType_SOURCE_TYPE_POSTMAN SourceType = 33
)
// Enum value maps for SourceType.
@@ -99,6 +100,7 @@ var (
30: "SOURCE_TYPE_GCS_UNAUTHED",
31: "SOURCE_TYPE_AZURE_REPOS",
32: "SOURCE_TYPE_TRAVISCI",
+ 33: "SOURCE_TYPE_POSTMAN",
}
SourceType_value = map[string]int32{
"SOURCE_TYPE_AZURE_STORAGE": 0,
@@ -134,6 +136,7 @@ var (
"SOURCE_TYPE_GCS_UNAUTHED": 30,
"SOURCE_TYPE_AZURE_REPOS": 31,
"SOURCE_TYPE_TRAVISCI": 32,
+ "SOURCE_TYPE_POSTMAN": 33,
}
)
@@ -3510,6 +3513,175 @@ func (*AzureRepos_Token) isAzureRepos_Credential() {}
func (*AzureRepos_Oauth) isAzureRepos_Credential() {}
+type Postman struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ // Types that are assignable to Credential:
+ //
+ // *Postman_Unauthenticated
+ // *Postman_Token
+ Credential isPostman_Credential `protobuf_oneof:"credential"`
+ Workspaces []string `protobuf:"bytes,3,rep,name=workspaces,proto3" json:"workspaces,omitempty"`
+ Collections []string `protobuf:"bytes,4,rep,name=collections,proto3" json:"collections,omitempty"`
+ Environments []string `protobuf:"bytes,5,rep,name=environments,proto3" json:"environments,omitempty"`
+ ExcludeCollections []string `protobuf:"bytes,6,rep,name=exclude_collections,json=excludeCollections,proto3" json:"exclude_collections,omitempty"`
+ ExcludeEnvironments []string `protobuf:"bytes,7,rep,name=exclude_environments,json=excludeEnvironments,proto3" json:"exclude_environments,omitempty"`
+ IncludeCollections []string `protobuf:"bytes,8,rep,name=include_collections,json=includeCollections,proto3" json:"include_collections,omitempty"`
+ IncludeEnvironments []string `protobuf:"bytes,9,rep,name=include_environments,json=includeEnvironments,proto3" json:"include_environments,omitempty"`
+ DetectorKeywords []string `protobuf:"bytes,10,rep,name=detector_keywords,json=detectorKeywords,proto3" json:"detector_keywords,omitempty"`
+ WorkspacePaths []string `protobuf:"bytes,11,rep,name=workspace_paths,json=workspacePaths,proto3" json:"workspace_paths,omitempty"`
+ CollectionPaths []string `protobuf:"bytes,12,rep,name=collection_paths,json=collectionPaths,proto3" json:"collection_paths,omitempty"`
+ EnvironmentPaths []string `protobuf:"bytes,13,rep,name=environment_paths,json=environmentPaths,proto3" json:"environment_paths,omitempty"`
+}
+
+func (x *Postman) Reset() {
+ *x = Postman{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_sources_proto_msgTypes[30]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *Postman) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Postman) ProtoMessage() {}
+
+func (x *Postman) ProtoReflect() protoreflect.Message {
+ mi := &file_sources_proto_msgTypes[30]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use Postman.ProtoReflect.Descriptor instead.
+func (*Postman) Descriptor() ([]byte, []int) {
+ return file_sources_proto_rawDescGZIP(), []int{30}
+}
+
+func (m *Postman) GetCredential() isPostman_Credential {
+ if m != nil {
+ return m.Credential
+ }
+ return nil
+}
+
+func (x *Postman) GetUnauthenticated() *credentialspb.Unauthenticated {
+ if x, ok := x.GetCredential().(*Postman_Unauthenticated); ok {
+ return x.Unauthenticated
+ }
+ return nil
+}
+
+func (x *Postman) GetToken() string {
+ if x, ok := x.GetCredential().(*Postman_Token); ok {
+ return x.Token
+ }
+ return ""
+}
+
+func (x *Postman) GetWorkspaces() []string {
+ if x != nil {
+ return x.Workspaces
+ }
+ return nil
+}
+
+func (x *Postman) GetCollections() []string {
+ if x != nil {
+ return x.Collections
+ }
+ return nil
+}
+
+func (x *Postman) GetEnvironments() []string {
+ if x != nil {
+ return x.Environments
+ }
+ return nil
+}
+
+func (x *Postman) GetExcludeCollections() []string {
+ if x != nil {
+ return x.ExcludeCollections
+ }
+ return nil
+}
+
+func (x *Postman) GetExcludeEnvironments() []string {
+ if x != nil {
+ return x.ExcludeEnvironments
+ }
+ return nil
+}
+
+func (x *Postman) GetIncludeCollections() []string {
+ if x != nil {
+ return x.IncludeCollections
+ }
+ return nil
+}
+
+func (x *Postman) GetIncludeEnvironments() []string {
+ if x != nil {
+ return x.IncludeEnvironments
+ }
+ return nil
+}
+
+func (x *Postman) GetDetectorKeywords() []string {
+ if x != nil {
+ return x.DetectorKeywords
+ }
+ return nil
+}
+
+func (x *Postman) GetWorkspacePaths() []string {
+ if x != nil {
+ return x.WorkspacePaths
+ }
+ return nil
+}
+
+func (x *Postman) GetCollectionPaths() []string {
+ if x != nil {
+ return x.CollectionPaths
+ }
+ return nil
+}
+
+func (x *Postman) GetEnvironmentPaths() []string {
+ if x != nil {
+ return x.EnvironmentPaths
+ }
+ return nil
+}
+
+type isPostman_Credential interface {
+ isPostman_Credential()
+}
+
+type Postman_Unauthenticated struct {
+ Unauthenticated *credentialspb.Unauthenticated `protobuf:"bytes,1,opt,name=unauthenticated,proto3,oneof"`
+}
+
+type Postman_Token struct {
+ Token string `protobuf:"bytes,2,opt,name=token,proto3,oneof"`
+}
+
+func (*Postman_Unauthenticated) isPostman_Credential() {}
+
+func (*Postman_Token) isPostman_Credential() {}
+
var File_sources_proto protoreflect.FileDescriptor
var file_sources_proto_rawDesc = []byte{
@@ -4023,69 +4195,108 @@ var file_sources_proto_rawDesc = []byte{
0x61, 0x72, 0x69, 0x65, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x6b, 0x69, 0x70, 0x5f, 0x61, 0x72,
0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x73, 0x6b,
0x69, 0x70, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x42, 0x0c, 0x0a, 0x0a, 0x63, 0x72,
- 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x2a, 0x9e, 0x07, 0x0a, 0x0a, 0x53, 0x6f, 0x75,
- 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x19, 0x53, 0x4f, 0x55, 0x52, 0x43,
- 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x41, 0x5a, 0x55, 0x52, 0x45, 0x5f, 0x53, 0x54, 0x4f,
- 0x52, 0x41, 0x47, 0x45, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45,
- 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, 0x49, 0x54, 0x42, 0x55, 0x43, 0x4b, 0x45, 0x54, 0x10,
- 0x01, 0x12, 0x18, 0x0a, 0x14, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45,
- 0x5f, 0x43, 0x49, 0x52, 0x43, 0x4c, 0x45, 0x43, 0x49, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, 0x53,
- 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x43, 0x4f, 0x4e, 0x46, 0x4c,
- 0x55, 0x45, 0x4e, 0x43, 0x45, 0x10, 0x03, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x55, 0x52, 0x43,
- 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x44, 0x4f, 0x43, 0x4b, 0x45, 0x52, 0x10, 0x04, 0x12,
- 0x13, 0x0a, 0x0f, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x45,
- 0x43, 0x52, 0x10, 0x05, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54,
- 0x59, 0x50, 0x45, 0x5f, 0x47, 0x43, 0x53, 0x10, 0x06, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x55,
- 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x49, 0x54, 0x48, 0x55, 0x42, 0x10,
- 0x07, 0x12, 0x1a, 0x0a, 0x16, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45,
- 0x5f, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x5f, 0x47, 0x49, 0x54, 0x10, 0x08, 0x12, 0x16, 0x0a,
- 0x12, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x49, 0x54,
- 0x4c, 0x41, 0x42, 0x10, 0x09, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f,
- 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4a, 0x49, 0x52, 0x41, 0x10, 0x0a, 0x12, 0x24, 0x0a, 0x20, 0x53,
- 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4e, 0x50, 0x4d, 0x5f, 0x55,
- 0x4e, 0x41, 0x55, 0x54, 0x48, 0x44, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x41, 0x47, 0x45, 0x53, 0x10,
- 0x0b, 0x12, 0x25, 0x0a, 0x21, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45,
- 0x5f, 0x50, 0x59, 0x50, 0x49, 0x5f, 0x55, 0x4e, 0x41, 0x55, 0x54, 0x48, 0x44, 0x5f, 0x50, 0x41,
- 0x43, 0x4b, 0x41, 0x47, 0x45, 0x53, 0x10, 0x0c, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x4f, 0x55, 0x52,
- 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x33, 0x10, 0x0d, 0x12, 0x15, 0x0a, 0x11,
- 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x4c, 0x41, 0x43,
- 0x4b, 0x10, 0x0e, 0x12, 0x1a, 0x0a, 0x16, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59,
- 0x50, 0x45, 0x5f, 0x46, 0x49, 0x4c, 0x45, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x10, 0x0f, 0x12,
- 0x13, 0x0a, 0x0f, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47,
- 0x49, 0x54, 0x10, 0x10, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54,
- 0x59, 0x50, 0x45, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x10, 0x11, 0x12, 0x1b, 0x0a, 0x17, 0x53, 0x4f,
- 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x33, 0x5f, 0x55, 0x4e, 0x41,
- 0x55, 0x54, 0x48, 0x45, 0x44, 0x10, 0x12, 0x12, 0x2a, 0x0a, 0x26, 0x53, 0x4f, 0x55, 0x52, 0x43,
- 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x49, 0x54, 0x48, 0x55, 0x42, 0x5f, 0x55, 0x4e,
- 0x41, 0x55, 0x54, 0x48, 0x45, 0x4e, 0x54, 0x49, 0x43, 0x41, 0x54, 0x45, 0x44, 0x5f, 0x4f, 0x52,
- 0x47, 0x10, 0x13, 0x12, 0x19, 0x0a, 0x15, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59,
- 0x50, 0x45, 0x5f, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x4b, 0x49, 0x54, 0x45, 0x10, 0x14, 0x12, 0x16,
- 0x0a, 0x12, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x45,
- 0x52, 0x52, 0x49, 0x54, 0x10, 0x15, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45,
- 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4a, 0x45, 0x4e, 0x4b, 0x49, 0x4e, 0x53, 0x10, 0x16, 0x12,
- 0x15, 0x0a, 0x11, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54,
- 0x45, 0x41, 0x4d, 0x53, 0x10, 0x17, 0x12, 0x21, 0x0a, 0x1d, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45,
- 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4a, 0x46, 0x52, 0x4f, 0x47, 0x5f, 0x41, 0x52, 0x54, 0x49,
- 0x46, 0x41, 0x43, 0x54, 0x4f, 0x52, 0x59, 0x10, 0x18, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x55,
- 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x59, 0x53, 0x4c, 0x4f, 0x47, 0x10,
- 0x19, 0x12, 0x27, 0x0a, 0x23, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45,
- 0x5f, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x5f, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x4d, 0x4f,
- 0x4e, 0x49, 0x54, 0x4f, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x1a, 0x12, 0x1e, 0x0a, 0x1a, 0x53, 0x4f,
- 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x4c, 0x41, 0x43, 0x4b, 0x5f,
- 0x52, 0x45, 0x41, 0x4c, 0x54, 0x49, 0x4d, 0x45, 0x10, 0x1b, 0x12, 0x1c, 0x0a, 0x18, 0x53, 0x4f,
- 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x4f, 0x4f, 0x47, 0x4c, 0x45,
- 0x5f, 0x44, 0x52, 0x49, 0x56, 0x45, 0x10, 0x1c, 0x12, 0x1a, 0x0a, 0x16, 0x53, 0x4f, 0x55, 0x52,
- 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x48, 0x41, 0x52, 0x45, 0x50, 0x4f, 0x49,
- 0x4e, 0x54, 0x10, 0x1d, 0x12, 0x1c, 0x0a, 0x18, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54,
- 0x59, 0x50, 0x45, 0x5f, 0x47, 0x43, 0x53, 0x5f, 0x55, 0x4e, 0x41, 0x55, 0x54, 0x48, 0x45, 0x44,
- 0x10, 0x1e, 0x12, 0x1b, 0x0a, 0x17, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50,
- 0x45, 0x5f, 0x41, 0x5a, 0x55, 0x52, 0x45, 0x5f, 0x52, 0x45, 0x50, 0x4f, 0x53, 0x10, 0x1f, 0x12,
- 0x18, 0x0a, 0x14, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54,
- 0x52, 0x41, 0x56, 0x49, 0x53, 0x43, 0x49, 0x10, 0x20, 0x42, 0x3b, 0x5a, 0x39, 0x67, 0x69, 0x74,
- 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x73,
- 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x68,
- 0x6f, 0x67, 0x2f, 0x76, 0x33, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x73, 0x6f, 0x75,
- 0x72, 0x63, 0x65, 0x73, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x22, 0xd5, 0x04, 0x0a, 0x07, 0x50, 0x6f, 0x73,
+ 0x74, 0x6d, 0x61, 0x6e, 0x12, 0x48, 0x0a, 0x0f, 0x75, 0x6e, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e,
+ 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e,
+ 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x2e, 0x55, 0x6e, 0x61, 0x75,
+ 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x64, 0x48, 0x00, 0x52, 0x0f, 0x75,
+ 0x6e, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x16,
+ 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52,
+ 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70,
+ 0x61, 0x63, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x77, 0x6f, 0x72, 0x6b,
+ 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6c,
+ 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x65, 0x6e, 0x76, 0x69,
+ 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c,
+ 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x2f, 0x0a, 0x13,
+ 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x12, 0x65, 0x78, 0x63, 0x6c, 0x75,
+ 0x64, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x31, 0x0a,
+ 0x14, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e,
+ 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x13, 0x65, 0x78, 0x63,
+ 0x6c, 0x75, 0x64, 0x65, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73,
+ 0x12, 0x2f, 0x0a, 0x13, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x63, 0x6f, 0x6c, 0x6c,
+ 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52, 0x12, 0x69,
+ 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x73, 0x12, 0x31, 0x0a, 0x14, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x65, 0x6e, 0x76,
+ 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52,
+ 0x13, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d,
+ 0x65, 0x6e, 0x74, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x6f, 0x72,
+ 0x5f, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52,
+ 0x10, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x4b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64,
+ 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x70,
+ 0x61, 0x74, 0x68, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x77, 0x6f, 0x72, 0x6b,
+ 0x73, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x74, 0x68, 0x73, 0x12, 0x29, 0x0a, 0x10, 0x63, 0x6f,
+ 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x73, 0x18, 0x0c,
+ 0x20, 0x03, 0x28, 0x09, 0x52, 0x0f, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x50, 0x61, 0x74, 0x68, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e,
+ 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x09,
+ 0x52, 0x10, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x61, 0x74,
+ 0x68, 0x73, 0x42, 0x0c, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c,
+ 0x2a, 0xb7, 0x07, 0x0a, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12,
+ 0x1d, 0x0a, 0x19, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x41,
+ 0x5a, 0x55, 0x52, 0x45, 0x5f, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, 0x10, 0x00, 0x12, 0x19,
+ 0x0a, 0x15, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, 0x49,
+ 0x54, 0x42, 0x55, 0x43, 0x4b, 0x45, 0x54, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x53, 0x4f, 0x55,
+ 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x43, 0x49, 0x52, 0x43, 0x4c, 0x45, 0x43,
+ 0x49, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59,
+ 0x50, 0x45, 0x5f, 0x43, 0x4f, 0x4e, 0x46, 0x4c, 0x55, 0x45, 0x4e, 0x43, 0x45, 0x10, 0x03, 0x12,
+ 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x44,
+ 0x4f, 0x43, 0x4b, 0x45, 0x52, 0x10, 0x04, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x4f, 0x55, 0x52, 0x43,
+ 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x45, 0x43, 0x52, 0x10, 0x05, 0x12, 0x13, 0x0a, 0x0f,
+ 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x43, 0x53, 0x10,
+ 0x06, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45,
+ 0x5f, 0x47, 0x49, 0x54, 0x48, 0x55, 0x42, 0x10, 0x07, 0x12, 0x1a, 0x0a, 0x16, 0x53, 0x4f, 0x55,
+ 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x5f,
+ 0x47, 0x49, 0x54, 0x10, 0x08, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f,
+ 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x49, 0x54, 0x4c, 0x41, 0x42, 0x10, 0x09, 0x12, 0x14, 0x0a,
+ 0x10, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4a, 0x49, 0x52,
+ 0x41, 0x10, 0x0a, 0x12, 0x24, 0x0a, 0x20, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59,
+ 0x50, 0x45, 0x5f, 0x4e, 0x50, 0x4d, 0x5f, 0x55, 0x4e, 0x41, 0x55, 0x54, 0x48, 0x44, 0x5f, 0x50,
+ 0x41, 0x43, 0x4b, 0x41, 0x47, 0x45, 0x53, 0x10, 0x0b, 0x12, 0x25, 0x0a, 0x21, 0x53, 0x4f, 0x55,
+ 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x50, 0x59, 0x50, 0x49, 0x5f, 0x55, 0x4e,
+ 0x41, 0x55, 0x54, 0x48, 0x44, 0x5f, 0x50, 0x41, 0x43, 0x4b, 0x41, 0x47, 0x45, 0x53, 0x10, 0x0c,
+ 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f,
+ 0x53, 0x33, 0x10, 0x0d, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54,
+ 0x59, 0x50, 0x45, 0x5f, 0x53, 0x4c, 0x41, 0x43, 0x4b, 0x10, 0x0e, 0x12, 0x1a, 0x0a, 0x16, 0x53,
+ 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x46, 0x49, 0x4c, 0x45, 0x53,
+ 0x59, 0x53, 0x54, 0x45, 0x4d, 0x10, 0x0f, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x4f, 0x55, 0x52, 0x43,
+ 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x49, 0x54, 0x10, 0x10, 0x12, 0x14, 0x0a, 0x10,
+ 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, 0x45, 0x53, 0x54,
+ 0x10, 0x11, 0x12, 0x1b, 0x0a, 0x17, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50,
+ 0x45, 0x5f, 0x53, 0x33, 0x5f, 0x55, 0x4e, 0x41, 0x55, 0x54, 0x48, 0x45, 0x44, 0x10, 0x12, 0x12,
+ 0x2a, 0x0a, 0x26, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47,
+ 0x49, 0x54, 0x48, 0x55, 0x42, 0x5f, 0x55, 0x4e, 0x41, 0x55, 0x54, 0x48, 0x45, 0x4e, 0x54, 0x49,
+ 0x43, 0x41, 0x54, 0x45, 0x44, 0x5f, 0x4f, 0x52, 0x47, 0x10, 0x13, 0x12, 0x19, 0x0a, 0x15, 0x53,
+ 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, 0x55, 0x49, 0x4c, 0x44,
+ 0x4b, 0x49, 0x54, 0x45, 0x10, 0x14, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45,
+ 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x45, 0x52, 0x52, 0x49, 0x54, 0x10, 0x15, 0x12, 0x17,
+ 0x0a, 0x13, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4a, 0x45,
+ 0x4e, 0x4b, 0x49, 0x4e, 0x53, 0x10, 0x16, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x4f, 0x55, 0x52, 0x43,
+ 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, 0x45, 0x41, 0x4d, 0x53, 0x10, 0x17, 0x12, 0x21,
+ 0x0a, 0x1d, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4a, 0x46,
+ 0x52, 0x4f, 0x47, 0x5f, 0x41, 0x52, 0x54, 0x49, 0x46, 0x41, 0x43, 0x54, 0x4f, 0x52, 0x59, 0x10,
+ 0x18, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45,
+ 0x5f, 0x53, 0x59, 0x53, 0x4c, 0x4f, 0x47, 0x10, 0x19, 0x12, 0x27, 0x0a, 0x23, 0x53, 0x4f, 0x55,
+ 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x5f,
+ 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x4d, 0x4f, 0x4e, 0x49, 0x54, 0x4f, 0x52, 0x49, 0x4e, 0x47,
+ 0x10, 0x1a, 0x12, 0x1e, 0x0a, 0x1a, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50,
+ 0x45, 0x5f, 0x53, 0x4c, 0x41, 0x43, 0x4b, 0x5f, 0x52, 0x45, 0x41, 0x4c, 0x54, 0x49, 0x4d, 0x45,
+ 0x10, 0x1b, 0x12, 0x1c, 0x0a, 0x18, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50,
+ 0x45, 0x5f, 0x47, 0x4f, 0x4f, 0x47, 0x4c, 0x45, 0x5f, 0x44, 0x52, 0x49, 0x56, 0x45, 0x10, 0x1c,
+ 0x12, 0x1a, 0x0a, 0x16, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f,
+ 0x53, 0x48, 0x41, 0x52, 0x45, 0x50, 0x4f, 0x49, 0x4e, 0x54, 0x10, 0x1d, 0x12, 0x1c, 0x0a, 0x18,
+ 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x43, 0x53, 0x5f,
+ 0x55, 0x4e, 0x41, 0x55, 0x54, 0x48, 0x45, 0x44, 0x10, 0x1e, 0x12, 0x1b, 0x0a, 0x17, 0x53, 0x4f,
+ 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x41, 0x5a, 0x55, 0x52, 0x45, 0x5f,
+ 0x52, 0x45, 0x50, 0x4f, 0x53, 0x10, 0x1f, 0x12, 0x18, 0x0a, 0x14, 0x53, 0x4f, 0x55, 0x52, 0x43,
+ 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x54, 0x52, 0x41, 0x56, 0x49, 0x53, 0x43, 0x49, 0x10,
+ 0x20, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45,
+ 0x5f, 0x50, 0x4f, 0x53, 0x54, 0x4d, 0x41, 0x4e, 0x10, 0x21, 0x42, 0x3b, 0x5a, 0x39, 0x67, 0x69,
+ 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65,
+ 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65,
+ 0x68, 0x6f, 0x67, 0x2f, 0x76, 0x33, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x73, 0x6f,
+ 0x75, 0x72, 0x63, 0x65, 0x73, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -4101,7 +4312,7 @@ func file_sources_proto_rawDescGZIP() []byte {
}
var file_sources_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
-var file_sources_proto_msgTypes = make([]protoimpl.MessageInfo, 30)
+var file_sources_proto_msgTypes = make([]protoimpl.MessageInfo, 31)
var file_sources_proto_goTypes = []interface{}{
(SourceType)(0), // 0: sources.SourceType
(Confluence_GetAllSpacesScope)(0), // 1: sources.Confluence.GetAllSpacesScope
@@ -4135,73 +4346,75 @@ var file_sources_proto_goTypes = []interface{}{
(*SlackRealtime)(nil), // 29: sources.SlackRealtime
(*Sharepoint)(nil), // 30: sources.Sharepoint
(*AzureRepos)(nil), // 31: sources.AzureRepos
- (*durationpb.Duration)(nil), // 32: google.protobuf.Duration
- (*anypb.Any)(nil), // 33: google.protobuf.Any
- (*credentialspb.BasicAuth)(nil), // 34: credentials.BasicAuth
- (*credentialspb.Unauthenticated)(nil), // 35: credentials.Unauthenticated
- (*credentialspb.Oauth2)(nil), // 36: credentials.Oauth2
- (*credentialspb.KeySecret)(nil), // 37: credentials.KeySecret
- (*credentialspb.CloudEnvironment)(nil), // 38: credentials.CloudEnvironment
- (*credentialspb.SSHAuth)(nil), // 39: credentials.SSHAuth
- (*credentialspb.GitHubApp)(nil), // 40: credentials.GitHubApp
- (*credentialspb.AWSSessionTokenSecret)(nil), // 41: credentials.AWSSessionTokenSecret
- (*credentialspb.SlackTokens)(nil), // 42: credentials.SlackTokens
- (*credentialspb.Header)(nil), // 43: credentials.Header
- (*credentialspb.ClientCredentials)(nil), // 44: credentials.ClientCredentials
- (*timestamppb.Timestamp)(nil), // 45: google.protobuf.Timestamp
+ (*Postman)(nil), // 32: sources.Postman
+ (*durationpb.Duration)(nil), // 33: google.protobuf.Duration
+ (*anypb.Any)(nil), // 34: google.protobuf.Any
+ (*credentialspb.BasicAuth)(nil), // 35: credentials.BasicAuth
+ (*credentialspb.Unauthenticated)(nil), // 36: credentials.Unauthenticated
+ (*credentialspb.Oauth2)(nil), // 37: credentials.Oauth2
+ (*credentialspb.KeySecret)(nil), // 38: credentials.KeySecret
+ (*credentialspb.CloudEnvironment)(nil), // 39: credentials.CloudEnvironment
+ (*credentialspb.SSHAuth)(nil), // 40: credentials.SSHAuth
+ (*credentialspb.GitHubApp)(nil), // 41: credentials.GitHubApp
+ (*credentialspb.AWSSessionTokenSecret)(nil), // 42: credentials.AWSSessionTokenSecret
+ (*credentialspb.SlackTokens)(nil), // 43: credentials.SlackTokens
+ (*credentialspb.Header)(nil), // 44: credentials.Header
+ (*credentialspb.ClientCredentials)(nil), // 45: credentials.ClientCredentials
+ (*timestamppb.Timestamp)(nil), // 46: google.protobuf.Timestamp
}
var file_sources_proto_depIdxs = []int32{
- 32, // 0: sources.LocalSource.scan_interval:type_name -> google.protobuf.Duration
- 33, // 1: sources.LocalSource.connection:type_name -> google.protobuf.Any
- 34, // 2: sources.Artifactory.basic_auth:type_name -> credentials.BasicAuth
- 35, // 3: sources.Artifactory.unauthenticated:type_name -> credentials.Unauthenticated
- 34, // 4: sources.AzureStorage.basic_auth:type_name -> credentials.BasicAuth
- 35, // 5: sources.AzureStorage.unauthenticated:type_name -> credentials.Unauthenticated
- 36, // 6: sources.Bitbucket.oauth:type_name -> credentials.Oauth2
- 34, // 7: sources.Bitbucket.basic_auth:type_name -> credentials.BasicAuth
- 35, // 8: sources.Confluence.unauthenticated:type_name -> credentials.Unauthenticated
- 34, // 9: sources.Confluence.basic_auth:type_name -> credentials.BasicAuth
+ 33, // 0: sources.LocalSource.scan_interval:type_name -> google.protobuf.Duration
+ 34, // 1: sources.LocalSource.connection:type_name -> google.protobuf.Any
+ 35, // 2: sources.Artifactory.basic_auth:type_name -> credentials.BasicAuth
+ 36, // 3: sources.Artifactory.unauthenticated:type_name -> credentials.Unauthenticated
+ 35, // 4: sources.AzureStorage.basic_auth:type_name -> credentials.BasicAuth
+ 36, // 5: sources.AzureStorage.unauthenticated:type_name -> credentials.Unauthenticated
+ 37, // 6: sources.Bitbucket.oauth:type_name -> credentials.Oauth2
+ 35, // 7: sources.Bitbucket.basic_auth:type_name -> credentials.BasicAuth
+ 36, // 8: sources.Confluence.unauthenticated:type_name -> credentials.Unauthenticated
+ 35, // 9: sources.Confluence.basic_auth:type_name -> credentials.BasicAuth
1, // 10: sources.Confluence.spaces_scope:type_name -> sources.Confluence.GetAllSpacesScope
- 35, // 11: sources.Docker.unauthenticated:type_name -> credentials.Unauthenticated
- 34, // 12: sources.Docker.basic_auth:type_name -> credentials.BasicAuth
- 37, // 13: sources.ECR.access_key:type_name -> credentials.KeySecret
- 35, // 14: sources.GCS.unauthenticated:type_name -> credentials.Unauthenticated
- 38, // 15: sources.GCS.adc:type_name -> credentials.CloudEnvironment
- 36, // 16: sources.GCS.oauth:type_name -> credentials.Oauth2
- 34, // 17: sources.Git.basic_auth:type_name -> credentials.BasicAuth
- 35, // 18: sources.Git.unauthenticated:type_name -> credentials.Unauthenticated
- 39, // 19: sources.Git.ssh_auth:type_name -> credentials.SSHAuth
- 36, // 20: sources.GitLab.oauth:type_name -> credentials.Oauth2
- 34, // 21: sources.GitLab.basic_auth:type_name -> credentials.BasicAuth
- 40, // 22: sources.GitHub.github_app:type_name -> credentials.GitHubApp
- 35, // 23: sources.GitHub.unauthenticated:type_name -> credentials.Unauthenticated
- 34, // 24: sources.GitHub.basic_auth:type_name -> credentials.BasicAuth
- 34, // 25: sources.JIRA.basic_auth:type_name -> credentials.BasicAuth
- 35, // 26: sources.JIRA.unauthenticated:type_name -> credentials.Unauthenticated
- 36, // 27: sources.JIRA.oauth:type_name -> credentials.Oauth2
- 35, // 28: sources.NPMUnauthenticatedPackage.unauthenticated:type_name -> credentials.Unauthenticated
- 35, // 29: sources.PyPIUnauthenticatedPackage.unauthenticated:type_name -> credentials.Unauthenticated
- 37, // 30: sources.S3.access_key:type_name -> credentials.KeySecret
- 35, // 31: sources.S3.unauthenticated:type_name -> credentials.Unauthenticated
- 38, // 32: sources.S3.cloud_environment:type_name -> credentials.CloudEnvironment
- 41, // 33: sources.S3.session_token:type_name -> credentials.AWSSessionTokenSecret
- 42, // 34: sources.Slack.tokens:type_name -> credentials.SlackTokens
- 34, // 35: sources.Gerrit.basic_auth:type_name -> credentials.BasicAuth
- 35, // 36: sources.Gerrit.unauthenticated:type_name -> credentials.Unauthenticated
- 34, // 37: sources.Jenkins.basic_auth:type_name -> credentials.BasicAuth
- 43, // 38: sources.Jenkins.header:type_name -> credentials.Header
- 44, // 39: sources.Teams.authenticated:type_name -> credentials.ClientCredentials
- 36, // 40: sources.Teams.oauth:type_name -> credentials.Oauth2
- 35, // 41: sources.Forager.unauthenticated:type_name -> credentials.Unauthenticated
- 45, // 42: sources.Forager.since:type_name -> google.protobuf.Timestamp
- 42, // 43: sources.SlackRealtime.tokens:type_name -> credentials.SlackTokens
- 36, // 44: sources.Sharepoint.oauth:type_name -> credentials.Oauth2
- 36, // 45: sources.AzureRepos.oauth:type_name -> credentials.Oauth2
- 46, // [46:46] is the sub-list for method output_type
- 46, // [46:46] is the sub-list for method input_type
- 46, // [46:46] is the sub-list for extension type_name
- 46, // [46:46] is the sub-list for extension extendee
- 0, // [0:46] is the sub-list for field type_name
+ 36, // 11: sources.Docker.unauthenticated:type_name -> credentials.Unauthenticated
+ 35, // 12: sources.Docker.basic_auth:type_name -> credentials.BasicAuth
+ 38, // 13: sources.ECR.access_key:type_name -> credentials.KeySecret
+ 36, // 14: sources.GCS.unauthenticated:type_name -> credentials.Unauthenticated
+ 39, // 15: sources.GCS.adc:type_name -> credentials.CloudEnvironment
+ 37, // 16: sources.GCS.oauth:type_name -> credentials.Oauth2
+ 35, // 17: sources.Git.basic_auth:type_name -> credentials.BasicAuth
+ 36, // 18: sources.Git.unauthenticated:type_name -> credentials.Unauthenticated
+ 40, // 19: sources.Git.ssh_auth:type_name -> credentials.SSHAuth
+ 37, // 20: sources.GitLab.oauth:type_name -> credentials.Oauth2
+ 35, // 21: sources.GitLab.basic_auth:type_name -> credentials.BasicAuth
+ 41, // 22: sources.GitHub.github_app:type_name -> credentials.GitHubApp
+ 36, // 23: sources.GitHub.unauthenticated:type_name -> credentials.Unauthenticated
+ 35, // 24: sources.GitHub.basic_auth:type_name -> credentials.BasicAuth
+ 35, // 25: sources.JIRA.basic_auth:type_name -> credentials.BasicAuth
+ 36, // 26: sources.JIRA.unauthenticated:type_name -> credentials.Unauthenticated
+ 37, // 27: sources.JIRA.oauth:type_name -> credentials.Oauth2
+ 36, // 28: sources.NPMUnauthenticatedPackage.unauthenticated:type_name -> credentials.Unauthenticated
+ 36, // 29: sources.PyPIUnauthenticatedPackage.unauthenticated:type_name -> credentials.Unauthenticated
+ 38, // 30: sources.S3.access_key:type_name -> credentials.KeySecret
+ 36, // 31: sources.S3.unauthenticated:type_name -> credentials.Unauthenticated
+ 39, // 32: sources.S3.cloud_environment:type_name -> credentials.CloudEnvironment
+ 42, // 33: sources.S3.session_token:type_name -> credentials.AWSSessionTokenSecret
+ 43, // 34: sources.Slack.tokens:type_name -> credentials.SlackTokens
+ 35, // 35: sources.Gerrit.basic_auth:type_name -> credentials.BasicAuth
+ 36, // 36: sources.Gerrit.unauthenticated:type_name -> credentials.Unauthenticated
+ 35, // 37: sources.Jenkins.basic_auth:type_name -> credentials.BasicAuth
+ 44, // 38: sources.Jenkins.header:type_name -> credentials.Header
+ 45, // 39: sources.Teams.authenticated:type_name -> credentials.ClientCredentials
+ 37, // 40: sources.Teams.oauth:type_name -> credentials.Oauth2
+ 36, // 41: sources.Forager.unauthenticated:type_name -> credentials.Unauthenticated
+ 46, // 42: sources.Forager.since:type_name -> google.protobuf.Timestamp
+ 43, // 43: sources.SlackRealtime.tokens:type_name -> credentials.SlackTokens
+ 37, // 44: sources.Sharepoint.oauth:type_name -> credentials.Oauth2
+ 37, // 45: sources.AzureRepos.oauth:type_name -> credentials.Oauth2
+ 36, // 46: sources.Postman.unauthenticated:type_name -> credentials.Unauthenticated
+ 47, // [47:47] is the sub-list for method output_type
+ 47, // [47:47] is the sub-list for method input_type
+ 47, // [47:47] is the sub-list for extension type_name
+ 47, // [47:47] is the sub-list for extension extendee
+ 0, // [0:47] is the sub-list for field type_name
}
func init() { file_sources_proto_init() }
@@ -4570,6 +4783,18 @@ func file_sources_proto_init() {
return nil
}
}
+ file_sources_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*Postman); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
}
file_sources_proto_msgTypes[1].OneofWrappers = []interface{}{
(*Artifactory_BasicAuth)(nil),
@@ -4685,13 +4910,17 @@ func file_sources_proto_init() {
(*AzureRepos_Token)(nil),
(*AzureRepos_Oauth)(nil),
}
+ file_sources_proto_msgTypes[30].OneofWrappers = []interface{}{
+ (*Postman_Unauthenticated)(nil),
+ (*Postman_Token)(nil),
+ }
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_sources_proto_rawDesc,
NumEnums: 2,
- NumMessages: 30,
+ NumMessages: 31,
NumExtensions: 0,
NumServices: 0,
},
diff --git a/pkg/pb/sourcespb/sources.pb.validate.go b/pkg/pb/sourcespb/sources.pb.validate.go
index 7707499ac..29de5a3e3 100644
--- a/pkg/pb/sourcespb/sources.pb.validate.go
+++ b/pkg/pb/sourcespb/sources.pb.validate.go
@@ -4807,3 +4807,139 @@ var _ interface {
Cause() error
ErrorName() string
} = AzureReposValidationError{}
+
+// Validate checks the field values on Postman with the rules defined in the
+// proto definition for this message. If any rules are violated, the first
+// error encountered is returned, or nil if there are no violations.
+func (m *Postman) Validate() error {
+ return m.validate(false)
+}
+
+// ValidateAll checks the field values on Postman with the rules defined in the
+// proto definition for this message. If any rules are violated, the result is
+// a list of violation errors wrapped in PostmanMultiError, or nil if none found.
+func (m *Postman) ValidateAll() error {
+ return m.validate(true)
+}
+
+func (m *Postman) validate(all bool) error {
+ if m == nil {
+ return nil
+ }
+
+ var errors []error
+
+ switch m.Credential.(type) {
+
+ case *Postman_Unauthenticated:
+
+ if all {
+ switch v := interface{}(m.GetUnauthenticated()).(type) {
+ case interface{ ValidateAll() error }:
+ if err := v.ValidateAll(); err != nil {
+ errors = append(errors, PostmanValidationError{
+ field: "Unauthenticated",
+ reason: "embedded message failed validation",
+ cause: err,
+ })
+ }
+ case interface{ Validate() error }:
+ if err := v.Validate(); err != nil {
+ errors = append(errors, PostmanValidationError{
+ field: "Unauthenticated",
+ reason: "embedded message failed validation",
+ cause: err,
+ })
+ }
+ }
+ } else if v, ok := interface{}(m.GetUnauthenticated()).(interface{ Validate() error }); ok {
+ if err := v.Validate(); err != nil {
+ return PostmanValidationError{
+ field: "Unauthenticated",
+ reason: "embedded message failed validation",
+ cause: err,
+ }
+ }
+ }
+
+ case *Postman_Token:
+ // no validation rules for Token
+
+ }
+
+ if len(errors) > 0 {
+ return PostmanMultiError(errors)
+ }
+
+ return nil
+}
+
+// PostmanMultiError is an error wrapping multiple validation errors returned
+// by Postman.ValidateAll() if the designated constraints aren't met.
+type PostmanMultiError []error
+
+// Error returns a concatenation of all the error messages it wraps.
+func (m PostmanMultiError) Error() string {
+ var msgs []string
+ for _, err := range m {
+ msgs = append(msgs, err.Error())
+ }
+ return strings.Join(msgs, "; ")
+}
+
+// AllErrors returns a list of validation violation errors.
+func (m PostmanMultiError) AllErrors() []error { return m }
+
+// PostmanValidationError is the validation error returned by Postman.Validate
+// if the designated constraints aren't met.
+type PostmanValidationError struct {
+ field string
+ reason string
+ cause error
+ key bool
+}
+
+// Field function returns field value.
+func (e PostmanValidationError) Field() string { return e.field }
+
+// Reason function returns reason value.
+func (e PostmanValidationError) Reason() string { return e.reason }
+
+// Cause function returns cause value.
+func (e PostmanValidationError) Cause() error { return e.cause }
+
+// Key function returns key value.
+func (e PostmanValidationError) Key() bool { return e.key }
+
+// ErrorName returns error name.
+func (e PostmanValidationError) ErrorName() string { return "PostmanValidationError" }
+
+// Error satisfies the builtin error interface
+func (e PostmanValidationError) Error() string {
+ cause := ""
+ if e.cause != nil {
+ cause = fmt.Sprintf(" | caused by: %v", e.cause)
+ }
+
+ key := ""
+ if e.key {
+ key = "key for "
+ }
+
+ return fmt.Sprintf(
+ "invalid %sPostman.%s: %s%s",
+ key,
+ e.field,
+ e.reason,
+ cause)
+}
+
+var _ error = PostmanValidationError{}
+
+var _ interface {
+ Field() string
+ Reason() string
+ Key() bool
+ Cause() error
+ ErrorName() string
+} = PostmanValidationError{}
diff --git a/pkg/sources/postman/postman.go b/pkg/sources/postman/postman.go
new file mode 100644
index 000000000..cde6b3bc4
--- /dev/null
+++ b/pkg/sources/postman/postman.go
@@ -0,0 +1,673 @@
+package postman
+
+import (
+ "archive/zip"
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/url"
+ "os"
+ "path"
+ "path/filepath"
+ "slices"
+ "strings"
+
+ "github.com/trufflesecurity/trufflehog/v3/pkg/context"
+ "google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/anypb"
+
+ "github.com/go-errors/errors"
+ "github.com/trufflesecurity/trufflehog/v3/pkg/common"
+ "github.com/trufflesecurity/trufflehog/v3/pkg/pb/source_metadatapb"
+ "github.com/trufflesecurity/trufflehog/v3/pkg/pb/sourcespb"
+ "github.com/trufflesecurity/trufflehog/v3/pkg/sources"
+)
+
+const (
+ SourceType = sourcespb.SourceType_SOURCE_TYPE_POSTMAN
+ LINK_BASE_URL = "https://go.postman.co/"
+ GLOBAL_TYPE = "globals"
+ ENVIRONMENT_TYPE = "environment"
+ AUTH_TYPE = "authorization"
+ REQUEST_TYPE = "request"
+ FOLDER_TYPE = "folder"
+ COLLECTION_TYPE = "collection"
+ EVENT_TYPE = "script"
+)
+
+type Source struct {
+ name string
+ sourceId sources.SourceID
+ jobId sources.JobID
+ verify bool
+ client *Client
+ conn *sourcespb.Postman
+ DetectorKeywords map[string]struct{}
+
+ // Keywords are words that are discovered when we walk through postman data.
+ // These keywords are then injected into data that is sent to the detectors.
+ keywords map[string]struct{}
+ sub *Substitution
+
+ sources.Progress
+ sources.CommonSourceUnitUnmarshaller
+}
+
+func (s *Source) addKeywords(keywords []string) {
+ for _, keyword := range keywords {
+ s.addKeyword(keyword)
+ }
+}
+
+func (s *Source) addKeyword(keyword string) {
+ if _, ok := s.DetectorKeywords[keyword]; ok {
+ s.keywords[keyword] = struct{}{}
+ }
+}
+
+func (s *Source) resetKeywords() {
+ s.keywords = make(map[string]struct{})
+}
+
+// Type returns the type of source.
+// It is used for matching source types in configuration and job input.
+func (s *Source) Type() sourcespb.SourceType {
+ return SourceType
+}
+
+func (s *Source) SourceID() sources.SourceID {
+ return s.sourceId
+}
+
+func (s *Source) JobID() sources.JobID {
+ return s.jobId
+}
+
+// Init returns an initialized Postman source.
+func (s *Source) Init(ctx context.Context, name string, jobId sources.JobID, sourceId sources.SourceID, verify bool, connection *anypb.Any, concurrency int) error {
+ s.name = name
+ s.sourceId = sourceId
+ s.jobId = jobId
+ s.verify = verify
+ s.keywords = make(map[string]struct{})
+ s.sub = NewSubstitution()
+
+ var conn sourcespb.Postman
+ if err := anypb.UnmarshalTo(connection, &conn, proto.UnmarshalOptions{}); err != nil {
+ return errors.WrapPrefix(err, "error unmarshalling connection", 0)
+ }
+
+ s.conn = &conn
+
+ switch conn.Credential.(type) {
+ case *sourcespb.Postman_Token:
+ if conn.GetToken() == "" {
+ return errors.New("Postman token is empty")
+ }
+ s.client = NewClient(conn.GetToken())
+ s.client.HTTPClient = common.RetryableHTTPClientTimeout(3)
+ case *sourcespb.Postman_Unauthenticated:
+ s.client = nil
+ // No client needed if reading from local
+ default:
+ return errors.New("credential type not implemented for Postman")
+ }
+
+ return nil
+}
+
+// Chunks scans the Postman source and sends the data to the chunks chan.
+// It scans the local environment, collection, and workspace files, and then scans the Postman API if a token is provided.
+// The Postman source is different to our other sources in that we are not relying on the data we read from the source to contain
+// all the information we need to scan, i.e, a git chunk contains all the information needed to check if a secret is present in that chunk.
+// Postman on the other hand requires us to build context (the keywords and variables) as we scan the data.
+// Check out the postman UI to see what I mean.
+// Metadata is used to track information that informs the source of the chunk (e.g. the workspace -> collection -> request -> variable hierarchy).
+func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk, _ ...sources.ChunkingTarget) error {
+ // Scan local environments
+ for _, envPath := range s.conn.EnvironmentPaths {
+ env := VariableData{}
+ contents, err := os.ReadFile(envPath)
+ if err != nil {
+ return err
+ }
+ if err = json.Unmarshal(contents, &env); err != nil {
+ return err
+ }
+ s.scanVariableData(ctx, chunksChan, Metadata{EnvironmentName: env.ID, fromLocal: true, Link: envPath}, env)
+ }
+
+ // Scan local workspaces
+ for _, collectionPath := range s.conn.CollectionPaths {
+ collection := Collection{}
+ contents, err := os.ReadFile(collectionPath)
+ if err != nil {
+ return err
+ }
+ if err = json.Unmarshal(contents, &collection); err != nil {
+ return err
+ }
+ s.scanCollection(ctx, chunksChan, Metadata{CollectionInfo: collection.Info, fromLocal: true, Link: collectionPath}, collection)
+ }
+
+ // Scan local workspaces
+ for _, workspacePath := range s.conn.WorkspacePaths {
+ // check if zip file
+ workspace := Workspace{}
+ if strings.HasSuffix(workspacePath, ".zip") {
+ r, err := zip.OpenReader(workspacePath)
+ if err != nil {
+ return err
+ }
+ for _, file := range r.File {
+ rc, err := file.Open()
+ if err != nil {
+ return err
+ }
+ contents, err := io.ReadAll(rc)
+ rc.Close()
+ if err != nil {
+ return err
+ }
+ if strings.Contains(file.Name, "collection") {
+ // read in the collection then scan it
+ c := Collection{}
+ if err = json.Unmarshal(contents, &c); err != nil {
+ return err
+ }
+ workspace.CollectionsRaw = append(workspace.CollectionsRaw, c)
+ }
+ if strings.Contains(file.Name, "environment") {
+ e := VariableData{}
+ if err = json.Unmarshal(contents, &e); err != nil {
+ return err
+ }
+ workspace.EnvironmentsRaw = append(workspace.EnvironmentsRaw, e)
+ }
+ }
+ r.Close()
+ }
+ basename := path.Base(workspacePath)
+ workspace.ID = strings.TrimSuffix(basename, filepath.Ext(basename))
+ s.scanLocalWorkspace(ctx, chunksChan, workspace, workspacePath)
+ }
+
+ // Scan workspaces
+ for _, workspaceID := range s.conn.Workspaces {
+ w, err := s.client.GetWorkspace(workspaceID)
+ if err != nil {
+ return fmt.Errorf("error getting workspace %s: %w", workspaceID, err)
+ }
+ if err = s.scanWorkspace(ctx, chunksChan, w); err != nil {
+ return fmt.Errorf("error scanning workspace %s: %w", workspaceID, err)
+ }
+ }
+
+ // Scan collections
+ for _, collectionID := range s.conn.Collections {
+ if shouldSkip(collectionID, s.conn.IncludeCollections, s.conn.ExcludeCollections) {
+ continue
+ }
+
+ collection, err := s.client.GetCollection(collectionID)
+ if err != nil {
+ return fmt.Errorf("error getting collection %s: %w", collectionID, err)
+ }
+ s.scanCollection(ctx, chunksChan, Metadata{}, collection)
+ }
+
+ // Scan personal workspaces (from API token)
+ if s.conn.Workspaces == nil && s.conn.Collections == nil && s.conn.Environments == nil && s.conn.GetToken() != "" {
+ workspaces, err := s.client.EnumerateWorkspaces()
+ if err != nil {
+ return fmt.Errorf("error enumerating postman workspaces: %w", err)
+ }
+ for _, workspace := range workspaces {
+ if err = s.scanWorkspace(ctx, chunksChan, workspace); err != nil {
+ return fmt.Errorf("error scanning workspace %s: %w", workspace.ID, err)
+ }
+ }
+ }
+
+ return nil
+}
+
+func (s *Source) scanLocalWorkspace(ctx context.Context, chunksChan chan *sources.Chunk, workspace Workspace, filePath string) {
+ // reset keywords for each workspace
+ s.resetKeywords()
+
+ metadata := Metadata{
+ WorkspaceUUID: workspace.ID,
+ fromLocal: true,
+ }
+
+ for _, environment := range workspace.EnvironmentsRaw {
+ metadata.Link = strings.TrimSuffix(path.Base(filePath), path.Ext(filePath)) + "/environments/" + environment.ID + ".json"
+ s.scanVariableData(ctx, chunksChan, metadata, environment)
+ }
+ for _, collection := range workspace.CollectionsRaw {
+ metadata.Link = strings.TrimSuffix(path.Base(filePath), path.Ext(filePath)) + "/collections/" + collection.Info.PostmanID + ".json"
+ s.scanCollection(ctx, chunksChan, metadata, collection)
+ }
+}
+
+func (s *Source) scanWorkspace(ctx context.Context, chunksChan chan *sources.Chunk, workspace Workspace) error {
+ // reset keywords for each workspace
+ s.resetKeywords()
+ s.addKeyword(workspace.Name)
+
+ // initiate metadata to track the tree structure of postman data
+ metadata := Metadata{
+ WorkspaceUUID: workspace.ID,
+ WorkspaceName: workspace.Name,
+ CreatedBy: workspace.CreatedBy,
+ Type: "workspace",
+ }
+
+ // scan global variables
+ ctx.Logger().V(2).Info("starting scanning global variables")
+ globalVars, err := s.client.GetGlobalVariables(workspace.ID)
+ if err != nil {
+ return fmt.Errorf("error getting global variables for workspace %s, %w", workspace.ID, err)
+ }
+
+ metadata.Type = GLOBAL_TYPE
+ metadata.Link = LINK_BASE_URL + "workspace/" + workspace.ID + "/" + GLOBAL_TYPE
+ metadata.FullID = workspace.CreatedBy + "-" + globalVars.ID
+
+ s.scanVariableData(ctx, chunksChan, metadata, globalVars)
+ ctx.Logger().V(2).Info("finished scanning global variables")
+
+ // gather and scan environment variables
+ for _, envID := range workspace.Environments {
+ envVars, err := s.client.GetEnvironmentVariables(envID.UUID)
+ if err != nil {
+ ctx.Logger().Error(err, "could not get env variables", "environment_uuid", envID.UUID)
+ continue
+ }
+ if shouldSkip(envID.UUID, s.conn.IncludeEnvironments, s.conn.ExcludeEnvironments) {
+ continue
+ }
+ metadata.Type = ENVIRONMENT_TYPE
+ metadata.Link = LINK_BASE_URL + "environments/" + envID.UUID
+ metadata.FullID = envVars.ID
+ metadata.EnvironmentID = envID.UUID
+
+ ctx.Logger().V(2).Info("scanning environment vars", "environment_uuid", metadata.FullID)
+ for _, word := range strings.Split(envVars.Name, " ") {
+ s.addKeyword(word)
+ }
+
+ s.scanVariableData(ctx, chunksChan, metadata, envVars)
+ ctx.Logger().V(2).Info("finished scanning environment vars", "environment_uuid", metadata.FullID)
+ }
+ ctx.Logger().V(2).Info("finished scanning environments")
+
+ // scan all the collections in the workspace.
+ // at this point we have all the possible
+ // substitutions from Global and Environment variables
+ for _, collectionID := range workspace.Collections {
+ if shouldSkip(collectionID.UUID, s.conn.IncludeCollections, s.conn.ExcludeCollections) {
+ continue
+ }
+ collection, err := s.client.GetCollection(collectionID.UUID)
+ if err != nil {
+ return err
+ }
+ s.scanCollection(ctx, chunksChan, metadata, collection)
+ }
+ return nil
+}
+
+// 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 scanning collection", collection.Info.Name, "uuid", collection.Info.UID)
+ metadata.CollectionInfo = collection.Info
+ metadata.Type = COLLECTION_TYPE
+
+ if !metadata.fromLocal {
+ metadata.FullID = metadata.CollectionInfo.UID
+ metadata.Link = LINK_BASE_URL + COLLECTION_TYPE + "/" + metadata.FullID
+ }
+
+ // variables must be scanned first before drilling down into the folders and events
+ // because we need to pick up the substitutions from the top level collection variables
+ s.scanVariableData(ctx, chunksChan, metadata, VariableData{
+ KeyValues: collection.Variables,
+ })
+
+ for _, event := range collection.Events {
+ s.scanEvent(ctx, chunksChan, metadata, event)
+ }
+
+ for _, item := range collection.Items {
+ s.scanItem(ctx, chunksChan, collection, metadata, item)
+ }
+
+}
+
+func (s *Source) scanItem(ctx context.Context, chunksChan chan *sources.Chunk, collection Collection, metadata Metadata, item Item) {
+ s.addKeyword(item.Name)
+
+ // override the base collection metadata with item-specific metadata
+ metadata.FolderID = item.ID
+ metadata.Type = FOLDER_TYPE
+ if metadata.FolderName != "" {
+ // keep track of the folder hierarchy
+ metadata.FolderName = metadata.FolderName + " > " + item.Name
+ } else {
+ metadata.FolderName = item.Name
+ }
+
+ if item.UID != "" {
+ metadata.FullID = item.UID
+ metadata.Link = LINK_BASE_URL + FOLDER_TYPE + "/" + metadata.FullID
+ }
+ // recurse through the folders
+ for _, subItem := range item.Items {
+ s.scanItem(ctx, chunksChan, collection, metadata, subItem)
+ }
+
+ // check if there are any requests in the folder
+ if item.Request.Method != "" {
+ metadata.RequestID = item.ID
+ metadata.RequestName = item.Name
+ metadata.Type = REQUEST_TYPE
+ if item.UID != "" {
+ // Route to API endpoint
+ metadata.FullID = item.UID
+ metadata.Link = LINK_BASE_URL + REQUEST_TYPE + "/" + item.UID
+ } else {
+ // Route to collection.json
+ metadata.FullID = item.ID
+ }
+ s.scanHTTPRequest(ctx, chunksChan, metadata, item.Request)
+ }
+
+ // check if there are any responses in the folder
+ for _, response := range item.Response {
+ s.scanHTTPResponse(ctx, chunksChan, metadata, response)
+ }
+
+ for _, event := range item.Events {
+ s.scanEvent(ctx, chunksChan, metadata, event)
+ }
+
+ // an auth all by its lonesome could be inherited to subfolders and requests
+ s.scanAuth(ctx, chunksChan, metadata, item.Auth, item.Request.URL)
+}
+
+func (s *Source) scanEvent(ctx context.Context, chunksChan chan *sources.Chunk, metadata Metadata, event Event) {
+ metadata.Type = metadata.Type + " > event"
+ data := strings.Join(event.Script.Exec, " ")
+
+ // Prep direct links. Ignore updating link if it's a local JSON file
+ if !metadata.fromLocal {
+ metadata.Link = LINK_BASE_URL + metadata.Type + "/" + metadata.FullID
+ if event.Listen == "prerequest" {
+ metadata.Link += "?tab=pre-request-scripts"
+ } else {
+ metadata.Link += "?tab=tests"
+ }
+ }
+
+ s.scanData(ctx, chunksChan, s.formatAndInjectKeywords(s.buildSubstitueSet(metadata, data)), metadata)
+}
+
+func (s *Source) scanAuth(ctx context.Context, chunksChan chan *sources.Chunk, m Metadata, auth Auth, u URL) {
+ var authData string
+ switch auth.Type {
+ case "apikey":
+ var apiKeyValue, apiKeyName string
+ for _, kv := range auth.Apikey {
+ switch kv.Key {
+ case "key":
+ apiKeyValue = fmt.Sprintf("%v", kv.Value)
+ case "value":
+ apiKeyName = fmt.Sprintf("%v", kv.Value)
+ }
+ }
+ authData += fmt.Sprintf("%s=%s\n", apiKeyName, apiKeyValue)
+ case "awsSigV4", "awsv4":
+ for _, kv := range auth.AWSv4 {
+ switch kv.Key {
+ case "accessKey":
+ authData += fmt.Sprintf("accessKey:%s ", kv.Value)
+ case "secretKey":
+ authData += fmt.Sprintf("secretKey:%s ", kv.Value)
+ case "region":
+ authData += fmt.Sprintf("region:%s ", kv.Value)
+ case "service":
+ authData += fmt.Sprintf("service:%s ", kv.Value)
+ }
+ }
+ case "bearer":
+ var bearerKey, bearerValue string
+ for _, kv := range auth.Bearer {
+ bearerValue = fmt.Sprintf("%v", kv.Value)
+ bearerKey = fmt.Sprintf("%v", kv.Key)
+ }
+ authData += fmt.Sprintf("%s:%s\n", bearerKey, bearerValue)
+ case "basic":
+ username := ""
+ password := ""
+
+ for _, kv := range auth.Basic {
+ switch kv.Key {
+ case "username":
+ username = fmt.Sprintf("%v", kv.Value)
+ case "password":
+ password = fmt.Sprintf("%v", kv.Value)
+ }
+ }
+ if u.Raw != "" {
+ parsedURL, err := url.Parse(u.Raw)
+ if err != nil {
+ ctx.Logger().V(2).Info("error parsing URL in basic auth check", "url", u.Raw)
+ return
+ }
+
+ parsedURL.User = url.User(username + ":" + password)
+ decodedURL, err := url.PathUnescape(parsedURL.String())
+ if err != nil {
+ ctx.Logger().V(2).Info("error parsing URL in basic auth check", "url", u.Raw)
+ return
+ }
+ authData += decodedURL
+ }
+ case "oauth2":
+ for _, oauth := range auth.OAuth2 {
+ switch oauth.Key {
+ case "accessToken", "refreshToken", "clientId", "clientSecret", "accessTokenUrl", "authUrl":
+ authData += fmt.Sprintf("%s:%v ", oauth.Key, oauth.Value)
+ }
+ }
+ case "noauth":
+ return
+ default:
+ return
+ }
+
+ if !m.fromLocal {
+ m.Link += "?tab=auth"
+ m.Type += " > authorization"
+ }
+
+ m.FieldType = AUTH_TYPE
+ s.scanData(ctx, chunksChan, s.formatAndInjectKeywords(s.buildSubstitueSet(m, authData)), m)
+}
+
+func (s *Source) scanHTTPRequest(ctx context.Context, chunksChan chan *sources.Chunk, metadata Metadata, r Request) {
+ s.addKeywords(r.URL.Host)
+ originalType := metadata.Type
+
+ // Add in var procesisng for headers
+ if r.Header != nil {
+ vars := VariableData{
+ KeyValues: r.Header,
+ }
+ metadata.Type = originalType + " > header"
+ s.scanVariableData(ctx, chunksChan, metadata, vars)
+ }
+
+ if r.URL.Raw != "" {
+ metadata.Type = originalType + " > request URL (no query parameters)"
+ // Note: query parameters are handled separately
+ u := fmt.Sprintf("%s://%s/%s", r.URL.Protocol, strings.Join(r.URL.Host, "."), strings.Join(r.URL.Path, "/"))
+ s.scanData(ctx, chunksChan, s.formatAndInjectKeywords(s.buildSubstitueSet(metadata, u)), metadata)
+ }
+
+ if len(r.URL.Query) > 0 {
+ vars := VariableData{
+ KeyValues: r.URL.Query,
+ }
+ metadata.Type = originalType + " > GET parameters (query)"
+ s.scanVariableData(ctx, chunksChan, metadata, vars)
+ }
+
+ if r.Auth.Type != "" {
+ metadata.Type = originalType + " > request auth"
+ s.scanAuth(ctx, chunksChan, metadata, r.Auth, r.URL)
+ }
+
+ if r.Body.Mode != "" {
+ metadata.Type = originalType + " > body"
+ s.scanBody(ctx, chunksChan, metadata, r.Body)
+ }
+}
+
+func (s *Source) scanBody(ctx context.Context, chunksChan chan *sources.Chunk, m Metadata, b Body) {
+ if !m.fromLocal {
+ m.Link = m.Link + "?tab=body"
+ }
+ originalType := m.Type
+ switch b.Mode {
+ case "formdata":
+ m.Type = originalType + " > form data"
+ vars := VariableData{
+ KeyValues: b.FormData,
+ }
+ s.scanVariableData(ctx, chunksChan, m, vars)
+ case "urlencoded":
+ m.Type = originalType + " > url encoded"
+ vars := VariableData{
+ KeyValues: b.URLEncoded,
+ }
+ s.scanVariableData(ctx, chunksChan, m, vars)
+ case "raw", "graphql":
+ data := b.Raw
+ if b.Mode == "graphql" {
+ m.Type = originalType + " > graphql"
+ data = b.GraphQL.Query + " " + b.GraphQL.Variables
+ }
+ if b.Mode == "raw" {
+ m.Type = originalType + " > raw"
+ }
+ s.scanData(ctx, chunksChan, s.formatAndInjectKeywords(s.buildSubstitueSet(m, data)), m)
+ default:
+ break
+ }
+}
+
+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
+ }
+ originalType := m.Type
+
+ if response.Header != nil {
+ vars := VariableData{
+ KeyValues: response.Header,
+ }
+ m.Type = originalType + " > response header"
+ s.scanVariableData(ctx, chunksChan, m, vars)
+ }
+
+ // Body in a response is just a string
+ if response.Body != "" {
+ m.Type = originalType + " > response body"
+ s.scanData(ctx, chunksChan, s.formatAndInjectKeywords(s.buildSubstitueSet(m, response.Body)), m)
+ }
+
+ if response.OriginalRequest.Method != "" {
+ m.Type = originalType + " > original request"
+ s.scanHTTPRequest(ctx, chunksChan, m, response.OriginalRequest)
+ }
+}
+
+func (s *Source) scanVariableData(ctx context.Context, chunksChan chan *sources.Chunk, m Metadata, variableData VariableData) {
+ if len(variableData.KeyValues) == 0 {
+ ctx.Logger().V(2).Info("no variables to scan", "type", m.Type, "uuid", m.FullID)
+ return
+ }
+
+ if !m.fromLocal && m.Type == COLLECTION_TYPE {
+ m.Link += "?tab=variables"
+ }
+
+ values := []string{}
+ for _, kv := range variableData.KeyValues {
+ s.addKeyword(kv.Key)
+ valStr := fmt.Sprintf("%v", kv.Value)
+ if valStr != "" {
+ s.sub.add(m, kv.Key, valStr)
+ } else if kv.SessionValue != "" {
+ valStr = fmt.Sprintf("%v", kv.SessionValue)
+ }
+ if valStr == "" {
+ continue
+ }
+ values = append(values, s.buildSubstitueSet(m, valStr)...)
+ }
+
+ m.FieldType = m.Type + " variables"
+ s.scanData(ctx, chunksChan, s.formatAndInjectKeywords(values), m)
+}
+
+func (s *Source) scanData(ctx context.Context, chunksChan chan *sources.Chunk, data string, metadata Metadata) {
+ if data == "" {
+ return
+ }
+ metadata.FieldType = metadata.Type
+
+ chunksChan <- &sources.Chunk{
+ SourceType: s.Type(),
+ SourceName: s.name,
+ SourceID: s.SourceID(),
+ JobID: s.JobID(),
+ Data: []byte(data),
+ SourceMetadata: &source_metadatapb.MetaData{
+ Data: &source_metadatapb.MetaData_Postman{
+ Postman: &source_metadatapb.Postman{
+ Link: metadata.Link,
+ WorkspaceUuid: metadata.WorkspaceUUID,
+ WorkspaceName: metadata.WorkspaceName,
+ CollectionId: metadata.CollectionInfo.UID,
+ CollectionName: metadata.CollectionInfo.Name,
+ EnvironmentId: metadata.EnvironmentID,
+ EnvironmentName: metadata.EnvironmentName,
+ RequestId: metadata.RequestID,
+ RequestName: metadata.RequestName,
+ FolderId: metadata.FolderID,
+ FolderName: metadata.FolderName,
+ FieldType: metadata.FieldType,
+ FieldName: metadata.FieldName,
+ VariableType: metadata.VarType,
+ },
+ },
+ },
+ Verify: s.verify,
+ }
+}
+
+func shouldSkip(uuid string, include []string, exclude []string) bool {
+ if slices.Contains(exclude, uuid) {
+ return true
+ }
+ if len(include) > 0 && !slices.Contains(include, uuid) {
+ return true
+ }
+ return false
+}
diff --git a/pkg/sources/postman/postman_client.go b/pkg/sources/postman/postman_client.go
new file mode 100644
index 000000000..842ea35db
--- /dev/null
+++ b/pkg/sources/postman/postman_client.go
@@ -0,0 +1,400 @@
+package postman
+
+import (
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+ "time"
+)
+
+const (
+ GLOBAL_VARS_URL = "https://www.postman.com/_api/workspace/%s/globals"
+ //Note: This is an undocumented API endpoint. The office API endpoint keeps returning 502.
+ //We'll shift this once that behavior is resolved and stable.
+ //Official API Endpoint: "https://api.getpostman.com/workspaces/%s/global-variables"
+ //GLOBAL_VARS_URL = "https://api.getpostman.com/workspaces/%s/global-variables"
+ WORKSPACE_URL = "https://api.getpostman.com/workspaces/%s"
+ ENVIRONMENTS_URL = "https://api.getpostman.com/environments/%s"
+ COLLECTIONS_URL = "https://api.getpostman.com/collections/%s"
+
+ userAgent = "PostmanRuntime/7.26.8"
+ alt_userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
+ //Since we're using the undocumented API endpoint for global vars, we need a different user agent.
+ //We'll shift this once that behavior is resolved and stable.
+ defaultContentType = "*"
+)
+
+type Workspace struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+ Type string `json:"type"`
+ Description string `json:"description"`
+ Visibility string `json:"visibility"`
+ CreatedBy string `json:"createdBy"`
+ UpdatedBy string `json:"updatedBy"`
+ CreatedAt string `json:"createdAt"`
+ UpdatedAt string `json:"updatedAt"`
+ Collections []IDNameUUID `json:"collections"`
+ Environments []IDNameUUID `json:"environments"`
+ CollectionsRaw []Collection
+ EnvironmentsRaw []VariableData
+}
+
+type IDNameUUID struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+ UUID string `json:"uid"`
+}
+
+type KeyValue struct {
+ Key string `json:"key"`
+ Value interface{} `json:"value"`
+ Enabled bool `json:"enabled,omitempty"`
+ Type string `json:"type,omitempty"`
+ SessionValue string `json:"sessionValue,omitempty"`
+ Id string `json:"id,omitempty"`
+}
+
+type VariableData struct {
+ ID string `json:"id"` // For globals and envs, this is just the UUID, not the full ID.
+ Name string `json:"name"`
+ KeyValues []KeyValue `json:"values"`
+ Owner string `json:"owner"`
+ IsPublic bool `json:"isPublic"`
+ CreatedAt string `json:"createdAt"`
+ UpdatedAt string `json:"updatedAt"`
+}
+
+type Environment struct {
+ VariableData `json:"environment"`
+}
+
+type GlobalVars struct {
+ VariableData `json:"data"`
+}
+
+type Metadata struct {
+ WorkspaceUUID string
+ WorkspaceName string
+ CreatedBy string
+ EnvironmentID string
+ CollectionInfo Info
+ FolderID string // UUID of the folder (but not full ID)
+ FolderName string
+ RequestID string // UUID of the request (but not full ID)
+ RequestName string
+ FullID string //full ID of the reference item (created_by + ID) OR just the UUID
+ Link string //direct link to the folder (could be .json file path)
+ Type string //folder, request, etc.
+ EnvironmentName string
+ GlobalID string // might just be FullID, not sure
+ VarType string
+ FieldName string
+ FieldType string
+ fromLocal bool
+}
+
+type Collection struct {
+ Info Info `json:"info"`
+ Items []Item `json:"item,omitempty"`
+ Auth Auth `json:"auth,omitempty"`
+ Events []Event `json:"event,omitempty"`
+ Variables []KeyValue `json:"variable,omitempty"`
+}
+
+type Info struct {
+ PostmanID string `json:"_postman_id"` // This is a UUID. Needs createdBy ID prefix to be used with API.
+ Name string `json:"name"`
+ 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
+}
+
+type Item struct {
+ Name string `json:"name"`
+ Items []Item `json:"item,omitempty"`
+ ID string `json:"id,omitempty"`
+ Auth Auth `json:"auth,omitempty"`
+ Events []Event `json:"event,omitempty"`
+ Variable []KeyValue `json:"variable,omitempty"`
+ 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
+}
+
+type Auth struct {
+ Type string `json:"type"`
+ Apikey []KeyValue `json:"apikey,omitempty"`
+ Bearer []KeyValue `json:"bearer,omitempty"`
+ AWSv4 []KeyValue `json:"awsv4,omitempty"`
+ Basic []KeyValue `json:"basic,omitempty"`
+ OAuth2 []KeyValue `json:"oauth2,omitempty"`
+}
+
+type Event struct {
+ Listen string `json:"listen"`
+ Script Script `json:"script"`
+}
+
+type Script struct {
+ Type string `json:"type"`
+ Exec []string `json:"exec"`
+ Id string `json:"id"`
+}
+
+type Request struct {
+ Auth Auth `json:"auth,omitempty"`
+ Method string `json:"method"`
+ Header []KeyValue `json:"header,omitempty"`
+ Body Body `json:"body,omitempty"` //Need to update with additional options
+ URL URL `json:"url"`
+ Description string `json:"description,omitempty"`
+}
+
+type Body struct {
+ Mode string `json:"mode"`
+ Raw string `json:"raw,omitempty"`
+ File BodyFile `json:"file,omitempty"`
+ URLEncoded []KeyValue `json:"urlencoded,omitempty"` //FINISH
+ FormData []KeyValue `json:"formdata,omitempty"` //FINISH
+ GraphQL BodyGraphQL `json:"graphql,omitempty"`
+}
+
+type BodyGraphQL struct {
+ Query string `json:"query"`
+ Variables string `json:"variables"`
+}
+
+type BodyFile struct {
+ Src string `json:"src"`
+}
+
+type URL struct {
+ Raw string `json:"raw"`
+ Protocol string `json:"protocol"`
+ Host []string `json:"host"`
+ Path []string `json:"path"`
+ Query []KeyValue `json:"query,omitempty"`
+}
+
+type Response struct {
+ ID string `json:"id"`
+ Name string `json:"name,omitempty"`
+ OriginalRequest Request `json:"originalRequest,omitempty"`
+ Header []KeyValue `json:"header,omitempty"`
+ Body string `json:"body,omitempty"`
+ UID string `json:"uid,omitempty"`
+}
+
+// A Client manages communication with the Postman API.
+type Client struct {
+ // HTTP client used to communicate with the API
+ HTTPClient *http.Client
+
+ // Headers to attach to every requests made with the client.
+ Headers map[string]string
+}
+
+// NewClient returns a new Postman API client.
+func NewClient(postmanToken string) *Client {
+ bh := map[string]string{
+ "Content-Type": defaultContentType,
+ "User-Agent": userAgent,
+ "X-API-Key": postmanToken,
+ }
+
+ c := &Client{
+ HTTPClient: http.DefaultClient,
+ Headers: bh,
+ }
+
+ return c
+}
+
+// NewRequest creates an API request (Only GET needed for our interaction w/ Postman)
+// If specified, the map provided by headers will be used to update request headers.
+func (c *Client) NewRequest(urlStr string, headers map[string]string) (*http.Request, error) {
+ req, err := http.NewRequest("GET", urlStr, nil)
+ if err != nil {
+ return nil, err
+ }
+
+ var h = c.Headers
+ for k, v := range headers {
+ h[k] = v
+ }
+
+ for k, v := range h {
+ req.Header.Set(k, v)
+ }
+
+ return req, nil
+}
+
+// checkResponse checks the API response for errors and returns them if present.
+// A Response is considered an error if it has a status code outside the 2XX range.
+func checkResponseStatus(r *http.Response) error {
+ if c := r.StatusCode; 200 <= c && c <= 299 {
+ return nil
+ }
+ return fmt.Errorf("postman Request failed with status code: %d", r.StatusCode)
+}
+
+func (c *Client) getPostmanReq(url string, headers map[string]string) (*http.Response, error) {
+ req, err := c.NewRequest(url, headers)
+ if err != nil {
+ return nil, err
+ }
+
+ resp, err := c.HTTPClient.Do(req)
+ if err != nil {
+ return nil, err
+ }
+
+ if err := checkResponseStatus(resp); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// EnumerateWorkspaces returns the workspaces for a given user (both private, public, team and personal).
+// Consider adding additional flags to support filtering.
+func (c *Client) EnumerateWorkspaces() ([]Workspace, error) {
+ var workspaces []Workspace
+ workspacesObj := struct {
+ Workspaces []Workspace `json:"workspaces"`
+ }{}
+
+ r, err := c.getPostmanReq("https://api.getpostman.com/workspaces", nil)
+ if err != nil {
+ err = fmt.Errorf("could not get workspaces")
+ return workspaces, err
+ }
+
+ body, err := io.ReadAll(r.Body)
+ if err != nil {
+ err = fmt.Errorf("could not read response body for workspaces")
+ return workspaces, err
+ }
+ r.Body.Close()
+
+ if err := json.Unmarshal([]byte(body), &workspacesObj); err != nil {
+ err = fmt.Errorf("could not unmarshal workspaces JSON")
+ return workspaces, err
+ }
+
+ return workspacesObj.Workspaces, nil
+}
+
+// GetWorkspace returns the workspace for a given workspace
+func (c *Client) GetWorkspace(workspaceUUID string) (Workspace, error) {
+ var workspace Workspace
+ obj := struct {
+ Workspace Workspace `json:"workspace"`
+ }{}
+
+ url := fmt.Sprintf(WORKSPACE_URL, workspaceUUID)
+ r, err := c.getPostmanReq(url, nil)
+ if err != nil {
+ err = fmt.Errorf("could not get workspace: %s", workspaceUUID)
+ return workspace, err
+ }
+
+ body, err := io.ReadAll(r.Body)
+ if err != nil {
+ err = fmt.Errorf("could not read response body for workspace: %s", workspaceUUID)
+ return workspace, err
+ }
+ r.Body.Close()
+
+ if err := json.Unmarshal([]byte(body), &obj); err != nil {
+ err = fmt.Errorf("could not unmarshal workspace JSON for workspace: %s", workspaceUUID)
+ return workspace, err
+ }
+
+ return obj.Workspace, nil
+}
+
+// GetGlobalVariables returns the global variables for a given workspace
+func (c *Client) GetGlobalVariables(workspace_uuid string) (VariableData, error) {
+ obj := struct {
+ VariableData VariableData `json:"data"`
+ }{}
+
+ url := fmt.Sprintf(GLOBAL_VARS_URL, workspace_uuid)
+ r, err := c.getPostmanReq(url, map[string]string{"User-Agent": alt_userAgent})
+ if err != nil {
+ err = fmt.Errorf("could not get global variables for workspace: %s", workspace_uuid)
+ return VariableData{}, err
+ }
+
+ body, err := io.ReadAll(r.Body)
+ if err != nil {
+ err = fmt.Errorf("could not read response body for workspace: %s", workspace_uuid)
+ return VariableData{}, err
+ }
+ r.Body.Close()
+
+ if err := json.Unmarshal([]byte(body), &obj); err != nil {
+ err = fmt.Errorf("could not unmarshal global variables JSON for workspace: %s", workspace_uuid)
+ return VariableData{}, err
+ }
+ return obj.VariableData, nil
+}
+
+// GetEnvironmentVariables returns the environment variables for a given environment
+func (c *Client) GetEnvironmentVariables(environment_uuid string) (VariableData, error) {
+ obj := struct {
+ VariableData VariableData `json:"environment"`
+ }{}
+
+ url := fmt.Sprintf(ENVIRONMENTS_URL, environment_uuid)
+ r, err := c.getPostmanReq(url, nil)
+ if err != nil {
+ err = fmt.Errorf("could not get env variables for environment: %s", environment_uuid)
+ return VariableData{}, err
+ }
+
+ body, err := io.ReadAll(r.Body)
+ if err != nil {
+ err = fmt.Errorf("could not read env var response body for environment: %s", environment_uuid)
+ return VariableData{}, err
+ }
+ r.Body.Close()
+ if err := json.Unmarshal([]byte(body), &obj); err != nil {
+ err = fmt.Errorf("could not unmarshal env variables JSON for environment: %s", environment_uuid)
+ return VariableData{}, err
+ }
+
+ return obj.VariableData, nil
+}
+
+// GetCollection returns the collection for a given collection
+func (c *Client) GetCollection(collection_uuid string) (Collection, error) {
+ obj := struct {
+ Collection Collection `json:"collection"`
+ }{}
+
+ url := fmt.Sprintf(COLLECTIONS_URL, collection_uuid)
+ r, err := c.getPostmanReq(url, nil)
+ if err != nil {
+ err = fmt.Errorf("could not get collection: %s", collection_uuid)
+ return Collection{}, err
+ }
+
+ body, err := io.ReadAll(r.Body)
+ if err != nil {
+ err = fmt.Errorf("could not read response body for collection: %s", collection_uuid)
+ return Collection{}, err
+ }
+ r.Body.Close()
+ if err := json.Unmarshal([]byte(body), &obj); err != nil {
+ err = fmt.Errorf("could not unmarshal JSON for collection: %s", collection_uuid)
+ return Collection{}, err
+ }
+
+ return obj.Collection, nil
+}
diff --git a/pkg/sources/postman/postman_test.go b/pkg/sources/postman/postman_test.go
new file mode 100644
index 000000000..fbc50a515
--- /dev/null
+++ b/pkg/sources/postman/postman_test.go
@@ -0,0 +1,240 @@
+package postman
+
+import (
+ "reflect"
+ "sort"
+ "strings"
+ "testing"
+
+ "github.com/trufflesecurity/trufflehog/v3/pkg/context"
+
+ "github.com/trufflesecurity/trufflehog/v3/pkg/pb/sourcespb"
+ "github.com/trufflesecurity/trufflehog/v3/pkg/sources"
+ "google.golang.org/protobuf/types/known/anypb"
+)
+
+func createTestSource(src *sourcespb.Postman) (*Source, *anypb.Any) {
+ s := &Source{}
+ conn, err := anypb.New(src)
+ if err != nil {
+ panic(err)
+ }
+ return s, conn
+}
+
+func TestSource_Init(t *testing.T) {
+ s, conn := createTestSource(&sourcespb.Postman{
+ Credential: &sourcespb.Postman_Token{
+ Token: "super secret token",
+ },
+ })
+ s.DetectorKeywords = map[string]struct{}{
+ "keyword1": {},
+ "keyword2": {},
+ }
+
+ err := s.Init(context.Background(), "test - postman", 0, 1, false, conn, 10)
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+
+ expectedKeywords := map[string]struct{}{
+ "keyword1": {},
+ "keyword2": {},
+ }
+ if !reflect.DeepEqual(s.DetectorKeywords, expectedKeywords) {
+ t.Errorf("expected detector keywords: %v, got: %v", expectedKeywords, s.DetectorKeywords)
+ }
+}
+
+func TestSource_ScanCollection(t *testing.T) {
+ ctx := context.Background()
+ s := &Source{
+ DetectorKeywords: map[string]struct{}{
+ "keyword1": {},
+ },
+ keywords: map[string]struct{}{
+ "keyword1": {},
+ },
+ }
+
+ testCases := []struct {
+ name string
+ collection Collection
+ expectedChunks []string
+ }{
+ {
+ name: "GET request with URL",
+ collection: Collection{
+ Info: Info{
+ PostmanID: "col1",
+ Name: "Test Collection",
+ },
+ Items: []Item{
+ {
+ Name: "Request 1",
+ Request: Request{
+ URL: URL{
+ Protocol: "https",
+ Host: []string{"example.com"},
+ Path: []string{"api", "endpoint"},
+ Raw: "https://example.com/api/endpoint",
+ },
+ Method: "GET",
+ },
+ },
+ },
+ },
+ expectedChunks: []string{
+ "keyword1:https://example.com/api/endpoint\n",
+ },
+ },
+ {
+ name: "POST request with URL and auth",
+ collection: Collection{
+ Info: Info{
+ PostmanID: "col2",
+ Name: "Test Collection",
+ },
+ Items: []Item{
+ {
+ Name: "Request 2",
+ Request: Request{
+ URL: URL{
+ Protocol: "https",
+ Host: []string{"example.com"},
+ Path: []string{"api", "endpoint"},
+ Raw: "https://example.com/api/endpoint",
+ },
+ Method: "POST",
+ Auth: Auth{
+ Type: "bearer",
+ Bearer: []KeyValue{
+ {
+ Key: "token",
+ Value: "abcdef123456",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ expectedChunks: []string{
+ "keyword1:https://example.com/api/endpoint\n",
+ "keyword1:token:abcdef123456 \n",
+ },
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ chunksChan := make(chan *sources.Chunk, len(tc.expectedChunks))
+ metadata := Metadata{
+ CollectionInfo: tc.collection.Info,
+ }
+
+ go s.scanCollection(ctx, chunksChan, metadata, tc.collection)
+
+ for _, expectedData := range tc.expectedChunks {
+ chunk := <-chunksChan
+
+ // can't guarantee order of keywords in chunk data
+ // so we need to compare the data after sorting
+ got := strings.Split(strings.TrimSpace(string(chunk.Data)), "\n")
+ expected := strings.Split(strings.TrimSpace(expectedData), "\n")
+ sort.Strings(got)
+ sort.Strings(expected)
+
+ if !reflect.DeepEqual(got, expected) {
+ t.Errorf("expected chunk data from collection: \n%sgot: \n%s", expectedData, chunk.Data)
+ }
+ }
+ })
+ }
+}
+
+func TestSource_ScanVariableData(t *testing.T) {
+ ctx := context.Background()
+ s := &Source{
+ DetectorKeywords: map[string]struct{}{
+ "keyword1": {},
+ },
+ keywords: map[string]struct{}{
+ "keyword1": {},
+ },
+ sub: NewSubstitution(),
+ }
+
+ testCases := []struct {
+ name string
+ metadata Metadata
+ variableData VariableData
+ expectedChunks []string
+ }{
+ {
+ name: "Single variable",
+ metadata: Metadata{
+ CollectionInfo: Info{
+ PostmanID: "col1",
+ Name: "Test Collection",
+ },
+ },
+ variableData: VariableData{
+ KeyValues: []KeyValue{
+ {
+ Key: "var1",
+ Value: "value1",
+ },
+ },
+ },
+ expectedChunks: []string{
+ "keyword1:value1\n",
+ },
+ },
+ {
+ name: "Multiple variables",
+ metadata: Metadata{
+ CollectionInfo: Info{
+ PostmanID: "col2",
+ Name: "Test Collection",
+ },
+ },
+ variableData: VariableData{
+ KeyValues: []KeyValue{
+ {
+ Key: "var1",
+ Value: "value1",
+ },
+ {
+ Key: "var2",
+ Value: "value2",
+ },
+ },
+ },
+ expectedChunks: []string{
+ "keyword1:value1\nkeyword1:value2\n",
+ },
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ chunksChan := make(chan *sources.Chunk, len(tc.expectedChunks))
+
+ s.scanVariableData(ctx, chunksChan, tc.metadata, tc.variableData)
+
+ for _, expectedData := range tc.expectedChunks {
+ chunk := <-chunksChan
+ got := strings.Split(strings.TrimSpace(string(chunk.Data)), "\n")
+ expected := strings.Split(strings.TrimSpace(expectedData), "\n")
+ sort.Strings(got)
+ sort.Strings(expected)
+
+ if !reflect.DeepEqual(got, expected) {
+ t.Errorf("expected chunk data from collection: \n%sgot: \n%s", expectedData, chunk.Data)
+ }
+ }
+ })
+ }
+}
diff --git a/pkg/sources/postman/substitution.go b/pkg/sources/postman/substitution.go
new file mode 100644
index 000000000..30eca2b11
--- /dev/null
+++ b/pkg/sources/postman/substitution.go
@@ -0,0 +1,95 @@
+package postman
+
+import (
+ "fmt"
+ "regexp"
+ "strings"
+)
+
+var subRe = regexp.MustCompile(`\{\{[^{}]+\}\}`)
+
+type VariableInfo struct {
+ value string
+ Metadata Metadata
+}
+
+type Substitution struct {
+ variables map[string][]VariableInfo
+}
+
+func NewSubstitution() *Substitution {
+ return &Substitution{
+ variables: make(map[string][]VariableInfo),
+ }
+}
+
+func (sub *Substitution) add(metadata Metadata, key string, value string) {
+ sub.variables[key] = append(sub.variables[key], VariableInfo{
+ value: value,
+ Metadata: metadata,
+ })
+}
+
+func (s *Source) keywordCombinations(str string) string {
+ data := ""
+ for keyword := range s.keywords {
+ data += fmt.Sprintf("%s:%s\n", keyword, str)
+ }
+
+ return data
+}
+
+func (s *Source) formatAndInjectKeywords(data []string) string {
+ var ret []string
+ for _, d := range data {
+ ret = append(ret, s.keywordCombinations(d))
+ }
+ return strings.Join(ret, "")
+}
+
+func (s *Source) buildSubstitueSet(metadata Metadata, data string) []string {
+ var ret []string
+ combos := make(map[string]struct{})
+
+ s.buildSubstitution(data, metadata, &combos)
+
+ for combo := range combos {
+ ret = append(ret, combo)
+ }
+
+ if len(ret) == 0 {
+ return []string{data}
+ }
+ return ret
+}
+
+func (s *Source) buildSubstitution(data string, metadata Metadata, combos *map[string]struct{}) {
+ matches := removeDuplicateStr(subRe.FindAllString(data, -1))
+ for _, match := range matches {
+ for _, slice := range s.sub.variables[strings.Trim(match, "{}")] {
+ if slice.Metadata.CollectionInfo.PostmanID != "" && slice.Metadata.CollectionInfo.PostmanID != metadata.CollectionInfo.PostmanID {
+ continue
+ }
+ // to ensure we don't infinitely recurse, we will trim all `{{}}` from the values before replacement
+ d := strings.ReplaceAll(data, match, strings.Trim(slice.value, "{}"))
+ s.buildSubstitution(d, metadata, combos)
+ }
+ }
+
+ if len(matches) == 0 {
+ // add to combos
+ (*combos)[data] = struct{}{}
+ }
+}
+
+func removeDuplicateStr(strSlice []string) []string {
+ allKeys := make(map[string]bool)
+ list := []string{}
+ for _, item := range strSlice {
+ if _, value := allKeys[item]; !value {
+ allKeys[item] = true
+ list = append(list, item)
+ }
+ }
+ return list
+}
diff --git a/pkg/sources/postman/substitution_test.go b/pkg/sources/postman/substitution_test.go
new file mode 100644
index 000000000..7b24c53b8
--- /dev/null
+++ b/pkg/sources/postman/substitution_test.go
@@ -0,0 +1,154 @@
+package postman
+
+import (
+ "reflect"
+ "sort"
+ "strings"
+ "testing"
+)
+
+func TestNewSubstitution(t *testing.T) {
+ sub := NewSubstitution()
+ if sub.variables == nil {
+ t.Error("NewSubstitution should initialize variables map")
+ }
+}
+
+func TestSubstitution_Add(t *testing.T) {
+ sub := NewSubstitution()
+ metadata := Metadata{
+ CollectionInfo: Info{PostmanID: "col1"},
+ }
+ sub.add(metadata, "key1", "value1")
+ sub.add(metadata, "key1", "value2")
+ sub.add(metadata, "key2", "value3")
+
+ expected := map[string][]VariableInfo{
+ "key1": {
+ {value: "value1", Metadata: metadata},
+ {value: "value2", Metadata: metadata},
+ },
+ "key2": {
+ {value: "value3", Metadata: metadata},
+ },
+ }
+
+ if !reflect.DeepEqual(sub.variables, expected) {
+ t.Errorf("Expected variables: %+v, got: %+v", expected, sub.variables)
+ }
+}
+
+func TestSource_KeywordCombinations(t *testing.T) {
+ s := &Source{
+ DetectorKeywords: map[string]struct{}{
+ "keyword1": {},
+ "keyword2": {},
+ },
+ keywords: make(map[string]struct{}),
+ }
+ s.addKeyword("keyword1")
+ s.addKeyword("keyword2")
+ s.addKeyword("keyword3")
+
+ // remove that \n from the end of the string
+ got := strings.Split(strings.TrimSuffix(s.keywordCombinations("test"), "\n"), "\n")
+ expected := []string{"keyword1:test", "keyword2:test"}
+
+ sort.Strings(got)
+ sort.Strings(expected)
+
+ if !reflect.DeepEqual(got, expected) {
+ t.Errorf("Expected keyword combinations: %q, got: %q", expected, got)
+ }
+}
+
+func TestSource_BuildSubstituteSet(t *testing.T) {
+ s := &Source{
+ sub: NewSubstitution(),
+ }
+ s.sub.add(Metadata{Type: GLOBAL_TYPE}, "var1", "value1")
+ s.sub.add(Metadata{Type: GLOBAL_TYPE}, "var2", "value2")
+
+ metadata := Metadata{
+ Type: GLOBAL_TYPE,
+ }
+
+ testCases := []struct {
+ data string
+ expected []string
+ }{
+ {"{{var1}}", []string{"value1"}},
+ {"{{var2}}", []string{"value2"}},
+ {"{{var1}}:{{var2}}", []string{"value1:value2"}},
+ {"no variables", []string{"no variables"}},
+ }
+
+ for _, tc := range testCases {
+ result := s.buildSubstitueSet(metadata, tc.data)
+ if !reflect.DeepEqual(result, tc.expected) {
+ t.Errorf("Expected substitution set: %v, got: %v", tc.expected, result)
+ }
+ }
+}
+
+func TestRemoveDuplicateStr(t *testing.T) {
+ testCases := []struct {
+ input []string
+ expected []string
+ }{
+ {[]string{"a", "b", "c", "a", "b"}, []string{"a", "b", "c"}},
+ {[]string{"a", "a", "a"}, []string{"a"}},
+ {[]string{}, []string{}},
+ }
+
+ for _, tc := range testCases {
+ result := removeDuplicateStr(tc.input)
+ if !reflect.DeepEqual(result, tc.expected) {
+ t.Errorf("Expected result: %v, got: %v", tc.expected, result)
+ }
+ }
+}
+
+func TestSource_FormatAndInjectKeywords(t *testing.T) {
+ s := &Source{
+ DetectorKeywords: map[string]struct{}{
+ "keyword1": {},
+ "keyword2": {},
+ },
+ keywords: make(map[string]struct{}),
+ }
+ s.addKeyword("keyword1")
+ s.addKeyword("keyword2")
+ s.addKeyword("keyword3")
+
+ testCases := []struct {
+ input []string
+ expected string
+ }{
+ {
+ []string{"data1", "data2"},
+ "keyword1:data1\nkeyword2:data1\nkeyword1:data2\nkeyword2:data2\n",
+ },
+ {
+ []string{"data1"},
+ "keyword1:data1\nkeyword2:data1\n",
+ },
+ {
+ []string{},
+ "",
+ },
+ }
+
+ for _, tc := range testCases {
+ result := s.formatAndInjectKeywords(tc.input)
+ got := strings.Split(result, "\n")
+ expected := strings.Split(tc.expected, "\n")
+ sort.Strings(got)
+ sort.Strings(expected)
+ // CHATGPT CHECK HERE
+
+ if !reflect.DeepEqual(got, expected) {
+ t.Errorf("Expected result: %q, got: %q", tc.expected, result)
+ }
+ }
+}
diff --git a/pkg/sources/sources.go b/pkg/sources/sources.go
index 30f035250..ffd8e0962 100644
--- a/pkg/sources/sources.go
+++ b/pkg/sources/sources.go
@@ -289,6 +289,36 @@ type SyslogConfig struct {
Concurrency int
}
+// PostmanConfig defines the optional configuration for a Postman source.
+type PostmanConfig struct {
+ // Workspace UUID(s) or file path(s) to Postman workspace (.zip)
+ Workspaces []string
+ // Collection ID(s) or file path(s) to Postman collection (.json)
+ Collections []string
+ // Environment ID(s) or file path(s) to Postman environment (.json)
+ Environments []string
+ // Token is the token to use to authenticate with the API.
+ Token string
+ // IncludeCollections is a list of Collections to include in the scan.
+ IncludeCollections []string
+ // IncludeEnvironment is a list of Environments to include in the scan.
+ IncludeEnvironments []string
+ // ExcludeCollections is a list of Collections to exclude in the scan.
+ ExcludeCollections []string
+ // ExcludeEnvironment is a list of Environments to exclude in the scan.
+ ExcludeEnvironments []string
+ // Concurrency is the number of concurrent workers to use to scan the source.
+ Concurrency int
+ // CollectionPaths is the list of paths to Postman collections.
+ CollectionPaths []string
+ // WorkspacePaths is the list of paths to Postman workspaces.
+ WorkspacePaths []string
+ // EnvironmentPaths is the list of paths to Postman environments.
+ EnvironmentPaths []string
+ // Filter is the filter to use to scan the source.
+ Filter *common.Filter
+}
+
// Progress is used to update job completion progress across sources.
type Progress struct {
mut sync.Mutex
diff --git a/proto/source_metadata.proto b/proto/source_metadata.proto
index c5be04120..11f2c78e5 100644
--- a/proto/source_metadata.proto
+++ b/proto/source_metadata.proto
@@ -280,6 +280,24 @@ message AzureRepos {
string organization = 11;
}
+message Postman {
+ string link = 1;
+ string workspace_uuid = 2;
+ string workspace_name = 3;
+ string globals_id = 4;
+ string collection_id = 5;
+ string collection_name = 6;
+ string environment_id = 7;
+ string environment_name = 8;
+ string request_id = 9;
+ string request_name = 10;
+ string folder_id = 11;
+ string folder_name = 12;
+ string field_type = 13;
+ string field_name = 14;
+ string variable_type = 15;
+}
+
message MetaData {
oneof data {
Azure azure = 1;
@@ -310,5 +328,6 @@ message MetaData {
GoogleDrive googleDrive = 26;
AzureRepos azureRepos = 27;
TravisCI travisCI = 28;
+ Postman postman = 29;
}
}
diff --git a/proto/sources.proto b/proto/sources.proto
index debed06bf..8fe9de6e1 100644
--- a/proto/sources.proto
+++ b/proto/sources.proto
@@ -45,6 +45,7 @@ enum SourceType {
SOURCE_TYPE_GCS_UNAUTHED = 30;
SOURCE_TYPE_AZURE_REPOS = 31;
SOURCE_TYPE_TRAVISCI = 32;
+ SOURCE_TYPE_POSTMAN = 33;
}
message LocalSource {
@@ -380,3 +381,22 @@ message AzureRepos {
bool skip_binaries = 12;
bool skip_archives = 13;
}
+
+message Postman {
+ oneof credential {
+ credentials.Unauthenticated unauthenticated = 1;
+ string token = 2;
+ }
+ repeated string workspaces = 3;
+ repeated string collections = 4;
+ repeated string environments = 5;
+ repeated string exclude_collections = 6;
+ repeated string exclude_environments = 7;
+ repeated string include_collections = 8;
+ repeated string include_environments = 9;
+ repeated string detector_keywords = 10;
+ repeated string workspace_paths = 11;
+ repeated string collection_paths = 12;
+ repeated string environment_paths = 13;
+}
+
\ No newline at end of file