Documentation ¶
Index ¶
- Constants
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func BinaryFileSystem(root string) *binaryFileSystem
- func CloneRepository(url *string, branch *string, depth int) (*git.Repository, string, error)
- func FileExists(path string) bool
- func GetChangeAction(change *object.Change) string
- func GetChangePath(change *object.Change) string
- func GetChanges(commit *object.Commit, repo *git.Repository) (object.Changes, error)
- func GetParentCommit(commit *object.Commit, repo *git.Repository) (*object.Commit, error)
- func GetRepositoryHistory(repository *git.Repository) ([]*object.Commit, error)
- func MustAsset(name string) []byte
- func NewRouter(s *Session) *gin.Engine
- func Pluralize(count int, singular string, plural string) string
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func TruncateString(str string, maxLength int) string
- type Finding
- type GithubOwner
- type GithubRepository
- type Logger
- func (l *Logger) Debug(format string, args ...interface{})
- func (l *Logger) Error(format string, args ...interface{})
- func (l *Logger) Fatal(format string, args ...interface{})
- func (l *Logger) Important(format string, args ...interface{})
- func (l *Logger) Info(format string, args ...interface{})
- func (l *Logger) Log(level int, format string, args ...interface{})
- func (l *Logger) SetDebug(d bool)
- func (l *Logger) SetSilent(s bool)
- func (l *Logger) Warn(format string, args ...interface{})
- type MatchFile
- type Options
- type PatternSignature
- type Session
- func (s *Session) AddFinding(finding *Finding)
- func (s *Session) AddRepository(repository *GithubRepository)
- func (s *Session) AddTarget(target *GithubOwner)
- func (s *Session) Finish()
- func (s *Session) InitGithubAccessToken()
- func (s *Session) InitGithubClient()
- func (s *Session) InitLogger()
- func (s *Session) InitRouter()
- func (s *Session) InitStats()
- func (s *Session) InitThreads()
- func (s *Session) SaveToFile(location string) error
- func (s *Session) Start()
- type Signature
- type SimpleSignature
- type Stats
Constants ¶
const ( Name = "gitrob" Version = "2.0.0-beta" Author = "Michael Henriksen" Website = "https://github.com/michenriksen/gitrob" ASCIIBanner = " _ __ __\n" + " ___ _(_) /________ / /\n" + " / _ `/ / __/ __/ _ \\/ _ \\\n" + " \\_, /_/\\__/_/ \\___/_.__/\n" + "/___/ by @michenriksen" )
const ( FATAL = 5 ERROR = 4 WARN = 3 IMPORTANT = 2 INFO = 1 DEBUG = 0 )
const ( GithubBaseUri = "https://raw.githubusercontent.com" MaximumFileSize = 102400 CspPolicy = "default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'" ReferrerPolicy = "no-referrer" )
const ( AccessTokenEnvVariable = "GITROB_ACCESS_TOKEN" StatusInitializing = "initializing" StatusGathering = "gathering" StatusAnalyzing = "analyzing" StatusFinished = "finished" )
const ( TypeSimple = "simple" TypePattern = "pattern" PartExtension = "extension" PartFilename = "filename" PartPath = "path" )
const (
EmptyTreeCommitId = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
)
Variables ¶
var LogColors = map[int]*color.Color{ FATAL: color.New(color.FgRed).Add(color.Bold), ERROR: color.New(color.FgRed), WARN: color.New(color.FgYellow), IMPORTANT: color.New(color.Bold), DEBUG: color.New(color.FgCyan).Add(color.Faint), }
var NewlineRegex = regexp.MustCompile(`\r?\n`)
var Signatures = []Signature{ SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, SimpleSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, PatternSignature{ // contains filtered or unexported fields }, }
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func BinaryFileSystem ¶
func BinaryFileSystem(root string) *binaryFileSystem
func CloneRepository ¶
func FileExists ¶
func GetChangeAction ¶
func GetChangePath ¶
func GetChanges ¶
func GetParentCommit ¶
func GetRepositoryHistory ¶
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
func TruncateString ¶
Types ¶
type Finding ¶
type Finding struct { Id string FilePath string Action string Description string Comment string RepositoryOwner string RepositoryName string CommitHash string CommitMessage string CommitAuthor string FileUrl string CommitUrl string RepositoryUrl string }
func (*Finding) Initialize ¶
func (f *Finding) Initialize()
type GithubOwner ¶
type GithubOwner struct { Login *string ID *int Type *string Name *string AvatarURL *string URL *string Company *string Blog *string Location *string Email *string Bio *string }
func GetOrganizationMembers ¶
func GetOrganizationMembers(login *string, client *github.Client) ([]*GithubOwner, error)
func GetUserOrOrganization ¶
func GetUserOrOrganization(login string, client *github.Client) (*GithubOwner, error)
type GithubRepository ¶
type GithubRepository struct { Owner *string ID *int Name *string FullName *string CloneURL *string URL *string DefaultBranch *string Description *string Homepage *string }
func GetRepositoriesFromOwner ¶
func GetRepositoriesFromOwner(login *string, client *github.Client) ([]*GithubRepository, error)
type MatchFile ¶
func NewMatchFile ¶
type Options ¶
type Options struct { CommitDepth *int GithubAccessToken *string `json:"-"` NoExpandOrgs *bool Threads *int Save *string `json:"-"` Load *string `json:"-"` BindAddress *string Port *int Silent *bool Debug *bool Logins []string }
func ParseOptions ¶
type PatternSignature ¶
type PatternSignature struct {
// contains filtered or unexported fields
}
func (PatternSignature) Comment ¶
func (s PatternSignature) Comment() string
func (PatternSignature) Description ¶
func (s PatternSignature) Description() string
func (PatternSignature) Match ¶
func (s PatternSignature) Match(file MatchFile) bool
type Session ¶
type Session struct { sync.Mutex Version string Options Options `json:"-"` Out *Logger `json:"-"` Stats *Stats GithubAccessToken string `json:"-"` GithubClient *github.Client `json:"-"` Router *gin.Engine `json:"-"` Targets []*GithubOwner Repositories []*GithubRepository Findings []*Finding }
func NewSession ¶
func (*Session) AddFinding ¶
func (*Session) AddRepository ¶
func (s *Session) AddRepository(repository *GithubRepository)
func (*Session) AddTarget ¶
func (s *Session) AddTarget(target *GithubOwner)
func (*Session) InitGithubAccessToken ¶
func (s *Session) InitGithubAccessToken()
func (*Session) InitGithubClient ¶
func (s *Session) InitGithubClient()
func (*Session) InitLogger ¶
func (s *Session) InitLogger()
func (*Session) InitRouter ¶
func (s *Session) InitRouter()
func (*Session) InitThreads ¶
func (s *Session) InitThreads()
func (*Session) SaveToFile ¶
type SimpleSignature ¶
type SimpleSignature struct {
// contains filtered or unexported fields
}
func (SimpleSignature) Comment ¶
func (s SimpleSignature) Comment() string
func (SimpleSignature) Description ¶
func (s SimpleSignature) Description() string
func (SimpleSignature) Match ¶
func (s SimpleSignature) Match(file MatchFile) bool
type Stats ¶
type Stats struct { sync.Mutex StartedAt time.Time FinishedAt time.Time Status string Progress float64 Targets int Repositories int Commits int Files int Findings int }
func (*Stats) IncrementCommits ¶
func (s *Stats) IncrementCommits()
func (*Stats) IncrementFiles ¶
func (s *Stats) IncrementFiles()
func (*Stats) IncrementFindings ¶
func (s *Stats) IncrementFindings()
func (*Stats) IncrementRepositories ¶
func (s *Stats) IncrementRepositories()
func (*Stats) IncrementTargets ¶
func (s *Stats) IncrementTargets()