util

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: BSD-3-Clause Imports: 19 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeCert added in v0.8.8

func EncodeCert(cert, signingCert *x509.Certificate, pubKey *ecdsa.PublicKey, signingKey *ecdsa.PrivateKey) ([]byte, error)

DER encode certificate

func EncodeKey added in v0.8.8

func EncodeKey(key *ecdsa.PrivateKey) ([]byte, error)

Encode private key

func GenerateLeafCertificate added in v0.8.8

func GenerateLeafCertificate(rootCert *x509.Certificate, rootKey *ecdsa.PrivateKey) (*x509.Certificate, *ecdsa.PrivateKey, error)

func GenerateRootCert added in v0.8.8

func GenerateRootCert() (cert *x509.Certificate, key *ecdsa.PrivateKey, err error)

func Log added in v0.6.4

func Log(format string, v ...interface{})

Log and flush stdout. To be used by plugins, so we can stream plugin output in CheckMate service

Types

type LineKeeper

type LineKeeper struct {
	EOLLocations []int // end-of-line locations
	// contains filtered or unexported fields
}

LineKeeper keeps track of line numberson a textual source file and can map character location to the relevant `code.Position`

func (*LineKeeper) GetPositionFromCharacterIndex

func (lk *LineKeeper) GetPositionFromCharacterIndex(pos int64) code.Position

GetPositionFromCharacterIndex returns the `code.Position` given the index of the character in the file

type PathConsumer

type PathConsumer interface {
	ConsumePath(path RepositoryIndexedFile)
	diagnostics.ExclusionProvider
}

PathConsumer is a sink for paths and URIs

type PathMultiplexer

type PathMultiplexer interface {
	SetPathConsumers(consumers ...PathConsumer)
	ConsumePath(path RepositoryIndexedFile)
}

PathMultiplexer interface defines an aggregator of analysers that can consume filesystem paths and URIs and process them

func NewPathMultiplexer

func NewPathMultiplexer(consumers ...PathConsumer) PathMultiplexer

NewPathMultiplexer creates a choreographer that orchestrates the consumption of paths by consumers

type PositionProvider

type PositionProvider interface {
	GetPosition(index int64) code.Position
}

PositionProvider provides a "global" view of code location, given an arbitrary character index.

type RepositoryIndexedFile added in v0.8.5

type RepositoryIndexedFile struct {
	RepositoryIndex int //repository index of the under which the file is found
	File            string
}

Provide repository index context for every file that is scanned In FindFiles(paths []string). The index of the paths is mapped to each file found during search

func FindFiles

func FindFiles(paths []string) []RepositoryIndexedFile

FindFiles recursively searches the directories and files contained in paths and returns a unique list of files

type ResourceConsumer

type ResourceConsumer interface {
	//Consume allows a source processor receive `source` data streamed in "chunks", with `startIndex` indicating the
	//character location of the first character in the stream
	Consume(startIndex int64, source string)
	//ConsumePath allows resource consumers that process filepaths directly to analyse files on disk
	ConsumePath(filePath RepositoryIndexedFile)
	SetLineKeeper(*LineKeeper)
	//ShouldProvideSourceInDiagnostics toggles whether source evidence should be provided with diagnostics, defaults to false
	ShouldProvideSourceInDiagnostics(bool)
	//used to signal to the consumer that the source stream has ended
	End()
}

ResourceConsumer is a sink for streaming source

type ResourceMultiplexer

type ResourceMultiplexer interface {
	//SetSource is the source reader to multiplex to multiple consumers, which will be provided with a copy of the source data as it is being streamed in from the source
	SetResourceAndConsumers(filePath RepositoryIndexedFile, source *io.Reader, provideSourceInDiagnostics bool, consumers ...ResourceConsumer)
}

ResourceMultiplexer interface defines a path or source reader that can be multiplexed to multiple consumers. It provides additional utility such as mapping a source index to the line and character, i.e. the `code.Position` in the source

func NewResourceMultiplexer

func NewResourceMultiplexer(filePath RepositoryIndexedFile, source *io.Reader, provideSource bool, consumers ...ResourceConsumer) ResourceMultiplexer

NewResourceMultiplexer creates a source multiplexer over an input reader

type UUID

type UUID [16]byte

func NewRandomUUID

func NewRandomUUID() UUID

func (UUID) String

func (uuid UUID) String() string

String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx , or "" if uuid is invalid.

Jump to

Keyboard shortcuts

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