utils

package
v0.0.0-...-192809c Latest Latest
Warning

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

Go to latest
Published: May 31, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const TimeFormat = "2006-01-02T15:04:05Z07:00"

Variables

View Source
var ExecCommand = func(name string, arg ...string) ([]byte, error) {
	cmd := exec.Command(name, arg...)
	return cmd.Output()
}

ExecCommand is a variable that can be replaced in tests to mock command execution

View Source
var ExecuteCommandWithEnv = func(command string, env []string, args ...string) (string, error) {
	cmd := exec.Command(command, args...)
	cmd.Env = append(os.Environ(), env...)
	output, err := cmd.Output()
	return strings.TrimSpace(string(output)), err
}

ExecuteCommandWithEnv is a variable that can be replaced in tests to mock command execution with env

Functions

func CompressOutput

func CompressOutput(srcDir, outputFilename string) error

func Contains

func Contains(slice []string, item string) bool

func ConvertCFAbsoluteTimeToDate

func ConvertCFAbsoluteTimeToDate(cfTimeStr string) (string, error)

func ConvertDateString

func ConvertDateString(input string) (string, error)

Parse from Oct 26 19:34:13 to 2006-01-02T15:04:05Z07:00 format

func CopyFile

func CopyFile(src, dst string) error

func ExecuteCommand

func ExecuteCommand(command string, args ...string) (string, error)

func GetCodeSignature

func GetCodeSignature(program string) (string, error)

GetCodeSignature returns the code signature information for a given program path. It uses the macOS `codesign` utility to verify the signature. Returns a string containing the signature information or an error if verification fails.

func GetHostname

func GetHostname() (string, error)

func GetMacOSVersion

func GetMacOSVersion() (string, error)

func GetNestedValue

func GetNestedValue(m map[string]interface{}, keys ...string) interface{}

Helper function to safely get nested map values

func GetOutputFileName

func GetOutputFileName(moduleName, format, outputDir string) string

func GetUsernameFromPath

func GetUsernameFromPath(path string) string

func ListFiles

func ListFiles(pattern string) ([]string, error)

ListFiles lists all files that match the given glob-like pattern. Example pattern: /path/starts*/*ends/file-*.asl

func Now

func Now() string

func ParseBiPList

func ParseBiPList(data string) (map[string]interface{}, error)

func ParseChromeTimestamp

func ParseChromeTimestamp(microsecondsStr string) string

func ParseTimestamp

func ParseTimestamp(value string) (string, error)

func ParseTimestampWithFormats

func ParseTimestampWithFormats(value string) (string, error)

ParseTimestampWithFormats attempts to parse a timestamp string using multiple common formats It returns the timestamp in the standard TimeFormat (2006-01-02T15:04:05Z07:00)

func QuerySQLite

func QuerySQLite(dbPath string, query string) (*sql.Rows, error)

Types

type CSVDataWriter

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

func (*CSVDataWriter) Close

func (dw *CSVDataWriter) Close() error

func (*CSVDataWriter) WriteRecord

func (dw *CSVDataWriter) WriteRecord(record Record) error

type DataWriter

type DataWriter interface {
	WriteRecord(record Record) error
	Close() error
}

func NewDataWriter

func NewDataWriter(outDir, filename, format string) (DataWriter, error)

type JSONDataWriter

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

func (*JSONDataWriter) Close

func (dw *JSONDataWriter) Close() error

func (*JSONDataWriter) WriteRecord

func (dw *JSONDataWriter) WriteRecord(record Record) error

type Logger

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

func NewLogger

func NewLogger() *Logger

func NewLoggerWithFile

func NewLoggerWithFile(file *os.File) *Logger

func (*Logger) Close

func (l *Logger) Close() error

func (*Logger) Debug

func (l *Logger) Debug(format string, v ...interface{})

func (*Logger) Error

func (l *Logger) Error(format string, v ...interface{})

func (*Logger) Info

func (l *Logger) Info(format string, v ...interface{})

func (*Logger) SetVerbosity

func (l *Logger) SetVerbosity(level int)

type Record

type Record struct {
	CollectionTimestamp string      `json:"collection_timestamp"`
	EventTimestamp      string      `json:"event_timestamp"`
	SourceFile          string      `json:"source_file"`
	Data                interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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