mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2024-11-10 15:14:38 +00:00
Actually save the normalized repos (#50)
This commit is contained in:
parent
7f7e2665a0
commit
b25295580a
2 changed files with 29 additions and 3 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Reference in a new issue