provenlogs

package
v0.0.0-...-b1cb840 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultBSONRegistry

func DefaultBSONRegistry() *bsoncodec.Registry

DefaultBSONRegistry returns the default BSON registry being used by ProvenLogs

func NewOrderedBSONRegistry

func NewOrderedBSONRegistry() *bsoncodec.Registry

NewOrderedBSONRegistry creates a default BSON registry that encodes a map into an ordered BSON doc with its keys sorted in string order

Types

type LogEntries

type LogEntries []LogEntry

LogEntries represents a slice of log entries

func (LogEntries) AnyArray

func (l LogEntries) AnyArray() []interface{}

AnyArray returns the `[]interface{}` version of the LogEntries

func (LogEntries) AttachSig

func (l LogEntries) AttachSig(sigStr string)

AttachSig attaches the given RSA signature to the last log entry

func (LogEntries) DetachSig

func (l LogEntries) DetachSig() string

DetachSig detaches the RSA signature from the last log entry and returns it

func (LogEntries) Hash

func (l LogEntries) Hash() ([]byte, error)

Hash returns the LogEntries' SHA256 hash

func (LogEntries) Len

func (l LogEntries) Len() int

Len is the number of LogEntries

func (LogEntries) Less

func (l LogEntries) Less(i, j int) bool

Less reports whether the LogEntry with index i should sort before the LogEntry with index j

func (LogEntries) Sign

func (l LogEntries) Sign(prv *rsa.PrivateKey) (string, error)

Sign signs the LogEntries using the given RSA private key and returns a base64 encoded RSA signature

func (LogEntries) Sort

func (l LogEntries) Sort()

Sort sorts the LogEntries in chronological order of its entries' timestamps

func (LogEntries) Swap

func (l LogEntries) Swap(i, j int)

Swap swaps the LogEntries with indexes i and j

func (LogEntries) Verify

func (l LogEntries) Verify(sigStr string, pub *rsa.PublicKey) error

Verify verifies the LogEntries's base64 encoded RSA signature with the given RSA public key

type LogEntry

type LogEntry struct {
	PDBMetadata  *provendb.Metadata     `json:"_provendb_metadata,omitempty" bson:"_provendb_metadata,omitempty"`
	Timestamp    time.Time              `json:"timestamp" bson:"timestamp"`
	Level        string                 `json:"level" bson:"level"`
	Message      string                 `json:"message" bson:"message"`
	Data         map[string]interface{} `json:"data,omitempty" bson:"data,omitempty"`
	RSASignature string                 `json:"_rsa_sig,omitempty" bson:"_rsa_sig,omitempty"`
}

LogEntry represents an internal log entry data structure

func (*LogEntry) Hash

func (l *LogEntry) Hash() ([]byte, error)

Hash returns the LogEntry's SHA256 hash

func (*LogEntry) Verify

func (l *LogEntry) Verify() error

Verify verifies the LogEntry's hash against the hash in its ProvenDB metadata

type Parser

type Parser interface {
	Parse(raw string) LogEntry
}

Parser represents a log parser

type Server

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

Server represents a ProvenLogs service instance

func NewServer

func NewServer(
	provenDBURI string,
	provenDBColName string,
	logger *zap.Logger,
	prvKeyPath string,
	batchTime time.Duration,
	batchSize int,
) *Server

NewServer creates a new singleton ProvenLogs service instance

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run runs the ProvenLogs service

type VerificationResult

type VerificationResult struct {
	RawLog                        string
	StoredLog                     string
	PubKeyPath                    string
	BatchVersion                  int64
	BatchSigHash                  string
	BatchSigProof                 string
	BatchSigBTCConfirmedTimestamp time.Time
	BatchSigBTCTxn                string
	BatchSigBTCBlock              string
}

VerificationResult represents a log entry's verification result

type Verifier

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

Verifier represents a ProvenLogs Verifier instance

func NewVerifier

func NewVerifier(
	ctx context.Context,
	provenDBURI string,
	provenDBColName string,
	pubKeyPath string,
) (*Verifier, error)

NewVerifier creates a new ProvenLogs Verifier

func (*Verifier) Verify

func (v *Verifier) Verify(
	ctx context.Context,
	raw string,
) (result *VerificationResult, er error)

Verify verifies the given raw log string

type ZapProductionParser

type ZapProductionParser struct {
	TimestampKey,
	LevelKey,
	MessageKey string
}

ZapProductionParser represents a parser for production logs from Zap logger

func NewZapProductionParser

func NewZapProductionParser() *ZapProductionParser

NewZapProductionParser creates a new parser for production Zap

func (*ZapProductionParser) Parse

func (p *ZapProductionParser) Parse(raw string) LogEntry

Parse parses the given raw log string into a log entry

Jump to

Keyboard shortcuts

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