audit

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LogName is the auditing log name to use. This is the name that comes up
	// for "gcloud logging logs list".
	LogName = "cip-audit-log"
)

Variables

This section is empty.

Functions

func GetMatchingSourceRegistries

func GetMatchingSourceRegistries(
	manifests []reg.Manifest,
	gcrPayload reg.GCRPubSubPayload,
) ([]reg.RegistryContext, error)

GetMatchingSourceRegistries gets the first source repository that matches the image information inside a GCRPubSubPayload.

func ParsePubSubMessage

func ParsePubSubMessage(body io.Reader) (*reg.GCRPubSubPayload, error)

ParsePubSubMessage parses an HTTP request body into a reg.GCRPubSubPayload.

func ParsePubSubMessageBody

func ParsePubSubMessageBody(
	body []byte,
) (*reg.GCRPubSubPayload, error)

ParsePubSubMessageBody parses the body of an HTTP request to be a GCRPubSubPayload.

func ValidatePayload

func ValidatePayload(gcrPayload *reg.GCRPubSubPayload) error

ValidatePayload ensures that the payload is well-formed, per our business-logic needs.

Types

type GcrReadingFacility

type GcrReadingFacility struct {
	ReadRepo         func(*reg.SyncContext, reg.RegistryContext) stream.Producer
	ReadManifestList func(*reg.SyncContext, reg.GCRManifestListContext) stream.Producer
}

GcrReadingFacility holds functions used to create streams for reading the repository and manifest list.

nolint[lll]

type PubSubMessage

type PubSubMessage struct {
	Message      PubSubMessageInner `json:"message"`
	Subscription string             `json:"subscription"`
}

PubSubMessage is the payload of a Pub/Sub event.

type PubSubMessageInner

type PubSubMessageInner struct {
	Data []byte `json:"data,omitempty"`
	ID   string `json:"id"`
}

PubSubMessageInner is the inner struct that holds the actual Pub/Sub information.

type ServerContext

type ServerContext struct {
	ID                     string
	RemoteManifestFacility remotemanifest.Facility
	ErrorReportingFacility report.ReportingFacility
	LoggingFacility        logclient.LoggingFacility
	GcrReadingFacility     GcrReadingFacility
}

ServerContext holds all of the initialization data for the server to start up.

func InitRealServerContext

func InitRealServerContext(
	gcpProjectID, repoURLStr, branch, path, uuid string,
) (*ServerContext, error)

InitRealServerContext creates a ServerContext with facilities that are meant for production use (going over the network to fetch actual official promoter manifests from GitHub, for example).

func (*ServerContext) Audit

func (s *ServerContext) Audit(w http.ResponseWriter, r *http.Request)

Audit receives and processes a Pub/Sub push message. It has 3 parts: (1) parse the request body to understand the GCR state change, (2) update the Git repo of the promoter manifests, and (3) reconcile these two against each other. nolint[funlen]

func (*ServerContext) RunAuditor

func (s *ServerContext) RunAuditor()

RunAuditor runs an HTTP server.

Jump to

Keyboard shortcuts

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