Documentation ¶
Overview ¶
Package lib Functionality for the Hookz CLI
Index ¶
- Variables
- func BuildFileList(fs FileSystem) (fileList []string, err error)
- func DownloadFile(fs FileSystem, filepath string, URL string) (filename string, err error)
- func IfErrorLog(err error, prefix string)
- func IsError(err error, prefix string) error
- func IsErrorBool(err error, prefix string) (b bool)
- func LoadIgnore(fs FileSystem) (ignores []string, err error)
- func LuchaDir() (path string, err error)
- type Configuration
- type FileSystem
- type Issue
- type Lucha
- type Rule
- type ScanFile
- type WriteCounter
Constants ¶
This section is empty.
Variables ¶
var ( //Rules contains the loaded rules from lucha.yaml Rules []Rule )
Functions ¶
func BuildFileList ¶
func BuildFileList(fs FileSystem) (fileList []string, err error)
BuildFileList gathers all of the files from the searchpath down the folder tree
func DownloadFile ¶
func DownloadFile(fs FileSystem, filepath string, URL string) (filename string, err error)
DownloadFile will download a url to a local file. It's efficient because it will write as it downloads and not load the whole file into memory. We pass an io.TeeReader into Copy() to report progress on the download.
func IfErrorLog ¶
IfErrorLog Checks to see if an error exists, and if so simply writes it to the log.
func IsError ¶
IsError Checks to see if an error exists, and if so writes it to the log with the provided prefix
func IsErrorBool ¶
IsErrorBool Checks to see if an error exists, and if so returns true after writing the error to the log with the provided prefix
func LoadIgnore ¶
func LoadIgnore(fs FileSystem) (ignores []string, err error)
LoadIgnore loads content in from the .luchaignore file
Types ¶
type Configuration ¶
Configuration encapsulates the high level lucha rules file structure
func LoadRules ¶
func LoadRules(fs FileSystem, version string, luchaFile string) (config Configuration, err error)
LoadRules loads the lucha.yaml rules file into memory
func RefreshRules ¶
func RefreshRules(fs FileSystem, version string) (config Configuration, err error)
RefreshRules pulls down the latest rules from https://github.com/devops-kung-fu/lucha
type FileSystem ¶
type FileSystem struct { SearchPath string Recursive bool IncludeGit bool // contains filtered or unexported fields }
FileSystem encapsulates the Afero fs Filesystem
func (FileSystem) AbsoluteSearchPath ¶
func (fs FileSystem) AbsoluteSearchPath() string
AbsoluteSearchPath returns the the absolute path for the (possibly) relative search path
type Lucha ¶
type Lucha struct {
Rules []Rule `json:"rules"`
}
Lucha contains the rules used to evaluate files with
type Rule ¶
type Rule struct { Code string `json:"code"` Name string `json:"name"` Description string `json:"description"` Message string `json:"message"` Attribution string `json:"attribution,omitempty"` Regex string `json:"regex"` Severity int64 `json:"severity,omitempty"` }
Rule the definition of a rule used to check files against
type ScanFile ¶
ScanFile encapsulates file information and issues for scanned files
func FindIssues ¶
func FindIssues(fs FileSystem, minSeverity int) (violations []ScanFile, violationsDetected bool, err error)
FindIssues scans the provided filesystem for issues
type WriteCounter ¶
WriteCounter encapsulates the total number of bytes captured and rendered
func (WriteCounter) PrintProgress ¶
func (wc WriteCounter) PrintProgress()
PrintProgress prints the current download progress to STDOUT