Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
strings contain keyword check, add collection name to keywords (#2602)
Zachary Rice1216fa23c9bc
diff --git a/pkg/sources/postman/postman.go b/pkg/sources/postman/postman.goindex cde6b3bc4..d1b86a582 100644--- a/pkg/sources/postman/postman.go+++ b/pkg/sources/postman/postman.go@@ -60,8 +60,18 @@ func (s *Source) addKeywords(keywords []string) {}func (s *Source) addKeyword(keyword string) {+ // fast checkif _, ok := s.DetectorKeywords[keyword]; ok {s.keywords[keyword] = struct{}{}+ return+ }++ // slow check. This is to handle the case where the keyword is a substring of a detector keyword+ // e.g. "datadog-token" is a variable key in postman, but "datadog" is a detector keyword+ for k := range s.DetectorKeywords {+ if strings.Contains(keyword, k) {+ s.keywords[k] = struct{}{}+ }}}@@ -325,6 +335,7 @@ func (s *Source) scanCollection(ctx context.Context, chunksChan chan *sources.Chctx.Logger().V(2).Info("starting scanning collection", collection.Info.Name, "uuid", collection.Info.UID)metadata.CollectionInfo = collection.Infometadata.Type = COLLECTION_TYPE+ s.addKeyword(collection.Info.Name)if !metadata.fromLocal {metadata.FullID = metadata.CollectionInfo.UIDdiff --git a/pkg/sources/postman/substitution_test.go b/pkg/sources/postman/substitution_test.goindex 7b24c53b8..234e93400 100644--- a/pkg/sources/postman/substitution_test.go+++ b/pkg/sources/postman/substitution_test.go@@ -145,7 +145,6 @@ func TestSource_FormatAndInjectKeywords(t *testing.T) {expected := strings.Split(tc.expected, "\n")sort.Strings(got)sort.Strings(expected)- // CHATGPT CHECK HEREif !reflect.DeepEqual(got, expected) {t.Errorf("Expected result: %q, got: %q", tc.expected, result)