app

package
v1.2.2-0...-067134f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(x int) int

Abs returns the absolute value of x.

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 DirSize

func DirSize(path string) (int64, error)

DirSize gets the size of a diretory.

func DownloadRawFile

func DownloadRawFile(client *http.Client, base string, searchResult RepoSearchResult) (data []byte, err error)

DownloadRawFile downloads files from the githubusercontent CDN.

func Entropy

func Entropy(str string) (entropy float32)

Entropy calculates the Shannon entropy of a string

func GetFileLines

func GetFileLines(file string) (lines []string)

GetFileLines takes a file path and returns its lines, stringified.

func GetRawGistPage

func GetRawGistPage(client *http.Client, gist string) string

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

func GrabCSRFToken(csrfURL string, client *http.Client) (token string, err error)

GrabCSRFToken grabs the CSRF token from a GitHub page

func GrabCSRFTokenBody

func GrabCSRFTokenBody(pageBody string) (token string, err error)

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(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.

func GetFlags

func GetFlags() *Flags

GetFlags is a singleton that returns the program flags.

type GitHubCredentials

type GitHubCredentials struct {
	Username string
	Password string
	OTP      string
}

GitHubCredentials stores a GitHub username and password

type Line

type Line struct {
	Text          string
	MatchIndex    int
	MatchEndIndex int
}

Line represents a text line, the context for a Match.

func GetLine

func GetLine(source string, pattern string) Line

GetLine grabs the full line of the first instance of a pattern within it

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 Dig

func Dig(result RepoSearchResult) (matches []Match)

Dig into the secrets of a repo

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

func MatchAPIKeys(source string) (matches []Match)

MatchAPIKeys takes a string and checks if it contains API keys using pattern matching and entropy checking.

func MatchCustomRegex

func MatchCustomRegex(source string) (matches []Match)

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

func MatchKeywords(source string) (matches []Match)

MatchKeywords takes a string and checks if it contains sensitive information using pattern matching.

func ScanDiff

func ScanDiff(from *object.Tree, to *object.Tree, result RepoSearchResult) (matches []Match)

ScanDiff finds secrets in the diff between two Git trees.

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.

func Search(query string, client *http.Client) (results []RepoSearchResult, err error)

Search Everything

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL