Documentation ¶
Index ¶
- func FilterMap(m map[string]interface{}, include, exclude []string) map[string]interface{}
- func IsDir(f string) bool
- func ObjectToMap(obj *vt.Object) map[string]interface{}
- type APIClient
- type Coordinator
- type Doer
- type DoerState
- type FilteredStringReader
- type MappedStringReader
- type PQueue
- type PQueueNode
- type Printer
- func (p *Printer) GetAndPrintObjects(endpoint string, r StringReader, argRe *regexp.Regexp) error
- func (p *Printer) Print(data interface{}) error
- func (p *Printer) PrintCollection(collection *url.URL) error
- func (p *Printer) PrintCommandLineWithCursor(it *vt.Iterator)
- func (p *Printer) PrintIterator(it *vt.Iterator) error
- func (p *Printer) PrintObject(obj *vt.Object) error
- func (p *Printer) PrintObjects(objs []*vt.Object) error
- func (p *Printer) PrintSyncMap(sm *sync.Map) error
- type StringArrayReader
- type StringIOReader
- type StringReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterMap ¶
FilterMap receives a map with string keys and arbitrary values (possibly other maps) and return a new map which is a subset of the original one containing only the keys matching any of the patterns in "include" and excluding keys matching any of the patterns in "exclude". The logic for determining if a key matches the pattern goes as follow:
- The path for the key is computed. If the key is in the top-level map its path is the key itself, if the key is contained within a nested map its path is the concatenation of the parent's path and the key, using a dot (.) as a separator. The path for "key" in {a:{b:{key:val}}} is a.b.key.
- The path is matched against the pattern, which can contain asterisks (*) as a placeholder for any character different from a dot (.) and ** as a placeholder for any character including a dot. For more information go to: https://godoc.org/github.com/gobwas/glob#Compile
- If the path matches any pattern in "include" the key is included in the resulting map, as long as it doesn't match a pattern in "exclude".
func ObjectToMap ¶
ObjectToMap function that returns the attributes for an object as a map. Keys are attribute names and values are the attribute's value. Two special keys _id and _type are also included in the map with object's identifier and type respectively. The map is filtered according to the filters specified in the --include and --exclude command-line arguments.
Types ¶
type APIClient ¶
APIClient represents a VirusTotal API client.
func NewAPIClient ¶
NewAPIClient returns a new VirusTotal API client using the API key configured either using the program configuration file or the --apikey command-line flag.
func (*APIClient) RetrieveObjects ¶
func (c *APIClient) RetrieveObjects(endpoint string, args []string, outCh chan *vt.Object, errCh chan error) error
RetrieveObjects retrieves objects from the specified endpoint. The endpoint must contain a %s placeholder that will be replaced with items from the args slice. The objects are put into the outCh as they are retrieved.
type Coordinator ¶
type Coordinator struct { Threads int Spinner *spinner.Spinner // contains filtered or unexported fields }
Coordinator coordinates the work of multiple instances of a Doer that run in parallel.
func NewCoordinator ¶
func NewCoordinator(threads int) *Coordinator
NewCoordinator creates a new instance of Coordinator.
func (*Coordinator) DoWithItemsFromChannel ¶
func (c *Coordinator) DoWithItemsFromChannel(doer Doer, ch <-chan interface{})
DoWithItemsFromChannel calls the Do method of a type implementing the Doer interface with items read from a channel. This function doesn't exit until the channel is closed.
func (*Coordinator) DoWithObjectsFromIterator ¶
func (c *Coordinator) DoWithObjectsFromIterator(doer Doer, it *vt.Iterator, bufferSize int)
DoWithObjectsFromIterator calls the Do of a type implementing the Doer interface with the objects returned by a vt.Iterator. Objects returned by the iterator are put in a channel with a buffer size of bufferSize.
func (*Coordinator) DoWithStringsFromReader ¶
func (c *Coordinator) DoWithStringsFromReader(doer Doer, reader StringReader)
DoWithStringsFromReader calls the Do of a type implementing the Doer interface with strings read from a StringReader. The doer's Do method is called once for each string, and this function doesn't exit until the StringReader returns an empty string.
func (*Coordinator) EnableSpinner ¶
func (c *Coordinator) EnableSpinner()
EnableSpinner activates an animation while the coordinator is waiting.
type Doer ¶
Doer is the interface that must be implemented for any type to be used with DoWithStringsFromReader and DoWithStringsFromChannel.
type DoerState ¶
type DoerState struct {
Progress string
}
DoerState represents the current state of a Doer.
type FilteredStringReader ¶
type FilteredStringReader struct {
// contains filtered or unexported fields
}
FilteredStringReader filters a StringReader returning only the strings that match a given regular expression.
func NewFilteredStringReader ¶
func NewFilteredStringReader(r StringReader, re *regexp.Regexp) *FilteredStringReader
NewFilteredStringReader creates a new FilteredStringReader that reads strings from r and return only those that match re.
func (*FilteredStringReader) ReadString ¶
func (f *FilteredStringReader) ReadString() (s string, err error)
ReadString reads strings from the underlying StringReader and returns the first one that matches the regular expression specified while creating the FilteredStringReader. If no more strings can be read err is io.EOF.
type MappedStringReader ¶
type MappedStringReader struct {
// contains filtered or unexported fields
}
MappedStringReader reads strings from a StringReader and call a map function that transforms the strings in some other string.
func NewMappedStringReader ¶
func NewMappedStringReader(r StringReader, mapFn func(string) string) *MappedStringReader
NewMappedStringReader creates a new MappedStringReader that reads strings from r and can call mapFn for transforming the string before returning it.
func (*MappedStringReader) ReadString ¶
func (m *MappedStringReader) ReadString() (s string, err error)
ReadString reads strings from the underlying StringReader and can call the map function associated to the MappedStringReader with that string, then returns the result produced by the map function.
type PQueue ¶
type PQueue []PQueueNode
PQueue is a type implementing a priority queue
func (*PQueue) Pop ¶
func (pq *PQueue) Pop() interface{}
Pop removes a value from the head of the priority queue
type PQueueNode ¶
type PQueueNode struct { Priority int Data interface{} }
PQueueNode is a node in a priority queues
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer prints objects to stdout.
func NewPrinter ¶
NewPrinter creates a new object printer.
func (*Printer) GetAndPrintObjects ¶
GetAndPrintObjects retrieves objects from the specified endpoint and prints them. The endpoint must contain a %s placeholder that will be replaced with items from the args slice. If args contains a single "-" string, the args are read from stdin one per line. If argRe is non-nil, only args that match the regular expression are used and the rest are discarded.
func (*Printer) PrintCollection ¶
PrintCollection prints a collection of objects retrieved from the collection specified by the collection URL.
func (*Printer) PrintCommandLineWithCursor ¶
PrintCommandLineWithCursor prints the same command-line that was used for executing the program but adding or replacing the --cursor flag with the current cursor for the given iterator.
func (*Printer) PrintIterator ¶
PrintIterator prints the objects returned by an object iterator.
func (*Printer) PrintObject ¶
PrintObject prints the specified object to stdout.
func (*Printer) PrintObjects ¶
PrintObjects prints all the specified objects to stdout.
type StringArrayReader ¶
type StringArrayReader struct {
// contains filtered or unexported fields
}
StringArrayReader is a wrapper around a slice of strings that implements the StringReader interface. Each time the ReadString method is called a string from the array is returned and the position is advanced by one. When all strings have been returned ReadString returns an io.EOF error.
func NewFileDirReader ¶
func NewFileDirReader(fileDir string) (*StringArrayReader, error)
FileDirReader returns all files inside a given directory as a StringArrayReader
func NewStringArrayReader ¶
func NewStringArrayReader(strings []string) *StringArrayReader
NewStringArrayReader creates a new StringArrayReader.
func (*StringArrayReader) ReadString ¶
func (sar *StringArrayReader) ReadString() (string, error)
ReadString reads one string from StringArrayReader. When all strings have been returned ReadString returns an io.EOF error.
type StringIOReader ¶
type StringIOReader struct {
// contains filtered or unexported fields
}
StringIOReader is a wrapper around a bufio.Scanner that implements the StringReader interface.
func NewStringIOReader ¶
func NewStringIOReader(r io.Reader) *StringIOReader
NewStringIOReader creates a new StringIOReader.
func (*StringIOReader) ReadString ¶
func (sir *StringIOReader) ReadString() (string, error)
ReadString reads one string from StringIOReader. When all strings have been returned ReadString returns an io.EOF error.
type StringReader ¶
StringReader is the interface that wraps the ReadString method.
func StringReaderFromCmdArgs ¶
func StringReaderFromCmdArgs(args []string) StringReader
StringReaderFromCmdArgs returns a string reader for reading the arguments passed in the command line. If the arguments consists in single hypen "-", they are read from stdin.