adapters

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2019 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package adapters provides functions that make some kind of transformation or processing on an entity that involves the external world. Every adapter has the same signature:

- First argument: The command struct, that serves to pass information to all the application. - Second argument: The entity to transform.

As we have not generics in go (yet), there are multiple signatures depending on the kind of entity that the adapter accepts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdapterMap

type AdapterMap struct {
	Services ServiceAdapters
	Tools    ToolAdapters
	Output   OutputAdapters
}

The adapters are passed to the usecases using the adapter map. The adapter map is just a struct containing all the adapters the program may need to use, classified by their utility. This way, if a usecases needs to access an adapter. all it has to do is to call the asigned adapter in the map.

Usecases check if an adapter is nil when calling it, so every value on the map can be nil.

type ErrorAdapter

type ErrorAdapter func(entities.Command, *entities.Error) error

ErrorAdapter is intended to process the errors generated by the usecases while functioning. Usually, it should be used to log the error. It returns an error if the entities.Error argument had an error, so the usual convention `if err != nil` can be used as `if ErrorAdapter(command, error) != nil` to stop execution.

type GenericAdapter

type GenericAdapter func(entities.Command, entities.Entity) error

GenericAdapter is an adapter that accepts a generic entity. It's the type used to output the usecases results (AdapterMap.Output.Result).

type LogAdapter

type LogAdapter func(entities.Command, *entities.LogMessage) error

LogAdapter logs messages that are generated while the program executes. These messages can be informatives, warnings or errors.

type MalwareAdapter

type MalwareAdapter func(entities.Command, *entities.CodeAnalysis) error

MalwareAdapter is the adapter to access the malware analysis service. It accepts an entities.CodeAnalysis as second argument.

type OutputAdapters

type OutputAdapters struct {
	Logger LogAdapter
	Result GenericAdapter
	Error  ErrorAdapter
}

type ServiceAdapters

type ServiceAdapters struct {
	MalwareDomains MalwareAdapter
	VirusScan      VirusAdapter
}

type ToolAdapter

type ToolAdapter func(entities.Command, *entities.BinaryAnalysis) error

ToolAdapter is the adapter used to access external tools. As every tool until now is accesed by the binary analysis usecase, it accepts a entities.BinaryAnalyisis as second argument.

type ToolAdapters

type ToolAdapters struct {
	ClassDump ToolAdapter
	Libs      ToolAdapter
	Headers   ToolAdapter
	Symbols   ToolAdapter
}

type VirusAdapter

type VirusAdapter func(entities.Command, *entities.VirusAnalysis) error

VirusAdapter access the VirusTotal service. It has its own VirusAnalysis entity, as it is called directly in static analysis.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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