Skip to content

Commit

Permalink
bugfix: repo filter
Browse files Browse the repository at this point in the history
  • Loading branch information
rumenvasilev committed Sep 20, 2023
1 parent cc954a2 commit 1abbfd7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
14 changes: 9 additions & 5 deletions internal/core/gh_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/rumenvasilev/rvsecret/internal/util"
)

const retrievedRepo string = " Retrieved repository %s"

func ghWorker(sess *Session, tid int, wg *sync.WaitGroup, ch chan *github.Organization, log *log.Logger) {
ctx := context.Background()
for {
Expand Down Expand Up @@ -53,14 +55,16 @@ func processRequest(ctx context.Context, org *github.Organization, tid int, sess
sess.State.Stats.IncrementRepositoriesTotal()

// Only a subset of repos
if sess.GithubUserRepos != nil && isFilteredRepo(repo.Name, sess.GithubUserRepos) {
log.Debug(" Retrieved repository %s", repo.FullName)
// Add the repo to the sess to be scanned
sess.AddRepository(repo)
if sess.GithubUserRepos != nil {
if isFilteredRepo(repo.Name, sess.GithubUserRepos) {
log.Debug(retrievedRepo, repo.FullName)
// Add the repo to the sess to be scanned
sess.AddRepository(repo)
}
continue
}

log.Debug(" Retrieved repository %s", repo.FullName)
log.Debug(retrievedRepo, repo.FullName)
// If we are not doing any filtering and simply grabbing all available repos we add the repos
// to the session to be scanned
sess.AddRepository(repo)
Expand Down
11 changes: 7 additions & 4 deletions internal/core/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,19 @@ func GatherGithubRepositoriesFromOwner(sess *Session) error {
for _, repo := range allRepos {
// Increment the total number of repos found, regardless if we are cloning them
sess.State.Stats.IncrementRepositoriesTotal()
if sess.GithubUserRepos != nil && isFilteredRepo(repo.Name, sess.GithubUserRepos) {
log.Debug(retrievedRepoFromUser, repo.FullName, repo.Owner)
// Add the repo to the sess to be scanned
sess.AddRepository(repo)
if sess.GithubUserRepos != nil {
if isFilteredRepo(repo.Name, sess.GithubUserRepos) {
log.Debug(retrievedRepoFromUser, repo.FullName, repo.Owner)
// Add the repo to the sess to be scanned
sess.AddRepository(repo)
}
continue
}
log.Debug(retrievedRepoFromUser, repo.FullName, repo.Owner)

// If we are not doing any filtering and simply grabbing all available repos we add the repos
// to the session to be scanned
log.Debug("Adding repo %s", repo.Name)
sess.AddRepository(repo)
}
return nil
Expand Down

0 comments on commit 1abbfd7

Please sign in to comment.