state

package
v0.0.0-...-6c6fd2d Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultStoreDir is the default directory name for storing scan histories file
	DefaultStoreDir = ".secretscanner"

	// DefaultStoreFile is the default scan histories file name
	DefaultStoreFile = "scan-histories.json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type History

type History struct {
	ID          string `json:"id"`
	GitProvider string `json:"git_provider"`
	RepoID      string `json:"repo_id"`
	CommitHash  string `json:"commit_hash"`
	CreatedAt   string `json:"created_at"`
}

History contains scan history fields

func Create

func Create(gitProvider, repoID, commitHash, createdAt string) *History

Create creates a scan history struct

func (*History) AssignID

func (h *History) AssignID()

AssignID generates a hash and assign it to history ID field

func (*History) GetMapKey

func (h *History) GetMapKey() string

GetMapKey returns the scan history map key

type JSONFileStore

type JSONFileStore struct {
	DataFile *os.File
	Records  map[string]*History
}

JSONFileStore is a JSON-based storage for scan histories

func (*JSONFileStore) Close

func (fs *JSONFileStore) Close()

Close cleans up resources

func (*JSONFileStore) Get

func (fs *JSONFileStore) Get(gitprovider, repoID string) *History

Get retrieves history from store

func (*JSONFileStore) GetDefaultStorePath

func (fs *JSONFileStore) GetDefaultStorePath() (string, error)

GetDefaultStorePath returns default store file path, creates dir and file is not found

func (*JSONFileStore) Initialize

func (fs *JSONFileStore) Initialize(filepath string) error

Initialize ...

func (*JSONFileStore) Save

func (fs *JSONFileStore) Save(history *History) error

Save persists records to file

Jump to

Keyboard shortcuts

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