scan

package
v0.0.0-...-8851a85 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Application version information
	Version = "0.1.3"
)

Variables

View Source
var (
	ErrNotIsDir = errors.New("the current file is not a directory")
	NilString   = ""
)

Functions

func BlockMd5

func BlockMd5(file *os.File, size int64, hashed hash.Hash) (string, error)

BlockMd5 Built-in sharding md5 algorithm used

func Exec

func Exec(do func() error)

Exec execution statistics time

func Files

func Files(folder string) ([]string, error)

Files returns the collection of all file paths under the specified path

func HexDecode

func HexDecode(s string) []byte

HexDecode hex decryption

func HexDump

func HexDump(path string) (string, error)

HexDump convert the specified file to hexadecimal

func HexEncode

func HexEncode(s string) []byte

HexEncode hex encoding

func IsDir

func IsDir(path string) bool

IsDir check if the path is a directory

func IsFile

func IsFile(path string) bool

IsFile check if the path is a file

func Md5

func Md5(filepath string) (string, error)

Md5 get the md5 value of the file based on the path

func OutFileString

func OutFileString(out string, _ *Scanner, hexStr string)

OutFileString output content to the specified file

func Output

func Output(out string, scanner *Scanner, res []Result)

Output send the specified content to the console or file

func SaveFile

func SaveFile(out string, scanner *Scanner, res []ResultElement)

Types

type HexMatcher

type HexMatcher struct{}

func (*HexMatcher) Search

func (*HexMatcher) Search(files []string, searchTerm string) ([]Result, error)

Search match search signatures by hex in file collections

type Matcher

type Matcher interface {
	Search(files []string, searchTerm string) ([]Result, error)
}

Matcher scanner matcher

type Md5Matcher

type Md5Matcher struct{}

Matcher md5 and hex implement

func (*Md5Matcher) Search

func (*Md5Matcher) Search(files []string, searchTerm string) ([]Result, error)

Search match search signatures by md5 in file collections

type Ref

type Ref struct {
	Line string `json:"line"`
	Msg  string `json:"msg"`
	Tag  string `json:"tag"`
	Path string `json:"path"`
}

type Result

type Result struct {
	Index int    `json:"index,omitempty"`
	Path  string `json:"path,omitempty"`
	Code  string `json:"code,omitempty"`
}

Result content scan results

type ResultElement

type ResultElement struct {
	Path   string `json:"path"`
	Line   string `json:"line"`
	Column string `json:"column"`
	Msg    string `json:"msg"`
	Rule   string `json:"rule"`
	Refs   []Ref  `json:"refs"`
}

type Scanner

type Scanner struct {
	Matcher
	Path string
	Code string
}

Scanner universal scanner

func (*Scanner) HexDump

func (s *Scanner) HexDump() (string, error)

HexDump convert path content to hexadecimal

func (*Scanner) List

func (s *Scanner) List() ([]Result, error)

List returns all files under the specified path to calculate the signature

func (*Scanner) Output

func (*Scanner) Output(writer io.Writer, res []Result) error

Output output result to writable io device

func (*Scanner) SaveAs

func (*Scanner) SaveAs(writer io.Writer, res []ResultElement) error

func (*Scanner) Search

func (s *Scanner) Search(code string) ([]Result, error)

Search search signature

func (*Scanner) SetMatcher

func (s *Scanner) SetMatcher(m Matcher)

SetMatcher setting matcher scanner

func (*Scanner) SetPath

func (s *Scanner) SetPath(path string)

SetPath setting path scanner

Jump to

Keyboard shortcuts

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