Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Add -include-forks switch #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Gitrob is a tool to help find potentially sensitive files pushed to public repos
Print debugging information
-github-access-token string
GitHub access token to use for API requests
-include-forks
Include forked repositories in scan
-load string
Load session file
-no-expand-orgs
Expand Down
4 changes: 2 additions & 2 deletions core/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func GetUserOrOrganization(login string, client *github.Client) (*GithubOwner, e
}, nil
}

func GetRepositoriesFromOwner(login *string, client *github.Client) ([]*GithubRepository, error) {
func GetRepositoriesFromOwner(login *string, client *github.Client, includeForks *bool) ([]*GithubRepository, error) {
var allRepos []*GithubRepository
loginVal := *login
ctx := context.Background()
Expand All @@ -67,7 +67,7 @@ func GetRepositoriesFromOwner(login *string, client *github.Client) ([]*GithubRe
return allRepos, err
}
for _, repo := range repos {
if !*repo.Fork {
if (*includeForks && *repo.Fork) || !*repo.Fork {
r := GithubRepository{
Owner: repo.Owner.Login,
ID: repo.ID,
Expand Down
2 changes: 2 additions & 0 deletions core/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Options struct {
Port *int
Silent *bool
Debug *bool
IncludeForks *bool
Logins []string
}

Expand All @@ -30,6 +31,7 @@ func ParseOptions() (Options, error) {
Port: flag.Int("port", 9393, "Port to run web server on"),
Silent: flag.Bool("silent", false, "Suppress all output except for errors"),
Debug: flag.Bool("debug", false, "Print debugging information"),
IncludeForks: flag.Bool("include-forks", false, "Include forked repositories in scan"),
}

flag.Parse()
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func GatherRepositories(sess *core.Session) {
wg.Done()
return
}
repos, err := core.GetRepositoriesFromOwner(target.Login, sess.GithubClient)
repos, err := core.GetRepositoriesFromOwner(target.Login, sess.GithubClient, sess.Options.IncludeForks)
if err != nil {
sess.Out.Error(" Failed to retrieve repositories from %s: %s\n", *target.Login, err)
}
Expand Down