Skip to content

Commit

Permalink
Merge pull request #41 from 0xCC00FFEE/master
Browse files Browse the repository at this point in the history
Fixed the indexing issue of "args" and looking up secrets in a given repo
  • Loading branch information
tillson committed Aug 3, 2021
2 parents 518e7e5 + 11e9955 commit 0932bbe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
config.yml
config.yml
git-hound
10 changes: 6 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func InitializeFlags() {
rootCmd.PersistentFlags().StringVar(&app.GetFlags().LanguageFile, "language-file", "", "Supply your own list of languages to search (java, python).")
rootCmd.PersistentFlags().StringVar(&app.GetFlags().ConfigFile, "config-file", "", "Supply the path to a config file.")
rootCmd.PersistentFlags().IntVar(&app.GetFlags().Pages, "pages", 100, "Maximum pages to search per query")
rootCmd.PersistentFlags().BoolVar(&app.GetFlags().GithubRepo, "github-repo", false, "Search in a specific Github Repo only.")
rootCmd.PersistentFlags().BoolVar(&app.GetFlags().ResultsOnly, "results-only", false, "Only print match strings.")
rootCmd.PersistentFlags().BoolVar(&app.GetFlags().NoAPIKeys, "no-api-keys", false, "Don't search for generic API keys.")
rootCmd.PersistentFlags().BoolVar(&app.GetFlags().NoScoring, "no-scoring", false, "Don't use scoring to filter out false positives.")
Expand Down Expand Up @@ -109,11 +110,12 @@ var rootCmd = &cobra.Command{
}

func getScanner(args []string) *bufio.Scanner {
if args[0] == "searchKeyword" {
return bufio.NewScanner(strings.NewReader(args[1]))
} else {
return bufio.NewScanner(os.Stdin)
if len(args) == 2 {
if args[0] == "searchKeyword" {
return bufio.NewScanner(strings.NewReader(args[1]))
}
}
return bufio.NewScanner(os.Stdin)
}

// Execute command
Expand Down
1 change: 1 addition & 0 deletions internal/app/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type Flags struct {
LanguageFile string
ConfigFile string
Pages int
GithubRepo bool
ResultsOnly bool
NoAPIKeys bool
NoScoring bool
Expand Down
8 changes: 7 additions & 1 deletion internal/app/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ func Search(query string, client *http.Client) (results []RepoSearchResult, err
func SearchGitHub(query string, options SearchOptions, client *http.Client, results *[]RepoSearchResult, resultSet map[string]bool) (err error) {
// TODO: A lot of this code is shared between GitHub and Gist searches,
// so we should rework the logic
base := "https://github.com/search"
base := ""
if GetFlags().GithubRepo {
base = "https://github.com/" + query + "/search"
} else {
base = "https://github.com/search"
}

page, pages := 0, 1
var delay = 5
orders := []string{"asc"}
Expand Down

0 comments on commit 0932bbe

Please sign in to comment.