core

package
v0.0.0-...-81b3271 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package core represents the core functionality of all commands

Package core generated by go-bindata.// sources: static/fonts/open-iconic.eot static/fonts/open-iconic.otf static/fonts/open-iconic.svg static/fonts/open-iconic.ttf static/fonts/open-iconic.woff static/images/gopher_full.png static/images/gopher_head.png static/images/spinner.gif static/index.html static/javascripts/application.js static/javascripts/backbone.js static/javascripts/bootstrap.js static/javascripts/clipboard.js static/javascripts/hexdump.js static/javascripts/highlight.js static/javascripts/highlight_worker.js static/javascripts/jquery-3.3.1.js static/javascripts/popper.js static/javascripts/underscore.js static/stylesheets/application.css static/stylesheets/bootstrap.css static/stylesheets/highlight.css static/stylesheets/openiconic.css

Package core represents the core functionality of all commands

Package core represents the core functionality of all commands

Index

Constants

View Source
const (
	GithubBaseUri   = "https://raw.githubusercontent.com"
	MaximumFileSize = 153600
	GitLabBaseUri   = "https://gitlab.com"
	CspPolicy       = "default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'"
	ReferrerPolicy  = "no-referrer"
)

Set various internal values used by the web interface

View Source
const (
	StatusInitializing = "initializing"
	StatusGathering    = "gathering"
	StatusAnalyzing    = "analyzing"
	StatusFinished     = "finished"
)

These are varios environment variables and tool statuses used in auth and displaying messages

Variables

View Source
var DefaultValues = map[string]interface{}{
	"bind-address":     "127.0.0.1",
	"bind-port":        9393,
	"commit-depth":     0,
	"config-file":      "$HOME/.gitrob/config.yaml",
	"debug":            false,
	"github-targets":   "",
	"github-api-token": "0123456789ABCDEFGHIJKLMNOPQRSTUVWXVZabcd",
	"gitlab-targets":   "",
	"gitlab-api-token": "0123456789ABCDEFGHIJ",
	"ignore-extension": "",
	"ignore-path":      "",
	"in-mem-clone":     false,
	"max-file-size":    50,
	"repo-dirs":        "",
	"scan-forks":       true,
	"scan-tests":       false,
	"scan-type":        "",
	"silent":           false,
	"mode":             1,
}
View Source
var IsGithub bool

Is this a github repo/org

Functions

func AnalyzeRepositories

func AnalyzeRepositories(sess *Session)

AnalyzeRepositories will take a given repository, clone it, pull the commit history and use that as a basis for scanning for secrets within the repo and based on that output create a finding associated with that repo

func Asset

func Asset(name string) ([]byte, error)

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

func AssetDir(name string) ([]string, error)

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

func AssetInfo(name string) (os.FileInfo, error)

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 AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func BinaryFileSystem

func BinaryFileSystem(root string) *binaryFileSystem

BinaryFileSystem returns a binary file system object used by the web frontend

func GatherLocalRepositories

func GatherLocalRepositories(sess *Session)

GatherLocalRepositories will grab all the local repos from the user input and generate a repository object, putting dummy or generated values in where necessary

func GatherRepositories

func GatherRepositories(sess *Session)

Gather Repositories will gather all repositories associated with a given target during a scan session. This is done using threads, whose count is set via commandline flag. Care much be taken to avoid rate limiting associated with suspected DOS attacks.

func GatherTargets

func GatherTargets(sess *Session)

GatherTargets will enumerate github orgs and members and add them to the running target list of a session

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func NewRouter

func NewRouter(s *Session) *gin.Engine

NewRouter will create an instance of the web frontend, setting the necessary parameters.

func PrintSessionStats

func PrintSessionStats(sess *Session)

PrintSessionStats will print the performance and sessions stats to stdout at the conclusion of a session scan

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

func SetConfig

func SetConfig() *viper.Viper

setConfig will set the defaults, and load a config file and environment variables if they are present

Types

type Session

type Session struct {
	sync.Mutex

	BindAddress       string
	BindPort          int
	Client            common.IClient `json:"-"`
	CommitDepth       int
	Debug             bool
	Findings          []*matching.Finding
	GithubAccessToken string
	GithubTargets     []string
	GitlabAccessToken string
	GitlabTargets     []string
	InMemClone        bool
	Mode              int // TODO make this go away when MJ sig functionality is applied
	MaxFileSize       int64
	NoExpandOrgs      bool
	Out               *common.Logger `json:"-"`
	RepoDirs          []string
	Repositories      []*common.Repository
	Router            *gin.Engine `json:"-"`
	ScanFork          bool
	ScanTests         bool
	ScanType          string
	Signatures        matching.Signatures `json:"-"`
	Silent            bool
	SkippableExt      []string
	SkippablePath     []string
	Stats             *Stats
	Targets           []*common.Owner
	Threads           int
	Version           string
}

Session contains all the necessary values and parameters used during a scan

func NewSession

func NewSession(v *viper.Viper, scanType string) (*Session, error)

NewSession is the entry point for starting a new scan session

func (*Session) AddFinding

func (s *Session) AddFinding(finding *matching.Finding)

TODO Need to update this to MJ methods AddFinding will add a finding that has been discovered during a session to the list of findings for that session

func (*Session) AddRepository

func (s *Session) AddRepository(repository *common.Repository)

AddRepository will add a given repository to be scanned to a session

func (*Session) AddTarget

func (s *Session) AddTarget(target *common.Owner)

AddTarget will add a new target to a session to be scanned during that session

func (*Session) Finish

func (s *Session) Finish()

Finish is called at the end of a scan session and used to generate discrete data points for a given scan session including setting the status of a scan to finished.

func (*Session) InitAPIClient

func (s *Session) InitAPIClient()

InitAPIClient will create a new gitlab or github api client based on the session identifier

func (*Session) InitLogger

func (s *Session) InitLogger()

InitLogger will initialize the logger for the session

func (*Session) InitRouter

func (s *Session) InitRouter()

InitRouter will configure and start the webserver for graphical output and status messages

func (*Session) InitSignatures

func (s *Session) InitSignatures()

InitSignature will load any signatures files into the session runtime configuration

func (*Session) InitStats

func (s *Session) InitStats()

InitStats will zero out the stats for a given session, setting them to known values

func (*Session) InitThreads

func (s *Session) InitThreads()

InitThreads will set the correct number of threads based on the commandline flags

func (*Session) Initialize

func (s *Session) Initialize(v *viper.Viper, scanType string)

Initialize will set the initial values and options used during a scan session

func (*Session) SaveToFile

func (s *Session) SaveToFile(location string) error

SaveToFile will save a json representation of the session output to a file

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
}

Stats will store all performance and scan related data tallies

func (*Stats) IncrementCommits

func (s *Stats) IncrementCommits()

IncrementCommits will add one to the running count of commits during the target discovery phase of a session

func (*Stats) IncrementFiles

func (s *Stats) IncrementFiles()

IncrementFiles will add one to the running count of files during the target discovery phase of a session

func (*Stats) IncrementFindings

func (s *Stats) IncrementFindings()

IncrementFindings will add one to the running count of findings during the target discovery phase of a session

func (*Stats) IncrementRepositories

func (s *Stats) IncrementRepositories()

IncrementRepositories will add one to the running repository count during the target discovery phase of a session

func (*Stats) IncrementTargets

func (s *Stats) IncrementTargets()

IncrementTargets will add one to the running target count during the target discovery phase of a session

func (*Stats) UpdateProgress

func (s *Stats) UpdateProgress(current int, total int)

UpdateProgress will update the progress percentage

Jump to

Keyboard shortcuts

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