Documentation
¶
Index ¶
- Constants
- Variables
- func ArchiveFilename(path string) string
- func IndexFileFromPath(path string) string
- func RemoveIndexedLogfile(path string) (lastErr error)
- func RenameIndexedLogfile(old, new string) (lastErr error)
- type EventLogger
- func (l *EventLogger) Close() (lastErr error)
- func (l *EventLogger) CommitTransaction() (lastErr error)
- func (l *EventLogger) CountFiles() int
- func (l *EventLogger) InitTransaction() (id TransactionId)
- func (l *EventLogger) WriteEvent(id TransactionId, key string, evt *evtx.GoEvtxMap) (n int, err error)
- type EventSearcher
- type IndexEntry
- func (i *IndexEntry) Before(other *IndexEntry) bool
- func (i *IndexEntry) Contains(ts time.Time) bool
- func (i *IndexEntry) In(start time.Time, stop time.Time) bool
- func (i *IndexEntry) Less(other *datastructs.Sortable) bool
- func (i *IndexEntry) Overlaps(start time.Time, stop time.Time) bool
- func (i *IndexEntry) ToCSV() string
- func (i *IndexEntry) UpdateTime(t time.Time)
- type IndexFile
- type IndexedLogfile
- func (f *IndexedLogfile) Close() (err error)
- func (f *IndexedLogfile) Flush() (err error)
- func (f *IndexedLogfile) IndexFile() string
- func (f *IndexedLogfile) ReadRawEvents(offset int64, n int64) (events []*RawEvent, err error)
- func (f *IndexedLogfile) Size() (size int64, err error)
- func (f *IndexedLogfile) WriteRawEvent(e *RawEvent) (n int, err error)
- func (f *IndexedLogfile) WriteRawEventWithTimestamp(e *RawEvent, timestamp time.Time) (n int, err error)
- type RawEvent
- type TransactionId
Constants ¶
const ( // IndexExt is the file extension used for index files IndexExt = ".index" // IndexedLogfileExt is the file extension used by logfiles IndexedLogfileExt = ".gz" // DefaultLogPerm default logfile permission for Manager DefaultLogPerm = 0600 )
const (
MaxOpenedLogfile = 1024
)
Variables ¶
var ( TimeFormat = time.RFC3339Nano IndexHeader = "Start,Stop,Offset,EventCount" )
Functions ¶
func ArchiveFilename ¶
ArchiveFilename returns a standardized name to archive and IndexedLogfile
func IndexFileFromPath ¶
IndexFileFromPath returns a standardized IndexFile name from a path
func RemoveIndexedLogfile ¶
RemoveIndexedLogfile removes both an IndexLogfile and its associated IndexFile
func RenameIndexedLogfile ¶
RenameIndexedLogfile renames both an IndexLogfile and its associated IndexFile
Types ¶
type EventLogger ¶
EventLogger structure used to log EDR events
func NewEventLogger ¶
func NewEventLogger(root, base string, size int64) *EventLogger
NewEventLogger creates a new EventLogger
func (*EventLogger) Close ¶
func (l *EventLogger) Close() (lastErr error)
Close closes an EventLogger
func (*EventLogger) CommitTransaction ¶
func (l *EventLogger) CommitTransaction() (lastErr error)
CommitTransaction commits a transaction leaving the place for a new one. A transaction needs to be committed before a new one can be initialized and used.
func (*EventLogger) CountFiles ¶
func (l *EventLogger) CountFiles() int
CountFiles returns the count of opened IndexedFiles
func (*EventLogger) InitTransaction ¶
func (l *EventLogger) InitTransaction() (id TransactionId)
InitTransaction initializes a new logging transaction only attempts to use WriteEvent with the proper id will succeed
func (*EventLogger) WriteEvent ¶
func (l *EventLogger) WriteEvent(id TransactionId, key string, evt *evtx.GoEvtxMap) (n int, err error)
WriteEvent writes an event to an IndexedLogfile chosen according to the internal algorithm of the EventLogger
type EventSearcher ¶
EventSearcher is used to search for events accross the file system
func NewEventSearcher ¶
func NewEventSearcher(root string) (s *EventSearcher)
NewEventSearcher creates a new EventSearcher structure to be used to search logs
func (*EventSearcher) Close ¶
func (s *EventSearcher) Close() (lastErr error)
Close closes all the opened IndexedLogfile
func (*EventSearcher) Err ¶
func (s *EventSearcher) Err() error
Err returns any error which happened during a call to Events function
type IndexEntry ¶
type IndexEntry struct {
Start time.Time `json:"start"`
Stop time.Time `json:"stop"`
Offset int64 `json:"offset"`
EventCount int64 `json:"count"`
// contains filtered or unexported fields
}
IndexEntry represents encodes information about the events written in an IndexedLogfile
func IndexEntryFromCSV ¶
func IndexEntryFromCSV(line string) (ie *IndexEntry, err error)
IndexEntryFromCSV returns an IndexEntry from a CSV line
func (*IndexEntry) Before ¶
func (i *IndexEntry) Before(other *IndexEntry) bool
Before returns true if index is before another
func (*IndexEntry) Contains ¶
func (i *IndexEntry) Contains(ts time.Time) bool
Contains returns true if time is in between entry start and stop
func (*IndexEntry) Less ¶
func (i *IndexEntry) Less(other *datastructs.Sortable) bool
Implements datastructs.Sortable interface
func (*IndexEntry) ToCSV ¶
func (i *IndexEntry) ToCSV() string
ToCSV marshals an IndexEntry to CSV data
func (*IndexEntry) UpdateTime ¶
func (i *IndexEntry) UpdateTime(t time.Time)
UpdateTime must be used to update the Start and Stop timestamps of the IndexEntry structure
type IndexFile ¶
type IndexFile struct {
// contains filtered or unexported fields
}
IndexFile represents an opened index file
func OpenIndexFile ¶
OpenIndexFile opens an index file from a path
func (*IndexFile) LogfilePath ¶
LogfilePaths returns the name of the IndexedLogFile associated to the IndexFile
func (*IndexFile) Next ¶
func (inf *IndexFile) Next() (ie *IndexEntry, err error)
Next returns the next IndexEntry stop condition if ie == nil or err != nil
type IndexedLogfile ¶
IndexedLogfile structure
func OpenIndexedLogfile ¶
func OpenIndexedLogfile(path string) (l *IndexedLogfile, err error)
OpenIndexedLogfile opens an IndexedLogfile
func (*IndexedLogfile) Close ¶
func (f *IndexedLogfile) Close() (err error)
Close flushes and closes an IndexedLogfile
func (*IndexedLogfile) Flush ¶
func (f *IndexedLogfile) Flush() (err error)
Flush flushes the IndexedLogfile to disk
func (*IndexedLogfile) IndexFile ¶
func (f *IndexedLogfile) IndexFile() string
IndexFile returns the path of the IndexFile associated to the IndexedLogfile
func (*IndexedLogfile) ReadRawEvents ¶
func (f *IndexedLogfile) ReadRawEvents(offset int64, n int64) (events []*RawEvent, err error)
ReadRawEvents reads n RawEvents located at offset in IndexedLogfile
func (*IndexedLogfile) Size ¶
func (f *IndexedLogfile) Size() (size int64, err error)
Size returns the size of the IndexedLogfile
func (*IndexedLogfile) WriteRawEvent ¶
func (f *IndexedLogfile) WriteRawEvent(e *RawEvent) (n int, err error)
WriteRawEvent writes a RawEvent in IndexLogfile taking the event timestamp as reference time
func (*IndexedLogfile) WriteRawEventWithTimestamp ¶
func (f *IndexedLogfile) WriteRawEventWithTimestamp(e *RawEvent, timestamp time.Time) (n int, err error)
WriteRawEventWithTimestamp writes a RawEvent with an associated event timestamp in the IndexLogfile