internal

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Formatters = map[string]Formatter{
	"text":   TextFormatter{},
	"ndjson": JSONFormatter{},
}

Formatters holds available formatters

Functions

func Main

func Main(urlStr string, showData bool, showAll bool, limit int, processes int, only string, except string, minCount int, pattern string, debug bool, format string) error

Types

type Adapter

type Adapter interface {
	Scan(scanOpts ScanOpts) ([]ruleMatch, error)
}

type DataStoreAdapter added in v0.1.5

type DataStoreAdapter interface {
	TableName() string
	RowName() string
	Init(url string) error
	FetchTables() ([]table, error)
	FetchTableData(table table, limit int) (*tableData, error)
}

type ElasticsearchAdapter added in v0.1.4

type ElasticsearchAdapter struct {
	DB *elasticsearch.Client
	// contains filtered or unexported fields
}

func (ElasticsearchAdapter) FetchTableData added in v0.1.4

func (a ElasticsearchAdapter) FetchTableData(table table, limit int) (*tableData, error)

func (ElasticsearchAdapter) FetchTables added in v0.1.4

func (a ElasticsearchAdapter) FetchTables() ([]table, error)

func (*ElasticsearchAdapter) Init added in v0.1.4

func (a *ElasticsearchAdapter) Init(urlStr string) error

func (*ElasticsearchAdapter) RowName added in v0.1.4

func (a *ElasticsearchAdapter) RowName() string

func (*ElasticsearchAdapter) Scan added in v0.1.6

func (a *ElasticsearchAdapter) Scan(scanOpts ScanOpts) ([]ruleMatch, error)

func (*ElasticsearchAdapter) TableName added in v0.1.4

func (a *ElasticsearchAdapter) TableName() string

type FileAdapter added in v0.1.1

type FileAdapter interface {
	ObjectName() string
	Init(url string) error
	FetchFiles() ([]string, error)
	FindFileMatches(file string, matchFinder *MatchFinder) error
}

type Formatter added in v0.1.7

type Formatter interface {
	// PrintMatch formats and prints the match to `writer`.
	PrintMatch(writer io.Writer, match matchInfo) error
}

Format defines the interface used to deliver results to the end user.

type JSONFormatter added in v0.1.7

type JSONFormatter struct{}

JSONFormatter prints the result as a JSON object.

func (JSONFormatter) PrintMatch added in v0.1.7

func (f JSONFormatter) PrintMatch(writer io.Writer, match matchInfo) error

type LocalFileAdapter added in v0.1.1

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

func (LocalFileAdapter) FetchFiles added in v0.1.1

func (a LocalFileAdapter) FetchFiles() ([]string, error)

func (LocalFileAdapter) FindFileMatches added in v0.1.1

func (a LocalFileAdapter) FindFileMatches(filename string, matchFinder *MatchFinder) error

TODO read metadata for certain file types

func (*LocalFileAdapter) Init added in v0.1.1

func (a *LocalFileAdapter) Init(url string) error

func (*LocalFileAdapter) ObjectName added in v0.1.5

func (a *LocalFileAdapter) ObjectName() string

func (*LocalFileAdapter) Scan added in v0.1.6

func (a *LocalFileAdapter) Scan(scanOpts ScanOpts) ([]ruleMatch, error)

type MatchConfig added in v0.1.6

type MatchConfig struct {
	RegexRules     []regexRule
	NameRules      []nameRule
	MultiNameRules []multiNameRule
	TokenRules     []tokenRule
	MinCount       int
}

func NewMatchConfig added in v0.1.6

func NewMatchConfig() MatchConfig

type MatchFinder added in v0.1.6

type MatchFinder struct {
	MatchedValues [][]MatchLine
	TokenValues   [][]MatchLine
	Count         int
	// contains filtered or unexported fields
}

func NewMatchFinder added in v0.1.6

func NewMatchFinder(matchConfig *MatchConfig) MatchFinder

func (*MatchFinder) CheckMatches added in v0.1.6

func (a *MatchFinder) CheckMatches(colIdentifier string, onlyValues bool) []ruleMatch

func (*MatchFinder) CheckTableData added in v0.1.6

func (a *MatchFinder) CheckTableData(table table, tableData *tableData) []ruleMatch

func (*MatchFinder) Clear added in v0.1.6

func (a *MatchFinder) Clear()

func (*MatchFinder) Scan added in v0.1.6

func (a *MatchFinder) Scan(v string, index int)

fast check for matches extract values and index in a later step if needed (if --show-data is passed)

func (*MatchFinder) ScanValues added in v0.1.6

func (a *MatchFinder) ScanValues(values []string)

type MatchLine added in v0.1.7

type MatchLine struct {
	LineIndex int
	Line      string
}

type MongodbAdapter added in v0.1.4

type MongodbAdapter struct {
	DB *mongo.Database
}

func (MongodbAdapter) FetchTableData added in v0.1.4

func (a MongodbAdapter) FetchTableData(table table, limit int) (*tableData, error)

func (MongodbAdapter) FetchTables added in v0.1.4

func (a MongodbAdapter) FetchTables() ([]table, error)

func (*MongodbAdapter) Init added in v0.1.4

func (a *MongodbAdapter) Init(urlStr string) error

func (*MongodbAdapter) RowName added in v0.1.4

func (a *MongodbAdapter) RowName() string

func (*MongodbAdapter) Scan added in v0.1.6

func (a *MongodbAdapter) Scan(scanOpts ScanOpts) ([]ruleMatch, error)

func (*MongodbAdapter) TableName added in v0.1.4

func (a *MongodbAdapter) TableName() string

type RedisAdapter added in v0.1.4

type RedisAdapter struct {
	DB *redis.Client
}

func (RedisAdapter) FetchTableData added in v0.1.4

func (a RedisAdapter) FetchTableData(table table, limit int) (*tableData, error)

func (RedisAdapter) FetchTables added in v0.1.4

func (a RedisAdapter) FetchTables() ([]table, error)

func (*RedisAdapter) Init added in v0.1.4

func (a *RedisAdapter) Init(urlStr string) error

func (*RedisAdapter) RowName added in v0.1.4

func (a *RedisAdapter) RowName() string

func (*RedisAdapter) Scan added in v0.1.6

func (a *RedisAdapter) Scan(scanOpts ScanOpts) ([]ruleMatch, error)

func (*RedisAdapter) TableName added in v0.1.4

func (a *RedisAdapter) TableName() string

type S3Adapter added in v0.1.1

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

func (S3Adapter) FetchFiles added in v0.1.1

func (a S3Adapter) FetchFiles() ([]string, error)

func (S3Adapter) FindFileMatches added in v0.1.1

func (a S3Adapter) FindFileMatches(filename string, matchFinder *MatchFinder) error

func (*S3Adapter) Init added in v0.1.1

func (a *S3Adapter) Init(url string) error

func (*S3Adapter) ObjectName added in v0.1.5

func (a *S3Adapter) ObjectName() string

func (*S3Adapter) Scan added in v0.1.6

func (a *S3Adapter) Scan(scanOpts ScanOpts) ([]ruleMatch, error)

type ScanOpts added in v0.1.7

type ScanOpts struct {
	UrlStr      string
	ShowData    bool
	ShowAll     bool
	Limit       int
	Debug       bool
	Formatter   Formatter
	MatchConfig *MatchConfig
}

type SqlAdapter

type SqlAdapter struct {
	DB *sqlx.DB
}

func (SqlAdapter) FetchTableData

func (a SqlAdapter) FetchTableData(table table, limit int) (*tableData, error)

func (SqlAdapter) FetchTables

func (a SqlAdapter) FetchTables() ([]table, error)

func (*SqlAdapter) Init

func (a *SqlAdapter) Init(url string) error

func (*SqlAdapter) RowName added in v0.1.4

func (a *SqlAdapter) RowName() string

func (*SqlAdapter) Scan added in v0.1.6

func (a *SqlAdapter) Scan(scanOpts ScanOpts) ([]ruleMatch, error)

func (*SqlAdapter) TableName added in v0.1.4

func (a *SqlAdapter) TableName() string

type TextFormatter added in v0.1.7

type TextFormatter struct{}

TextFormatter prints the result as human readable text.

func (TextFormatter) PrintMatch added in v0.1.7

func (f TextFormatter) PrintMatch(writer io.Writer, match matchInfo) error

Jump to

Keyboard shortcuts

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