Documentation ¶
Index ¶
- func Abs(x int) int
- func CheckErr(err error)
- func ClearFinishedRepos()
- func ClearRepoStorage()
- func ConstructSearchURL(base string, query string, options SearchOptions) string
- func DirSize(path string) (int64, error)
- func DownloadRawFile(client *http.Client, base string, searchResult RepoSearchResult) (data []byte, err error)
- func Entropy(str string) (entropy float32)
- func GetFileLines(file string) (lines []string)
- func GetRawGistPage(client *http.Client, gist string) string
- func GetRawURLForSearchResult(repo RepoSearchResult) string
- func GetRepoURLForSearchResult(repo RepoSearchResult) string
- func GrabCSRFToken(csrfURL string, client *http.Client) (token string, err error)
- func GrabCSRFTokenBody(pageBody string) (token string, err error)
- func HandleOTPCode(credentials GitHubCredentials) string
- func LoginToGitHub(credentials GitHubCredentials) (httpClient *http.Client, err error)
- func PrintContextLine(line Line)
- func PrintKeywordType(match Match)
- func PrintPatternLine(match Match)
- func PrintResultLink(result RepoSearchResult, match Match)
- func RepoIsUnpopular(client *http.Client, result RepoSearchResult) bool
- func ScanAndPrintResult(client *http.Client, repo RepoSearchResult)
- func SearchGist(query string, options SearchOptions, client *http.Client, ...) (err error)
- func SearchGitHub(query string, options SearchOptions, client *http.Client, ...) (err error)
- func WithHeader(rt http.RoundTripper) withHeader
- type Flags
- type GitHubCredentials
- type Line
- type Match
- func Dig(result RepoSearchResult) (matches []Match)
- func GetMatchesForString(source string, result RepoSearchResult) (matches []Match, score int)
- func MatchAPIKeys(source string) (matches []Match)
- func MatchCustomRegex(source string) (matches []Match)
- func MatchFileExtensions(source string, result RepoSearchResult) (matches []Match)
- func MatchKeywords(source string) (matches []Match)
- func ScanDiff(from *object.Tree, to *object.Tree, result RepoSearchResult) (matches []Match)
- type RepoSearchResult
- type ResultScan
- type SearchOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckErr ¶
func CheckErr(err error)
CheckErr checks if an error is not null, and exits if it is not null.
func ClearFinishedRepos ¶
func ClearFinishedRepos()
ClearFinishedRepos deletes the stored repos that have already been analyzed.
func ClearRepoStorage ¶
func ClearRepoStorage()
ClearRepoStorage deletes all stored repos from the disk.
func ConstructSearchURL ¶
func ConstructSearchURL(base string, query string, options SearchOptions) string
ConstructSearchURL serializes its parameters into a search URL
func DownloadRawFile ¶
func DownloadRawFile(client *http.Client, base string, searchResult RepoSearchResult) (data []byte, err error)
DownloadRawFile downloads files from the githubusercontent CDN.
func GetFileLines ¶
GetFileLines takes a file path and returns its lines, stringified.
func GetRawGistPage ¶
GetRawGistPage gets the source code for a Gist.
func GetRawURLForSearchResult ¶
func GetRawURLForSearchResult(repo RepoSearchResult) string
GetRawURLForSearchResult returns a raw data URL for a RepoSearchResult
func GetRepoURLForSearchResult ¶
func GetRepoURLForSearchResult(repo RepoSearchResult) string
GetRepoURLForSearchResult returns the URL of the repo depending on RepoSearchResult source
func GrabCSRFToken ¶
GrabCSRFToken grabs the CSRF token from a GitHub page
func GrabCSRFTokenBody ¶
GrabCSRFTokenBody grabs the CSRF token from a GitHub page
func HandleOTPCode ¶
func HandleOTPCode(credentials GitHubCredentials) string
HandleOTPCode returns a user's OTP code for authenticating with Github by searching config values, then CLI arguments, then prompting the user for input
func LoginToGitHub ¶
func LoginToGitHub(credentials GitHubCredentials) (httpClient *http.Client, err error)
LoginToGitHub logs into GitHub with the given credentials and returns an HTTTP client.
func PrintContextLine ¶
func PrintContextLine(line Line)
PrintContextLine pretty-prints the line of a Match, with the result highlighted.
func PrintKeywordType ¶
func PrintKeywordType(match Match)
func PrintPatternLine ¶
func PrintPatternLine(match Match)
PrintPatternLine pretty-prints the regex used to find the leak
func PrintResultLink ¶
func PrintResultLink(result RepoSearchResult, match Match)
PrintResultLink prints a link to the result.
func RepoIsUnpopular ¶
func RepoIsUnpopular(client *http.Client, result RepoSearchResult) bool
RepoIsUnpopular uses stars/forks/watchers to determine the popularity of a repo.
func ScanAndPrintResult ¶
func ScanAndPrintResult(client *http.Client, repo RepoSearchResult)
ScanAndPrintResult scans and prints information about a search result.
func SearchGist ¶
func SearchGist(query string, options SearchOptions, client *http.Client, results *[]RepoSearchResult, resultSet map[string]bool) (err error)
SearchGist searches Gist results for the given query
func SearchGitHub ¶
func SearchGitHub(query string, options SearchOptions, client *http.Client, results *[]RepoSearchResult, resultSet map[string]bool) (err error)
SearchGitHub searches GitHub code results for the given query
func WithHeader ¶
func WithHeader(rt http.RoundTripper) withHeader
Types ¶
type Flags ¶
type Flags struct { SubdomainFile string DigRepo bool DigCommits bool RegexFile string LanguageFile string ConfigFile string Pages int ResultsOnly bool NoAPIKeys bool NoScoring bool NoFiles bool NoKeywords bool OnlyFiltered bool Threads int Debug bool NoGists bool NoRepos bool ManyResults bool OTPCode string }
Flags stores the program options.
type GitHubCredentials ¶
GitHubCredentials stores a GitHub username and password
type Match ¶
type Match struct { Text string KeywordType string Line Line Commit string CommitFile string File string Expression string }
Match represents a keyword/API key match
func GetMatchesForString ¶
func GetMatchesForString(source string, result RepoSearchResult) (matches []Match, score int)
GetMatchesForString runs pattern matching and scoring checks on the given string and returns the matches.
func MatchAPIKeys ¶
MatchAPIKeys takes a string and checks if it contains API keys using pattern matching and entropy checking.
func MatchCustomRegex ¶
MatchCustomRegex matches a string against a slice of regexes.
func MatchFileExtensions ¶
func MatchFileExtensions(source string, result RepoSearchResult) (matches []Match)
MatchFileExtensions matches interesting file extensions.
func MatchKeywords ¶
MatchKeywords takes a string and checks if it contains sensitive information using pattern matching.
type RepoSearchResult ¶
type RepoSearchResult struct { Repo string File string Raw string Source string Query string URL string // contains filtered or unexported fields }
RepoSearchResult represents a result in GitHub/Gist code search.
type ResultScan ¶
type ResultScan struct { Matches []Match RepoSearchResult }
ResultScan is the final scan result.
type SearchOptions ¶
type SearchOptions struct { MaxPages int Language string github.SearchOptions }
SearchOptions are the options that the GitHub search will use.