util

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WatchNamespaceEnvVar    = "WATCH_NAMESPACE"
	OperatorNamespaceEnvVar = "OPERATOR_NAMESPACE"
	EnableWebHookEnvVar     = "ENABLE_WEBHOOK"
	EnableOtelEnvVar        = "ENABLE_OTEL"
	OtelCollectorUrlEnvVar  = "OTEL_EXPORTER_OTLP_ENDPOINT"
	OtelMetricPrefixEnvVar  = "OTEL_METRIC_PREFIX"
	HostNameEnvVar          = "HOSTNAME"
)
View Source
var ErrInvalidFileFormatError = errors.New("InvalidFileFormat")
View Source
var ErrInvalidTarArchive = errors.New("InvalidTarArchive")
View Source
var ErrInvalidZipArchive = errors.New("InvalidZipArchive")

Functions

func ApplyGraphmanBundle added in v1.0.2

func ApplyGraphmanBundle(username string, password string, target string, encpass string, bundle []byte) error

func ApplyToGraphmanTarget

func ApplyToGraphmanTarget(path string, secretBundle []byte, singleton bool, username string, password string, target string, encpass string) error

func BuildAndValidateBundle added in v1.0.4

func BuildAndValidateBundle(path string) ([]byte, error)

func BuildCWPBundle

func BuildCWPBundle(cwps []securityv1.Property) ([]byte, string, error)

func BuildCustomListenPortBundle

func BuildCustomListenPortBundle(gw *securityv1.Gateway, refreshOnKeyChanges bool) ([]byte, string, error)

func BuildDefaultListenPortBundle

func BuildDefaultListenPortBundle(refreshOnKeyChanges bool) ([]byte, string, error)

func BuildLayer7PolicyXml added in v1.0.4

func BuildLayer7PolicyXml(name string, gatewayHost string, fipId string) ([]byte, error)

func BuildOtkOverrideBundle added in v1.0.4

func BuildOtkOverrideBundle(mode string, gatewayHost string, otkPort int) ([]byte, string, error)

func CloneRepository

func CloneRepository(url string, username string, token string, privateKey []byte, privateKeyPass string, branch string, tag string, remoteName string, name string, vendor string, authType string, knownHosts []byte, namespace string) (string, error)

func CompressGraphmanBundle

func CompressGraphmanBundle(path string) ([]byte, error)

func ConcatBundles added in v1.1.0

func ConcatBundles(bundleMap map[string][]byte) ([]byte, error)

func Contains

func Contains(arr []string, str string) bool

Contains returns true if string array contains string

func ConvertCertsToGraphmanBundle added in v1.1.0

func ConvertCertsToGraphmanBundle(certs []GraphmanCert, notFound []string) ([]byte, error)

func ConvertOpaqueMapToGraphmanBundle added in v1.0.2

func ConvertOpaqueMapToGraphmanBundle(secrets []GraphmanSecret, notFound []string) ([]byte, error)

func ConvertX509ToGraphmanBundle added in v1.0.2

func ConvertX509ToGraphmanBundle(keys []GraphmanKey, notFound []string) ([]byte, error)

func DefaultLabels

func DefaultLabels(name string, additionalLabels map[string]string) map[string]string

func DownloadArtifact added in v1.0.4

func DownloadArtifact(URL string, username string, token string, name string, forceUpdate bool, namespace string) (string, error)

Download Artifact retrieves a compressed Graphman Bundle from an HTTP URL This is currently limited to URLs that contain the file extension as would be the case when targeting releases from Git releases. The following extensions are accepted .tar, .tar.gz, .zip

func GenerateSharedStateClientConfig added in v1.0.7

func GenerateSharedStateClientConfig(configType string, redisConfigs []RedisClientConfig, hazelcastConfigs interface{}) ([]byte, error)

Redis is currently the only supported shared state client that supports the new configuration.

func GetHostname added in v1.0.7

func GetHostname() (string, error)

func GetOperatorNamespace

func GetOperatorNamespace() (string, error)

GetOperatorNamespace returns the namespace of the operator pod

func GetOtelCollectorUrl added in v1.0.7

func GetOtelCollectorUrl() (string, error)

func GetOtelEnabled added in v1.0.7

func GetOtelEnabled() (bool, error)

func GetOtelMetricPrefix added in v1.0.7

func GetOtelMetricPrefix() (string, error)

func GetPortalAccessToken added in v1.0.4

func GetPortalAccessToken(name string, authServer string, clientId string, clientSecret string) (string, error)

func GetWatchNamespace

func GetWatchNamespace() (string, error)

GetWatchNamespace returns the namespace the operator should be watching for changes

func GetWebhookEnabled added in v1.0.4

func GetWebhookEnabled() (bool, error)

func InitOTelProvider added in v1.0.7

func InitOTelProvider(collectorURL string, ctx context.Context) (func(context.Context) error, error)

func RemoveL7API added in v1.0.4

func RemoveL7API(username string, password string, target string, apiName string, policyFragmentName string) error

func RestCall

func RestCall(method string, URL string, insecureSkipVerify bool, headers map[string]string, contentType string, data []byte, username string, password string) ([]byte, error)

func Untar added in v1.0.4

func Untar(folderName string, repoName string, tarStream io.Reader, gz bool) error

func Unzip

func Unzip(src string, dest string) error

Unzip will decompress a zip archive, moving all files and folders within the zip file (parameter 1) to an output directory (parameter 2).

Types

type AssertionComment added in v1.0.4

type AssertionComment struct {
	AssertionComment string            `xml:"assertionComment,attr"`
	Properties       MappingProperties `xml:"L7p:Properties"`
}

type AuthenticateAgainstIdpAssertion added in v1.0.4

type AuthenticateAgainstIdpAssertion struct {
	IdentityProviderOid IdentityProviderOid `xml:"L7p:IdentityProviderOid"`
}

type Bundle

type Bundle struct {
	XMLName    xml.Name   `xml:"l7:Bundle"`
	XMLNS      string     `xml:"xmlns:l7,attr"`
	References References `xml:"l7:References"`
	Mappings   Mappings   `xml:"l7:Mappings"`
}

type CachedSyncRequest added in v1.0.2

type CachedSyncRequest struct {
	SyncRequest
	// contains filtered or unexported fields
}

type CommentAssertion added in v1.0.4

type CommentAssertion struct {
	Comment CommentAssertionComment `xml:"L7p:Comment"`
}

type CommentAssertionComment added in v1.0.4

type CommentAssertionComment struct {
	StringValue string `xml:"stringValue,attr"`
}

type EncapsulatedAssertion added in v1.0.4

type EncapsulatedAssertion struct {
	AssertionComment                *AssertionComment `xml:"L7p:AssertionComment"`
	EncapsulatedAssertionConfigGuid PolicyStringValue `xml:"L7p:EncapsulatedAssertionConfigGuid"`
	EncapsulatedAssertionConfigName PolicyStringValue `xml:"L7p:EncapsulatedAssertionConfigName"`
	Parameters                      MappingProperties `xml:"L7p:Parameters"`
}

type GPolicy added in v1.0.4

type GPolicy struct {
	Xml string `json:"xml"`
}

type GraphmanCert added in v1.1.0

type GraphmanCert struct {
	Name                      string   `json:"name,omitempty"`
	Crt                       string   `json:"crt,omitempty"`
	TrustedFor                []string `json:"trustedFor,omitempty"`
	VerifyHostname            bool     `json:"verifyHostname,omitempty"`
	RevocationCheckPolicyType string   `json:"revocationCheckPolicyType,omitempty"`
	RevocationCheckPolicyName string   `json:"revocationCheckPolicyName,omitempty"`
	TrustAnchor               bool     `json:"trustAnchor,omitempty"`
}

type GraphmanKey added in v1.0.2

type GraphmanKey struct {
	Name      string `json:"name,omitempty"`
	Crt       string `json:"crt,omitempty"`
	Key       string `json:"key,omitempty"`
	Port      string `json:"port,omitempty"`
	Alias     string `json:"alias,omitempty"`
	UsageType string `json:"usageType,omitempty"`
}

type GraphmanOtkConfig added in v1.0.4

type GraphmanOtkConfig struct {
	Type                     string `json:"type,omitempty"`
	InternalGatewayReference string `json:"internalGatewayReference,omitempty"`
}

type GraphmanSecret added in v1.0.2

type GraphmanSecret struct {
	Name        string `json:"name,omitempty"`
	Secret      string `json:"secret,omitempty"`
	Description string `json:"description,omitempty"`

	VariableReferencable bool `json:"variableReferencable,omitempty"`
}

type HttpMapping added in v1.0.4

type HttpMapping struct {
	UrlPattern string `xml:"l7:UrlPattern"`
	Verbs      Verbs  `xml:"l7:Verbs"`
}

type IdentityProviderOid added in v1.0.4

type IdentityProviderOid struct {
	GoidValue string `xml:"goidValue,attr"`
}

type Item

type Item struct {
	Name     string   `xml:"l7:Name"`
	ID       string   `xml:"l7:Id"`
	Type     string   `xml:"l7:Type"`
	Resource Resource `xml:"l7:Resource"`
}

type Mapping

type Mapping struct {
	Action     string     `xml:"action,attr"`
	SrcId      string     `xml:"srcId,attr"`
	Type       string     `xml:"type,attr"`
	Properties Properties `xml:"l7:Properties"`
}

type MappingEntry added in v1.0.4

type MappingEntry struct {
	Key   PolicyStringValue `xml:"L7p:key"`
	Value PolicyStringValue `xml:"L7p:value"`
}

type MappingProperties added in v1.0.4

type MappingProperties struct {
	MapValue string         `xml:"mapValue,attr"`
	Entry    []MappingEntry `xml:"L7p:entry"`
}

type MappingSource added in v1.1.0

type MappingSource struct {
	Name           string `json:"name,omitempty"`
	Alias          string `json:"alias,omitempty"`
	KeystoreId     string `json:"keystoreId,omitempty"`
	ThumbprintSha1 string `json:"thumbprintSha1,omitempty"`
}

type Mappings

type Mappings struct {
	Mapping []Mapping `xml:"l7:Mapping"`
}

type OneOrMore added in v1.0.4

type OneOrMore struct {
	Text             string                          `xml:",chardata"`
	Usage            string                          `xml:"Usage,attr"`
	CommentAssertion *CommentAssertion               `xml:"L7p:CommentAssertion"`
	Authentication   AuthenticateAgainstIdpAssertion `xml:"L7p:Authentication"`
	Encapsulated     EncapsulatedAssertion           `xml:"L7p:Encapsulated"`
}

type Policy added in v1.0.4

type Policy struct {
	Guid         string       `xml:"guid,attr"`
	ID           string       `xml:"id,attr"`
	Version      string       `xml:"version,attr"`
	PolicyDetail PolicyDetail `xml:"l7:PolicyDetail"`

	Resources PolicyResources
}

type PolicyBody added in v1.0.4

type PolicyBody struct {
	Usage            string                  `xml:"wsp:Usage,attr"`
	CommentAssertion *CommentAssertion       `xml:"L7p:CommentAssertion"`
	SetVariable      *[]SetVariableAssertion `xml:"L7p:SetVariable"`
	OneOrMore        *OneOrMore              `xml:"wsp:OneOrMore"`
}

type PolicyDetail added in v1.0.4

type PolicyDetail struct {
	FolderId   string                 `xml:"folderId,attr"`
	Guid       string                 `xml:"guid,attr"`
	ID         string                 `xml:"id,attr"`
	Name       string                 `xml:"l7:Name"`
	PolicyType string                 `xml:"l7:PolicyType"`
	Properties PolicyDetailProperties `xml:"l7:Properties"`
}

type PolicyDetailProperties added in v1.0.4

type PolicyDetailProperties struct {
	Text     string `xml:",chardata"`
	Property []PolicyProperty
}

type PolicyProperty added in v1.0.4

type PolicyProperty struct {
	Text         string `xml:",chardata"`
	Key          string `xml:"key,attr"`
	LongValue    string `xml:"LongValue"`
	BooleanValue string `xml:"BooleanValue"`
}

type PolicyResource added in v1.0.4

type PolicyResource struct {
	Type string `xml:"type,attr"`
	Text string `xml:",chardata"`
}

type PolicyResourceSet added in v1.0.4

type PolicyResourceSet struct {
	Tag      string         `xml:"tag,attr"`
	Resource PolicyResource `xml:"l7:Resource"`
}

type PolicyResources added in v1.0.4

type PolicyResources struct {
	ResourceSet PolicyResourceSet `xml:"l7:ResourceSet"`
}

type PolicyStringValue added in v1.0.4

type PolicyStringValue struct {
	StringValue string `xml:"stringValue,attr"`
}

type PolicyXml added in v1.0.4

type PolicyXml struct {
	XMLName  xml.Name   `xml:"wsp:Policy"`
	XMLNSL7p string     `xml:"xmlns:L7p,attr"`
	XMLNSWsp string     `xml:"xmlns:wsp,attr"`
	All      PolicyBody `xml:"wsp:All"`
}

type PortalBundle added in v1.0.6

type PortalBundle struct {
	XMLName    xml.Name   `xml:"Bundle"`
	XMLNS      string     `xml:"xmlns:l7,attr"`
	References References `xml:"l7:References"`
	Mappings   Mappings   `xml:"l7:Mappings"`
}

type PortalPapiToken added in v1.0.4

type PortalPapiToken struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int    `json:"expires_in"`
	Scope       string `json:"scope"`
}

type Properties

type Properties struct {
	Property []Property `xml:"l7:Property"`
}

type Property

type Property struct {
	Key          string `xml:"key,attr"`
	StringValue  string `xml:"l7:StringValue,omitempty"`
	BooleanValue bool   `xml:"l7:BooleanValue,omitempty"`
}

type RedisClientConfig added in v1.0.7

type RedisClientConfig struct {
	Name               string        `yaml:"name,omitempty"`
	Type               string        `yaml:"type,omitempty"`
	CommandTimeout     int           `yaml:"commandTimeout,omitempty"`
	ConnectTimeout     int           `yaml:"connectTimeout,omitempty"`
	KeyPrefixGroupName string        `yaml:"keyPrefixGroupName,omitempty"`
	TestOnStart        bool          `yaml:"testOnStart"`
	Username           string        `yaml:"username,omitempty"`
	EncodedPassword    string        `yaml:"encodedPassword,omitempty"`
	Password           string        `yaml:"password,omitempty"`
	Standalone         RedisNode     `yaml:"standalone,omitempty"`
	Sentinel           RedisSentinel `yaml:"sentinel,omitempty"`
	Ssl                RedisSsl      `yaml:"ssl"`
}

type RedisConfigBlock added in v1.0.7

type RedisConfigBlock struct {
	Default RedisClientConfig `yaml:"default,omitempty"`
}

type RedisNode added in v1.0.7

type RedisNode struct {
	Host string `yaml:"host,omitempty"`
	Port int    `yaml:"port,omitempty"`
}

type RedisSentinel added in v1.0.7

type RedisSentinel struct {
	Master string      `yaml:"master,omitempty"`
	Nodes  []RedisNode `yaml:"nodes,omitempty"`
}

type RedisSsl added in v1.0.7

type RedisSsl struct {
	Enabled    bool   `yaml:"enabled"`
	Crt        string `yaml:"crt,omitempty"`
	VerifyPeer *bool  `yaml:"verifyPeer,omitempty"`
}

type References

type References struct {
	Item []Item `xml:"l7:Item"`
}

type Resource

type Resource struct {
	Policy  *Policy  `xml:"l7:Policy,omitempty"`
	Service *Service `xml:"l7:Service,omitempty"`
}

type Service added in v1.0.4

type Service struct {
	ID            string           `xml:"id,attr"`
	L7            string           `xml:"l7,attr"`
	ServiceDetail ServiceDetail    `xml:"l7:ServiceDetail"`
	Properties    ServiceProperty  `xml:"l7:Properties"`
	Resources     ServiceResources `xml:"l7:Resources"`
}

type ServiceDetail added in v1.0.4

type ServiceDetail struct {
	Text            string            `xml:",chardata"`
	FolderId        string            `xml:"folderId,attr"`
	ID              string            `xml:"id,attr"`
	Name            string            `xml:"l7:Name"`
	Enabled         bool              `xml:"l7:Enabled"`
	ServiceMappings ServiceMappings   `xml:"l7:ServiceMappings"`
	Properties      ServiceProperties `xml:"l7:Properties"`
}

type ServiceMappings added in v1.0.4

type ServiceMappings struct {
	HttpMapping HttpMapping
}

type ServiceProperties added in v1.0.4

type ServiceProperties struct {
	Property []ServiceProperty `xml:"l7:Property"`
}

type ServiceProperty added in v1.0.4

type ServiceProperty struct {
	Key          string `xml:"key,attr"`
	BooleanValue string `xml:"l7:BooleanValue"`
	StringValue  string `xml:"l7:StringValue"`
}

type ServiceResource added in v1.0.4

type ServiceResource struct {
	Text string `xml:",chardata"`
	Type string `xml:"type,attr"`
}

type ServiceResourceSet added in v1.0.4

type ServiceResourceSet struct {
	Tag      string          `xml:"tag,attr"`
	Resource ServiceResource `xml:"l7:Resource"`
}

type ServiceResources added in v1.0.4

type ServiceResources struct {
	ResourceSet ServiceResourceSet `xml:"l7:ResourceSet"`
}

type SetVariableAssertion added in v1.0.4

type SetVariableAssertion struct {
	AssertionComment AssertionComment  `xml:"L7p:AssertionComment"`
	Base64Expression PolicyStringValue `xml:"L7p:Base64Expression"`
	VariableToSet    PolicyStringValue `xml:"L7p:VariableToSet"`
}

type SharedStateClientConfigType added in v1.0.7

type SharedStateClientConfigType string
var (
	SharedStateClientConfigTypeRedis     SharedStateClientConfigType = "redis"
	SharedStateClientConfigTypeHazelcast SharedStateClientConfigType = "hazelcast"
)

type SyncCache added in v1.0.2

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

func NewSyncCache added in v1.0.2

func NewSyncCache(cleanupInterval time.Duration) *SyncCache

func (*SyncCache) Delete added in v1.0.2

func (sc *SyncCache) Delete(requestName string)

func (*SyncCache) Read added in v1.0.2

func (sc *SyncCache) Read(requestName string) (SyncRequest, error)

func (*SyncCache) Update added in v1.0.2

func (sc *SyncCache) Update(sr SyncRequest, expiryTimestamp int64)

type SyncRequest added in v1.0.2

type SyncRequest struct {
	RequestName string `json:"RequestName"`
	CacheData   string `json:"CacheData,omitempty"`
	Attempts    int    `json:"Attempts,omitempty"`
}

type Verbs added in v1.0.4

type Verbs struct {
	Verb []string `xml:"l7:Verb"`
}

Jump to

Keyboard shortcuts

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