auditlog

package
v0.0.0-...-dcbe3c4 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package auditlog implements 3rd-party auditlog service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditDB

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

AuditDB audit db

func NewDB

func NewDB(ctx context.Context, addr, dbName, user, pwd,
	normalLogColName, logColName, taskColName string) (b *AuditDB, err error)

NewDB new db

func (*AuditDB) Close

func (b *AuditDB) Close(ctx context.Context)

Close close db connection

type Log

type Log struct {
	ID    primitive.ObjectID `bson:"_id,omitempty" json:"-"`
	Level string             `bson:"level" json:"level"`
	// DeployEnv where the log from
	DeployEnv   string    `bson:"deploy_env" json:"deploy_env"`
	Time        time.Time `bson:"time" json:"time"`
	Logger      string    `bson:"logger" json:"logger"`
	Caller      string    `bson:"caller" json:"caller"`
	Msg         string    `bson:"msg" json:"msg"`
	ClusterUUID string    `bson:"cluster_uuid" json:"cluster_uuid"`
	// Ts used for generate signature
	Ts        string `bson:"ts" json:"ts"`
	CertChain string `bson:"cert_chain" json:"cert_chain"`
	// Signature generated by RSASHA256(msg + l.clusterUUID + ts)
	Signature string `bson:"signature" json:"signature"`
	// Verified if signature is valid
	Verified bool   `bson:"verified" json:"verified"`
	UUID     string `bson:"uuid" json:"uuid"`
}

Log for audit log

Example

	{
		"level": "info",
		"time": "2023-08-01T09:09:34.377Z",
		"logger": "pki.pki-audit",
		"caller": "audit/log.go:61",
		"msg": "yahoo",
		"cluster_uuid": "63760a3b-2f53-11ee-b5a4-5c6f69c1c020",
		"uuid": "63760a3b-2f53-11ee-b5a4-5c6f69c1c123",
		"ts": "2023-08-01T09:09:28Z",
		"cert_chain": "-----BEGIN CERTIFICATE-xxx",
        "signature": "3282c1160a47c84xxx"
	}

func (*Log) ValidFormat

func (l *Log) ValidFormat() (err error)

ValidFormat check log format and Signature

func (*Log) ValidRootCA

func (l *Log) ValidRootCA(rootcaPool *x509.CertPool) (err error)

check cert chain must be signed by rootca

type Task

type Task struct {
	ID   primitive.ObjectID `bson:"_id,omitempty" json:"-"`
	Type TaskType           `bson:"type" json:"type"`
	Data string             `bson:"data" json:"data"`
}

Task task for audit

type TaskType

type TaskType string

TaskType type of audit task

const (
	// TaskTypeClusterFingerprint check cluster fingerprint
	TaskTypeClusterFingerprint TaskType = "cluster_fingerprint"
)

func (TaskType) String

func (t TaskType) String() string

String convert TaskType to string

Jump to

Keyboard shortcuts

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