hashr

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 16 Imported by: 6

Documentation

Overview

Package hashr implements core functionality for hashR.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exporter

type Exporter interface {
	// Export exports samples to a given data sink.
	Export(ctx context.Context, repoName, repoPath, sourceID, sourceHash, sourcePath, sourceDescription string, samples []common.Sample) error
	// Name returns exporter name.
	Name() string
}

Exporter represents exporter instance that will be used to export extracted data.

type HashR

type HashR struct {
	Importers              []Importer
	Processor              Processor
	Exporters              []Exporter
	Storage                Storage
	ProcessingWorkerCount  int
	ExportWorkerCount      int
	CacheDir               string
	Dev                    bool
	Export                 bool
	ExportPath             string
	SourcesForReprocessing []string
	// contains filtered or unexported fields
}

HashR holds data related to running instance of HashR.

func New

func New(importers []Importer, processor Processor, exporters []Exporter, storage Storage) *HashR

New returns new instance of hashR.

func (*HashR) Run

func (h *HashR) Run(ctx context.Context) error

Run executes main processing loop for hashR.

type Importer

type Importer interface {
	// DiscoverRepo returns slice of objects that satisfy Source interface.
	DiscoverRepo() ([]Source, error)
	// RepoName() returns repository name.
	RepoName() string
	// RepoPath() returns repository path.
	RepoPath() string
}

Importer represents importer instance that will be used to import data for processing.

type ProcessingSource

type ProcessingSource struct {
	ID                    string
	Repo                  string
	RepoPath              string
	RemoteSourcePath      string
	Sha256                string
	Status                status
	ImportedAt            int64
	PreprocessingDuration time.Duration
	ProcessingDuration    time.Duration
	ExportDuration        time.Duration
	SampleCount           int
	ExportCount           int
	Error                 string
}

ProcessingSource holds data related to a processing source.

type Processor

type Processor interface {
	// ImageExport runs image_export.py binary and returns local path to the folder with extracted
	// data.
	ImageExport(string) (string, error)
}

Processor represents processor instance that will be used to process source data.

type Source

type Source interface {
	// ID returns non-unique ID for a given source.
	ID() string
	// RepoName returns source repository name.
	RepoName() string
	// RepoPath returns source repository path.
	RepoPath() string
	// LocalPath returns path to the source on the local file system.
	LocalPath() string
	// RemotePath returns path to the source in the remote location.
	RemotePath() string
	// Preprocess does the necessary preprocessing (extracting, mounting) to ingest the data in
	// Plaso.
	Preprocess() (string, error)
	// QuickSHA256Hash returns SHA256 digest, that is used to check if a given source data was
	// already processed.Given the fact that some repositories will hold a lot of data, the intent
	// here is to use the least resource demanding method to return a source digest.
	QuickSHA256Hash() (string, error)
	// Description provides additional description of the source.
	Description() string
}

Source represents data to be processed.

type Storage

type Storage interface {
	UpdateJobs(ctx context.Context, qHash string, p *ProcessingSource) error
	FetchJobs(ctx context.Context) (map[string]string, error)
}

Storage represents storage that is used to store data about processed sources.

Jump to

Keyboard shortcuts

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