Add --include-members flag to scan all members of an organization (#118)

* Add --member-repos flag to scan all members of an organization

* Move flag to the githubScan sub-command

Co-authored-by: Miccah Castorina <miccah.castorina@trufflesec.com>
This commit is contained in:
Miccah 2022-04-01 20:22:37 -05:00 committed by GitHub
parent cedb3393d1
commit 78b344d7b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -53,6 +53,7 @@ func main() {
githubScanOrgs := githubScan.Flag("org", `GitHub organization to scan. You can repeat this flag. Example: "trufflesecurity"`).Strings()
githubScanToken := githubScan.Flag("token", "GitHub token.").String()
githubIncludeForks := githubScan.Flag("include-forks", "Include forks in scan.").Bool()
githubIncludeMembers := githubScan.Flag("include-members", "Include organization member repositories in scan.").Bool()
gitlabScan := cli.Command("gitlab", "Find credentials in GitLab repositories.")
// TODO: Add more GitLab options
@ -138,7 +139,7 @@ func main() {
if len(*githubScanOrgs) == 0 && len(*githubScanRepos) == 0 {
log.Fatal("You must specify at least one organization or repository.")
}
err = e.ScanGitHub(ctx, *githubScanEndpoint, *githubScanRepos, *githubScanOrgs, *githubScanToken, *githubIncludeForks, filter, *concurrency)
err = e.ScanGitHub(ctx, *githubScanEndpoint, *githubScanRepos, *githubScanOrgs, *githubScanToken, *githubIncludeForks, filter, *concurrency, *githubIncludeMembers)
if err != nil {
logrus.WithError(err).Fatal("Failed to scan git.")
}

View file

@ -12,12 +12,13 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/sources/github"
)
func (e *Engine) ScanGitHub(ctx context.Context, endpoint string, repos, orgs []string, token string, includeForks bool, filter *common.Filter, concurrency int) error {
func (e *Engine) ScanGitHub(ctx context.Context, endpoint string, repos, orgs []string, token string, includeForks bool, filter *common.Filter, concurrency int, includeMembers bool) error {
source := github.Source{}
connection := sourcespb.GitHub{
Endpoint: endpoint,
Organizations: orgs,
Repositories: repos,
ScanUsers: includeMembers,
}
if len(token) > 0 {
connection.Credential = &sourcespb.GitHub_Token{