fetchers

package
v0.0.0-...-5988697 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearDiscoveryCache

func ClearDiscoveryCache()

ClearDiscoveryCache clears the discovery cache (useful for testing)

func FileExists

func FileExists(path string) bool

FileExists checks if a file exists

func GetFileInfo

func GetFileInfo(path string) (os.FileInfo, error)

GetFileInfo returns file information

func GetGVK

GetGVK returns the GroupVersionKind for a Kubernetes input spec using dynamic discovery

func GetGVKWithConfig

GetGVKWithConfig returns the GroupVersionKind using configuration and discovery

func IsDirectory

func IsDirectory(path string) bool

IsDirectory checks if a path is a directory

func IsNamespaced

func IsNamespaced(spec scanner.KubernetesInputSpec) bool

IsNamespaced returns true if the resource is namespaced using dynamic discovery

func IsNamespacedWithConfig

func IsNamespacedWithConfig(spec scanner.KubernetesInputSpec, discoveryClient discovery.DiscoveryInterface, config *ResourceMappingConfig) bool

IsNamespacedWithConfig returns true if the resource is namespaced using configuration and discovery

func IsNamespacedWithDiscovery

func IsNamespacedWithDiscovery(spec scanner.KubernetesInputSpec, discoveryClient discovery.DiscoveryInterface) bool

IsNamespacedWithDiscovery returns true if the resource is namespaced using API discovery

func ListDirectories

func ListDirectories(dirPath string) ([]string, error)

ListDirectories lists directories in a directory

func ListFiles

func ListFiles(dirPath string) ([]string, error)

ListFiles lists files in a directory (non-recursively)

func ReadFileAsString

func ReadFileAsString(path string) (string, error)

ReadFileAsString reads a file as a string

func ValidateFileInputSpec

func ValidateFileInputSpec(spec scanner.FileInputSpec) error

ValidateFileInputSpec validates a file input specification

func ValidateKubernetesInputSpec

func ValidateKubernetesInputSpec(spec scanner.KubernetesInputSpec) error

ValidateKubernetesInputSpec validates a Kubernetes input specification

func ValidateKubernetesInputSpecWithDiscovery

func ValidateKubernetesInputSpecWithDiscovery(spec scanner.KubernetesInputSpec, discoveryClient discovery.DiscoveryInterface) error

ValidateKubernetesInputSpecWithDiscovery validates a Kubernetes input specification using API discovery

Types

type CelVariable

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

CelVariable implements CelVariable interface for conversion

func (*CelVariable) GroupVersionKind

func (v *CelVariable) GroupVersionKind() schema.GroupVersionKind

func (*CelVariable) Name

func (v *CelVariable) Name() string

func (*CelVariable) Namespace

func (v *CelVariable) Namespace() string

func (*CelVariable) Value

func (v *CelVariable) Value() string

type CompositeFetcher

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

CompositeFetcher implements InputFetcher by delegating to specialized fetchers

func NewCompositeFetcher

func NewCompositeFetcher() *CompositeFetcher

NewCompositeFetcher creates a new composite input fetcher with default implementations

func NewCompositeFetcherWithDefaults

func NewCompositeFetcherWithDefaults(
	kubeClient runtimeclient.Client,
	kubeClientset kubernetes.Interface,
	apiResourcePath string,
	filesystemBasePath string,
	allowArbitraryCommands bool,
) *CompositeFetcher

NewCompositeFetcherWithDefaults creates a composite fetcher with default implementations

func (*CompositeFetcher) FetchInputs

func (c *CompositeFetcher) FetchInputs(inputs []scanner.Input, variables []scanner.CelVariable) (map[string]interface{}, error)

FetchInputs retrieves inputs by delegating to appropriate specialized fetchers

func (*CompositeFetcher) FetchResources

func (c *CompositeFetcher) FetchResources(ctx context.Context, rule scanner.Rule, variables []scanner.CelVariable) (map[string]interface{}, []string, error)

FetchResources implements the ResourceFetcher interface using the new unified API

func (*CompositeFetcher) GetSupportedInputTypes

func (c *CompositeFetcher) GetSupportedInputTypes() []scanner.InputType

GetSupportedInputTypes returns all supported input types

func (*CompositeFetcher) RegisterCustomFetcher

func (c *CompositeFetcher) RegisterCustomFetcher(inputType scanner.InputType, fetcher scanner.InputFetcher)

RegisterCustomFetcher registers a custom fetcher for a specific input type

func (*CompositeFetcher) SetFilesystemFetcher

func (c *CompositeFetcher) SetFilesystemFetcher(fetcher *FilesystemFetcher)

SetFilesystemFetcher sets the filesystem fetcher

func (*CompositeFetcher) SetKubernetesFetcher

func (c *CompositeFetcher) SetKubernetesFetcher(fetcher *KubernetesFetcher)

SetKubernetesFetcher sets the Kubernetes fetcher

func (*CompositeFetcher) SupportsInputType

func (c *CompositeFetcher) SupportsInputType(inputType scanner.InputType) bool

SupportsInputType returns true if any registered fetcher supports the input type

func (*CompositeFetcher) ValidateInputs

func (c *CompositeFetcher) ValidateInputs(inputs []scanner.Input) error

ValidateInputs validates all inputs are supported

type CompositeFetcherBuilder

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

CompositeFetcherBuilder helps build composite fetchers

func NewCompositeFetcherBuilder

func NewCompositeFetcherBuilder() *CompositeFetcherBuilder

NewCompositeFetcherBuilder creates a new builder

func (*CompositeFetcherBuilder) Build

Build returns the configured composite fetcher

func (*CompositeFetcherBuilder) WithCustomFetcher

func (b *CompositeFetcherBuilder) WithCustomFetcher(inputType scanner.InputType, fetcher scanner.InputFetcher) *CompositeFetcherBuilder

WithCustomFetcher adds a custom fetcher

func (*CompositeFetcherBuilder) WithFilesystem

func (b *CompositeFetcherBuilder) WithFilesystem(basePath string) *CompositeFetcherBuilder

WithFilesystem configures filesystem support

func (*CompositeFetcherBuilder) WithKubernetes

WithKubernetes configures Kubernetes support

func (*CompositeFetcherBuilder) WithKubernetesFiles

func (b *CompositeFetcherBuilder) WithKubernetesFiles(apiResourcePath string) *CompositeFetcherBuilder

WithKubernetesFiles configures Kubernetes support with file-based resources

type FilesystemFetcher

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

FilesystemFetcher implements InputFetcher for file system resources

func NewFilesystemFetcher

func NewFilesystemFetcher(basePath string) *FilesystemFetcher

NewFilesystemFetcher creates a new filesystem input fetcher

func (*FilesystemFetcher) FetchInputs

func (f *FilesystemFetcher) FetchInputs(inputs []scanner.Input, variables []scanner.CelVariable) (map[string]interface{}, error)

FetchInputs retrieves file system resources for the specified inputs

func (*FilesystemFetcher) SupportsInputType

func (f *FilesystemFetcher) SupportsInputType(inputType scanner.InputType) bool

SupportsInputType returns true for file input types

type KubernetesFetcher

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

KubernetesFetcher implements InputFetcher for Kubernetes resources

func NewKubernetesFetcher

func NewKubernetesFetcher(client runtimeclient.Client, clientset kubernetes.Interface) *KubernetesFetcher

NewKubernetesFetcher creates a new Kubernetes input fetcher

func NewKubernetesFileFetcher

func NewKubernetesFileFetcher(apiResourcePath string) *KubernetesFetcher

NewKubernetesFileFetcher creates a fetcher that reads from pre-fetched files

func (*KubernetesFetcher) FetchInputs

func (k *KubernetesFetcher) FetchInputs(inputs []scanner.Input, variables []scanner.CelVariable) (map[string]interface{}, error)

FetchInputs retrieves Kubernetes resources for the specified inputs

func (*KubernetesFetcher) GetResourceScope

func (k *KubernetesFetcher) GetResourceScope(spec scanner.KubernetesInputSpec) bool

GetResourceScope returns the scope of a resource (namespaced or cluster-scoped) using API discovery

func (*KubernetesFetcher) SupportsInputType

func (k *KubernetesFetcher) SupportsInputType(inputType scanner.InputType) bool

SupportsInputType returns true for Kubernetes input types

func (*KubernetesFetcher) ValidateInputSpec

func (k *KubernetesFetcher) ValidateInputSpec(spec scanner.KubernetesInputSpec) error

ValidateInputSpec validates a Kubernetes input specification using the fetcher's discovery client

func (*KubernetesFetcher) WithConfig

WithConfig allows customization of the fetcher configuration

type ResourceDiscoveryCache

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

ResourceDiscoveryCache caches resource discovery information

type ResourceMappingConfig

type ResourceMappingConfig struct {
	// CustomKindMappings allows override of resource type to Kind mappings
	CustomKindMappings map[string]string
	// CustomScopeMappings allows override of resource scope (true=namespaced, false=cluster-scoped)
	CustomScopeMappings map[schema.GroupVersionKind]bool
}

ResourceMappingConfig allows customization of resource mappings

func DefaultResourceMappingConfig

func DefaultResourceMappingConfig() *ResourceMappingConfig

DefaultResourceMappingConfig returns a default configuration

func LoadResourceMappingsFromFile

func LoadResourceMappingsFromFile(filePath string) (*ResourceMappingConfig, error)

LoadResourceMappingsFromFile loads custom resource mappings from a JSON file

Jump to

Keyboard shortcuts

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