Compare commits

..

2 Commits

2 changed files with 6 additions and 16 deletions
-4
View File
@@ -149,10 +149,6 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
results = append(results, s1)
// If we've found a verified match with this ID, we don't need to look for any more. So move on to the next ID.
if s1.Verified {
break
}
}
}
return detectors.CleanResults(results), nil
+6 -12
View File
@@ -678,11 +678,7 @@ func (s *Source) addReposByApp(ctx context.Context, apiClient *github.Client) er
func (s *Source) addAllVisibleOrgs(ctx context.Context, apiClient *github.Client) {
s.log.Debug("enumerating all visibile organizations on GHE")
// Enumeration on this endpoint does not use pages. it uses a since ID.
// The endpoint will return organizations with an ID greater than the given since ID.
// Empty org response is our cue to break the enumeration loop.
orgOpts := &github.OrganizationsListOptions{
Since: 0,
ListOptions: github.ListOptions{
PerPage: 100,
},
@@ -699,13 +695,7 @@ func (s *Source) addAllVisibleOrgs(ctx context.Context, apiClient *github.Client
log.WithError(err).Errorf("Could not list all organizations")
return
}
if len(orgs) == 0 {
break
}
lastOrgID := *orgs[len(orgs)-1].ID
s.log.Debugf("listed organization IDs %d through %d", orgOpts.Since, lastOrgID)
orgOpts.Since = lastOrgID
s.log.Debugf("listed organization page %d/%d", orgOpts.Page, resp.LastPage)
for _, org := range orgs {
var name string
if org.Name != nil {
@@ -715,9 +705,13 @@ func (s *Source) addAllVisibleOrgs(ctx context.Context, apiClient *github.Client
} else {
continue
}
s.log.Debugf("adding organization %d for repository enumeration: %s", org.ID, name)
s.log.Debug("adding organization for repository enumeration: ", name)
common.AddStringSliceItem(name, &s.orgs)
}
if resp.NextPage == 0 {
break
}
orgOpts.Page = resp.NextPage
}
}