Documentation
¶
Overview ¶
Package providerkit provides shared helpers used by integration definition implementations which assist in building consistent and robust integrations while reducing boilerplate
Index ¶
- Constants
- Variables
- func CelMapExpr(entries ...entityops.MappingEntry) string
- func CheckResultMapping(mapExpr string) types.MappingRegistration
- func DirectoryAccountPayloadSets(accounts []types.MappingEnvelope) []types.IngestPayloadSet
- func DirectoryGroupPayloadSets(groups, memberships []types.MappingEnvelope, complete bool) []types.IngestPayloadSet
- func DirectoryIngestContracts() []types.IngestContract
- func DirectoryMappings(accountExpr, groupExpr, membershipExpr string) []types.MappingRegistration
- func EdgeExternalIDEntry(schema *entityops.Schema, edge, expr string) entityops.MappingEntry
- func EdgeExternalIDKey(schema *entityops.Schema, edge string) string
- func EdgeKeyLinks(schema *entityops.Schema, edges ...string) []types.LinkRule
- func EncodeResult(value any, encodeErr error) (json.RawMessage, error)
- func EvalFilter(ctx context.Context, expr string, envelope types.MappingEnvelope, ...) (bool, error)
- func EvalMap(ctx context.Context, expr string, envelope types.MappingEnvelope, ...) (json.RawMessage, error)
- func FindingMapping(mapExpr string) types.MappingRegistration
- func GoogleTokenSource(ctx context.Context, clientID, clientSecret string, token *oauth2.Token) oauth2.TokenSource
- func MarshalEnvelope(resource string, payload any, encodeErr error) (types.MappingEnvelope, error)
- func MarshalEnvelopeVariant(variant string, resource string, payload any, encodeErr error) (types.MappingEnvelope, error)
- func OAuthToken(accessToken, refreshToken string, expiry *time.Time) *oauth2.Token
- func RawEnvelope(resource string, payload json.RawMessage) types.MappingEnvelope
- func RawEnvelopeVariant(variant string, resource string, payload json.RawMessage) types.MappingEnvelope
- func RawEnvelopeWithFields(resource string, payload json.RawMessage, fields map[string]any, ...) (types.MappingEnvelope, error)
- func RiskMapping(mapExpr string) types.MappingRegistration
- func UpgradeFromSection[T any](key string) ...
- func ValidateExpr(expr string) error
- func VulnerabilityMapping(mapExpr string) types.MappingRegistration
- type DirectorySync
Constants ¶
const (
// ExprInstallationName is the map expression yielding the writing installation's name
ExprInstallationName = celVarInstallation + ".name"
)
Variables ¶
var ( // ErrFilterExprEval is returned when a filter CEL expression fails during evaluation ErrFilterExprEval = errors.New("filter expression evaluation failed") // ErrMapExprEval is returned when a map CEL expression fails during evaluation ErrMapExprEval = errors.New("map expression evaluation failed") )
Functions ¶
func CelMapExpr ¶
func CelMapExpr(entries ...entityops.MappingEntry) string
CelMapExpr renders field-descriptor mapping entries into a CEL object literal string
func CheckResultMapping ¶
func CheckResultMapping(mapExpr string) types.MappingRegistration
CheckResultMapping returns the check result mapping linking check results to controls whose ref code is in the tags
func DirectoryAccountPayloadSets ¶
func DirectoryAccountPayloadSets(accounts []types.MappingEnvelope) []types.IngestPayloadSet
DirectoryAccountPayloadSets wraps directory account envelopes in a complete-snapshot payload set
func DirectoryGroupPayloadSets ¶
func DirectoryGroupPayloadSets(groups, memberships []types.MappingEnvelope, complete bool) []types.IngestPayloadSet
DirectoryGroupPayloadSets wraps group and membership envelopes with one completeness flag
func DirectoryIngestContracts ¶
func DirectoryIngestContracts() []types.IngestContract
DirectoryIngestContracts returns ingest contracts for directory accounts, groups, and memberships
func DirectoryMappings ¶
func DirectoryMappings(accountExpr, groupExpr, membershipExpr string) []types.MappingRegistration
DirectoryMappings returns account, group, and membership mappings linked by external id
func EdgeExternalIDEntry ¶
func EdgeExternalIDEntry(schema *entityops.Schema, edge, expr string) entityops.MappingEntry
EdgeExternalIDEntry binds a CEL expression producing the external ids schema's edge links to
func EdgeExternalIDKey ¶
EdgeExternalIDKey is the payload key EdgeKeyLinks reads the external ids schema's edge links to from
func EdgeKeyLinks ¶
EdgeKeyLinks returns a link rule for every edge of schema through each match key its target supports, external id and name, reading the values from a payload key named after the edge: <edge>_external_id(s) and <edge>_name(s), the singular key for a unique edge and the plural key for a to-many edge. When edges are given only those edges are linked
func EncodeResult ¶
func EncodeResult(value any, encodeErr error) (json.RawMessage, error)
EncodeResult serializes an operation result, mapping encode failure to the caller's error
func EvalFilter ¶
func EvalFilter(ctx context.Context, expr string, envelope types.MappingEnvelope, installation types.MappingInstallation) (bool, error)
EvalFilter evaluates a CEL filter expression against a MappingEnvelope and the writing installation An empty expr returns true (pass-through). Returns false when the expression excludes the envelope, or a wrapped ErrFilterExprEval on evaluation failure
func EvalMap ¶
func EvalMap(ctx context.Context, expr string, envelope types.MappingEnvelope, installation types.MappingInstallation) (json.RawMessage, error)
EvalMap evaluates a CEL map expression against a MappingEnvelope and the writing installation and returns a JSON payload An empty expr returns the original envelope.Payload (pass-through) Returns a wrapped ErrMapExprEval on failure
func FindingMapping ¶
func FindingMapping(mapExpr string) types.MappingRegistration
FindingMapping returns the finding mapping linking findings to controls by ref code, assets by name and external id, and the internal owner identity holder by email
func GoogleTokenSource ¶
func GoogleTokenSource(ctx context.Context, clientID, clientSecret string, token *oauth2.Token) oauth2.TokenSource
GoogleTokenSource builds a token source refreshing against the Google endpoint
func MarshalEnvelope ¶
MarshalEnvelope serializes a provider payload into one mapping envelope
func MarshalEnvelopeVariant ¶
func MarshalEnvelopeVariant(variant string, resource string, payload any, encodeErr error) (types.MappingEnvelope, error)
MarshalEnvelopeVariant serializes a provider payload into a variant-specific mapping envelope
func OAuthToken ¶
OAuthToken builds a refreshable bearer token from stored OAuth credential material
func RawEnvelope ¶
func RawEnvelope(resource string, payload json.RawMessage) types.MappingEnvelope
RawEnvelope wraps an already-serialized provider payload in a mapping envelope
func RawEnvelopeVariant ¶
func RawEnvelopeVariant(variant string, resource string, payload json.RawMessage) types.MappingEnvelope
RawEnvelopeVariant wraps a serialized provider payload in a variant-specific mapping envelope
func RawEnvelopeWithFields ¶
func RawEnvelopeWithFields(resource string, payload json.RawMessage, fields map[string]any, encodeErr error) (types.MappingEnvelope, error)
RawEnvelopeWithFields wraps a serialized provider payload in a mapping envelope with the non-empty fields merged in, pruning empty values so mapping orValue fallbacks apply, mapping merge failure to the caller's error
func RiskMapping ¶
func RiskMapping(mapExpr string) types.MappingRegistration
RiskMapping returns the risk mapping linking assets by edge keys
func UpgradeFromSection ¶
func UpgradeFromSection[T any](key string) func(context.Context, types.InstallationRequest, string, json.RawMessage) (T, error)
UpgradeFromSection returns an upgrade decoding T from the object stored under key when present, else from the stored document; it reads main's client config section for an operation whose main key differs from its camelCase name
TODO: remove with the integration config column once every installation has been upgraded off main's client config
func ValidateExpr ¶
ValidateExpr parses and type-checks a CEL expression without evaluating it
func VulnerabilityMapping ¶
func VulnerabilityMapping(mapExpr string) types.MappingRegistration
VulnerabilityMapping returns the vulnerability mapping linking the internal owner to an identity holder by email and assets by edge keys
Types ¶
type DirectorySync ¶
type DirectorySync struct {
types.OperationSettings
// DisableGroupSync skips collecting groups and memberships, syncing only users
DisableGroupSync bool `` /* 134-byte string literal not displayed */
}
DirectorySync is the stored config of a directory sync operation that can skip groups and memberships; a directory without group sync declares its own DirectorySync embedding only types.OperationSettings