Skip to content

Find, verify, and analyze leaked credentials

Actually save the normalized repos (#50)

Bill Richb25295580a1a
diff --git a/pkg/sources/github/github.go b/pkg/sources/github/github.go
index 1cc18b48a..51adea9df 100644
--- a/pkg/sources/github/github.go
+++ b/pkg/sources/github/github.go
@@ -560,8 +560,9 @@ func (s *Source) addOrgsByUser(ctx context.Context, apiClient *github.Client, us
func (s *Source) normalizeRepos(ctx context.Context, apiClient *github.Client) {
// TODO: Add check/fix for repos that are missing scheme
- var newRepoList []string
- for _, repo := range s.repos {
+ repoIter := make([]string, len(s.repos))
+ copy(repoIter, s.repos)
+ for _, repo := range repoIter {
if parts := strings.Split(repo, "/"); len(parts) == 1 {
origSources := len(s.repos)
s.addGistsByUser(ctx, apiClient, repo)
@@ -575,6 +576,6 @@ func (s *Source) normalizeRepos(ctx context.Context, apiClient *github.Client) {
if err != nil {
log.WithError(err).Warnf("Repo not in expected format: %s", repo)
}
- newRepoList = append(newRepoList, repoNormalized)
+ common.AddStringSliceItem(repoNormalized, &s.repos)
}
}
diff --git a/pkg/sources/github/github_test.go b/pkg/sources/github/github_test.go
index 7186a29b3..e5252ad51 100644
--- a/pkg/sources/github/github_test.go
+++ b/pkg/sources/github/github_test.go
@@ -94,6 +94,31 @@ func TestSource_Scan(t *testing.T) {
},
wantErr: false,
},
+ {
+ name: "token authenticated, single repo, no .git",
+ init: init{
+ name: "test source",
+ connection: &sourcespb.GitHub{
+ Repositories: []string{"https://github.com/dustin-decker/secretsandstuff"},
+ Credential: &sourcespb.GitHub_Token{
+ Token: githubToken,
+ },
+ },
+ },
+ wantChunk: &sources.Chunk{
+ SourceType: sourcespb.SourceType_SOURCE_TYPE_GITHUB,
+ SourceName: "test source",
+ SourceMetadata: &source_metadatapb.MetaData{
+ Data: &source_metadatapb.MetaData_Github{
+ Github: &source_metadatapb.Github{
+ Repository: "https://github.com/dustin-decker/secretsandstuff.git",
+ },
+ },
+ },
+ Verify: false,
+ },
+ wantErr: false,
+ },
{
name: "token authenticated, single org",
init: init{