client_inventory

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthTypeIAM             = "IAM"
	AuthTypeSASL_SCRAM      = "SASL_SCRAM"
	AuthTypeTLS             = "TLS"
	AuthTypeUNAUTHENTICATED = "UNAUTHENTICATED"
	AuthTypeUNKNOWN         = "UNKNOWN"
)

Variables

View Source
var (
	ErrorUnableToParseKafkaApiLine = errors.New("unable to parse Kafka API line")
	ErrorUnableToParseTimestamp    = errors.New("unable to parse timestamp")
	ErrorUnsupportedLogLine        = errors.New("unsupported log line")
)
View Source
var (
	TimestampPattern     = regexp.MustCompile(`^\[([^\]]+)\]`)
	ApiKeyPattern        = regexp.MustCompile(`apiKey=([^,\)]+)`)
	ClientIdPattern      = regexp.MustCompile(`clientId=([^,\)]+)`)
	BrokerFetcherPattern = regexp.MustCompile(`broker-(\d+)-fetcher-(\d+)`)

	ProducerTopicPattern = regexp.MustCompile(`partitionSizes=\[(.+)-\d+=`)
	ConsumerTopicPattern = regexp.MustCompile(`FetchTopic\(topic='([^']+)'`)

	// IAM-specific pattern to extract ARN
	IAMPrincipalArnPattern = regexp.MustCompile(`principal:\[IAM\]:\[(arn:aws:[^\]]+)\]:`)
	// SASL_SCRAM-specific pattern to extract User:username
	SASLSCRAMPrincipalPattern = regexp.MustCompile(`principal:(User:[^ ]+)`)
	// TLS pattern - extract User:CN= and any additional certificate info (requires SSL protocol)
	TLSPrincipalPattern = regexp.MustCompile(`securityProtocol:SSL,principal:(User:CN=[^(]+?)\s*\(`)
	// Anonymous pattern - detect unauthenticated requests with User:ANONYMOUS
	AnonymousPrincipalPattern = regexp.MustCompile(`principal:(User:ANONYMOUS)`)
)
View Source
var (
	// lines that match this pattern will be parsed by kafka trace line parser
	KafkaApiTracePattern = regexp.MustCompile(`^\[.*\] TRACE \[KafkaApi-\d+\].*\(kafka\.server\.KafkaApis\)$`)
)

Functions

func NewScanClientInventoryCmd

func NewScanClientInventoryCmd() *cobra.Command

Types

type ClientInventoryScanner

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

func NewClientInventoryScanner

func NewClientInventoryScanner(s3Service S3Service, opts ClientInventoryScannerOpts) (*ClientInventoryScanner, error)

func (*ClientInventoryScanner) Run

func (cis *ClientInventoryScanner) Run() error

type ClientInventoryScannerOpts

type ClientInventoryScannerOpts struct {
	S3Uri  string
	Region string
}

type KafkaApiTraceLineParser

type KafkaApiTraceLineParser struct{}

func (*KafkaApiTraceLineParser) Parse

func (p *KafkaApiTraceLineParser) Parse(line string, lineNumber int, fileName string) (*RequestMetadata, error)

type RequestMetadata

type RequestMetadata struct {
	CompositeKey string
	ClientId     string
	Topic        string
	Role         string
	Principal    string
	Auth         string
	ApiKey       string
	Timestamp    time.Time
}

type S3Service

type S3Service interface {
	ParseS3URI(s3Uri string) (string, string, error)
	ListLogFiles(ctx context.Context, bucket, prefix string) ([]string, error)
	DownloadAndDecompressLogFile(ctx context.Context, bucket, key string) ([]byte, error)
}

Jump to

Keyboard shortcuts

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