gitsearch

package
v0.0.0-...-9d1fe49 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//CloneDir is the temporary directory name used while
	//Checking out git repository
	CloneDir = "gitaudit-"
)

Variables

This section is empty.

Functions

func Start

func Start(gs *GSArgs)

Start is the entry point for git search

Types

type AuditReport

type AuditReport struct {
	RuleName  string `json:"rulename"`
	Rule      string `json:"rule"`
	Branch    string `json:"branch"`
	Hash      string `json:"hash"`
	Time      string `json:"time"`
	Committer string `json:"committer"`
	FilePath  string `json:"file"`
	Match     string `json:"match"`
}

AuditReport contains reporting fields to be

type BranchSearchOptions

type BranchSearchOptions struct {
	Branch  string  `json:"branch"`
	RuleSet RuleSet `json:"ruleset"`
}

BranchSearchOptions has the search options for each branch

type GSArgs

type GSArgs struct {
	// contains filtered or unexported fields
}

GSArgs used to store arguments received from the user

func (*GSArgs) Validate

func (gsArgs *GSArgs) Validate() error

Validate vaildates the arguments

type GitBranch

type GitBranch struct {
	// contains filtered or unexported fields
}

GitBranch contains details about branch and its search options

func (*GitBranch) Search

func (branch *GitBranch) Search()

Search searches as per the rules through all commit differences

func (*GitBranch) SearchInFile

func (branch *GitBranch) SearchInFile(searchString string, c *object.Commit) (bool, []string, []string)

SearchInFile searches the searchString in file , if a match is found we will just come out. searchString can be a regular experssion

func (*GitBranch) SearchInPatch

func (branch *GitBranch) SearchInPatch(searchString string, p *object.Patch) (bool, []string, []string)

SearchInPatch searches the searchString in patch , if a match is found we will just come out. searchString can be a regular experssion

func (*GitBranch) SetSearchOpts

func (branch *GitBranch) SetSearchOpts(gitRepo *GitRepository) bool

SetSearchOpts sets the branch search options

type GitRepository

type GitRepository struct {
	SearchOpts []BranchSearchOptions
	// contains filtered or unexported fields
}

GitRepository has the details about the repository to be searched and search options

func (*GitRepository) CloneRepo

func (gitRepo *GitRepository) CloneRepo(repoURL string) error

CloneRepo clones the repository

func (*GitRepository) Search

func (gitRepo *GitRepository) Search()

Search starts the search in gitrepo

type RepoSearchOptions

type RepoSearchOptions struct {
	BranchSearchOptions []BranchSearchOptions `json:"repository"`
}

RepoSearchOptions contains

func GetSearchOptions

func GetSearchOptions(searchOptFile string) (*RepoSearchOptions, error)

GetSearchOptions gets the search options from the seachoption file

type RuleSet

type RuleSet struct {
	RuleName string            `json:"rulename"`
	Rules    map[string]string `json:"rules"`
}

RuleSet contains rule details of a branch

type SafeCounter

type SafeCounter struct {
	// contains filtered or unexported fields
}

SafeCounter is safe to use concurrently.

func (*SafeCounter) GetViolationCount

func (c *SafeCounter) GetViolationCount() int

GetViolationCount returns the no of Violations

func (*SafeCounter) Inc

func (c *SafeCounter) Inc()

Inc increments the number of Violations

func (*SafeCounter) Reset

func (c *SafeCounter) Reset()

Reset resets the safe values

type SearchDetails

type SearchDetails struct {
	// contains filtered or unexported fields
}

SearchDetails contains search details

Jump to

Keyboard shortcuts

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