Skip to content

Find, verify, and analyze leaked credentials

[THOG-774] - GitHub ignore repo full name (#848)

ahrav2d6aadcb46f6
diff --git a/pkg/sources/github/github.go b/pkg/sources/github/github.go
index 6a0ff0698..f502beb6b 100644
--- a/pkg/sources/github/github.go
+++ b/pkg/sources/github/github.go
@@ -621,7 +621,7 @@ func (s *Source) getReposByOrg(ctx context.Context, org string) ([]string, error
s.log.Debugf("Listed repos for org %s page %d/%d", org, opts.Page, res.LastPage)
for _, r := range someRepos {
- if s.ignoreRepo(r.GetName()) {
+ if s.ignoreRepo(r.GetFullName()) {
continue
}
@@ -680,7 +680,7 @@ func (s *Source) getReposByUser(ctx context.Context, user string) ([]string, err
s.log.Debugf("Listed repos for user %s page %d/%d", user, opts.Page, res.LastPage)
for _, r := range someRepos {
- if s.ignoreRepo(r.GetName()) {
+ if s.ignoreRepo(r.GetFullName()) {
continue
}
diff --git a/pkg/sources/github/github_test.go b/pkg/sources/github/github_test.go
index a3dc968da..ea0e541ce 100644
--- a/pkg/sources/github/github_test.go
+++ b/pkg/sources/github/github_test.go
@@ -67,11 +67,11 @@ func TestAddReposByOrg(t *testing.T) {
Reply(200).
JSON([]map[string]string{
{"clone_url": "super-secret-repo", "name": "super-secret-repo"},
- {"clone_url": "super-secret-repo2", "name": "super-secret-repo2"},
+ {"clone_url": "super-secret-repo2", "full_name": "secret/super-secret-repo2"},
})
s := initTestSource(nil)
- s.ignoreRepos = []string{"super-secret-repo2"}
+ s.ignoreRepos = []string{"secret/super-secret-repo2"}
// gock works here because github.NewClient is using the default HTTP Transport
err := s.addRepos(context.TODO(), "super-secret-org", s.getReposByOrg)
assert.Nil(t, err)
@@ -88,11 +88,11 @@ func TestAddReposByUser(t *testing.T) {
Reply(200).
JSON([]map[string]string{
{"clone_url": "super-secret-repo", "name": "super-secret-repo"},
- {"clone_url": "super-secret-repo2", "name": "super-secret-repo2"},
+ {"clone_url": "super-secret-repo2", "full_name": "secret/super-secret-repo2"},
})
s := initTestSource(nil)
- s.ignoreRepos = []string{"super-secret-repo2"}
+ s.ignoreRepos = []string{"secret/super-secret-repo2"}
err := s.addRepos(context.TODO(), "super-secret-user", s.getReposByUser)
assert.Nil(t, err)
assert.Equal(t, 1, len(s.repos))