Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
Chunk orgs the same when authenticated as unauthenticated (#501)
Miccah71442320ec65
diff --git a/go.mod b/go.modindex 652e9cb11..7cf8f8810 100644--- a/go.mod+++ b/go.mod@@ -93,6 +93,8 @@ require (github.com/mitchellh/go-homedir v1.1.0 // indirectgithub.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirectgithub.com/modern-go/reflect2 v1.0.1 // indirect+ github.com/motemen/go-loghttp v0.0.0-20170804080138-974ac5ceac27 // indirect+ github.com/motemen/go-nuts v0.0.0-20210915132349-615a782f2c69 // indirectgithub.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7 // indirectgithub.com/xanzy/ssh-agent v0.3.0 // indirectgithub.com/yusufpapurcu/wmi v1.2.2 // indirectdiff --git a/go.sum b/go.sumindex 5cddbb3fc..3e0959f9a 100644--- a/go.sum+++ b/go.sum@@ -387,6 +387,10 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJgithub.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=+github.com/motemen/go-loghttp v0.0.0-20170804080138-974ac5ceac27 h1:uAI3rnOT1OSSY4PUtI/M1orb3q0ewkovwd3wr8xSno4=+github.com/motemen/go-loghttp v0.0.0-20170804080138-974ac5ceac27/go.mod h1:6eu9CfGt5kfrMVgeu9MfB9PRUnpc47I+udLswiTszI8=+github.com/motemen/go-nuts v0.0.0-20210915132349-615a782f2c69 h1:1KtusfE10/BxzK4Vks+ULP7S63TicyRu6cq86vCRWX8=+github.com/motemen/go-nuts v0.0.0-20210915132349-615a782f2c69/go.mod h1:xUDtqIPhzzkB+XSl0pW8qQKXzzR+SU6xcZToxwKi5zA=github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=@@ -412,6 +416,7 @@ github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc=github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc=github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=+github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU=github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=@@ -568,6 +573,7 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdgolang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=+golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=diff --git a/pkg/sources/github/github.go b/pkg/sources/github/github.goindex 38765f90a..5a5657693 100644--- a/pkg/sources/github/github.go+++ b/pkg/sources/github/github.go@@ -198,9 +198,10 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) errif len(s.orgs) > 0 {specificScope = truefor _, org := range s.orgs {- if !strings.HasSuffix(org, ".git") {- s.addReposByOrg(ctx, apiClient, org)- s.addReposByUser(ctx, apiClient, org)+ errOrg := s.addReposByOrg(ctx, apiClient, org)+ errUser := s.addReposByUser(ctx, apiClient, org)+ if errOrg != nil && errUser != nil {+ log.WithError(errOrg).Error("error fetching repos for org or user: ", org)}}}@@ -412,6 +413,7 @@ func (s *Source) addReposByOrg(ctx context.Context, apiClient *github.Client, orPerPage: 100,},}+ var numRepos, numForks intfor {someRepos, res, err := apiClient.Repositories.ListByOrg(ctx, org, opts)if err == nil {@@ -427,8 +429,12 @@ func (s *Source) addReposByOrg(ctx context.Context, apiClient *github.Client, orbreak}for _, r := range someRepos {- if r.GetFork() && !s.conn.IncludeForks {- continue+ numRepos+++ if r.GetFork() {+ numForks+++ if !s.conn.IncludeForks {+ continue+ }}common.AddStringSliceItem(r.GetCloneURL(), &s.repos)}@@ -437,6 +443,7 @@ func (s *Source) addReposByOrg(ctx context.Context, apiClient *github.Client, or}opts.Page = res.NextPage}+ log.WithField("org", org).Debugf("Found %d repos (%d forks)", numRepos, numForks)return nil}