ports

package
v0.3.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package ports defines interfaces for infrastructure dependencies. CapabilityInfo contains metadata about a capability request. This is placed in ports to avoid circular imports between services and ports.

Package ports defines interfaces for infrastructure dependencies. These are the "ports" in hexagonal architecture - abstractions that the application layer depends on but doesn't implement.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CapabilityAnalyzer

type CapabilityAnalyzer interface {
	ExtractCapabilities(profile entities.ProfileReader) map[string][]capabilities.Capability
}

CapabilityAnalyzer extracts specific capability requirements from profiles. This allows the orchestrator to be tested with mock analyzers.

type CapabilityCollector

type CapabilityCollector interface {
	CollectRequiredCapabilities(ctx context.Context, profile entities.ProfileReader, runtime PluginRuntime, pluginDir string) (map[string][]capabilities.Capability, error)
}

CapabilityCollector collects required capabilities from plugins.

type CapabilityGatekeeperPort

type CapabilityGatekeeperPort interface {
	GrantCapabilities(
		required capabilities.Grant,
		capabilityInfo map[string]CapabilityInfo,
		trustAll bool,
	) (capabilities.Grant, error)
}

CapabilityGatekeeperPort grants capabilities based on security policy. Named with "Port" suffix to avoid collision with the concrete CapabilityGatekeeper type.

type CapabilityGranter

type CapabilityGranter interface {
	GrantCapabilities(ctx context.Context, required map[string][]capabilities.Capability, trustAll bool) (map[string][]capabilities.Capability, error)
}

CapabilityGranter grants capabilities (interactively or automatically).

type CapabilityInfo

type CapabilityInfo struct {
	ProfileSpecific *capabilities.Capability
	Capability      capabilities.Capability
	PluginName      string
	IsProfileBased  bool
	IsBroad         bool
}

CapabilityInfo contains metadata about a capability request.

type Closer

type Closer interface {
	io.Closer
}

Closer is a common interface for resources that need cleanup.

type EngineFactory

type EngineFactory interface {
	CreateEngine(ctx context.Context, profile entities.ProfileReader, grantedCaps map[string][]capabilities.Capability, pluginDir string, filters dto.FilterOptions, execution dto.ExecutionOptions, skipSchemaValidation bool) (ExecutionEngine, error)
}

EngineFactory creates execution engines with capabilities.

type ExecutionEngine

type ExecutionEngine interface {
	Execute(ctx context.Context, profile entities.ProfileReader) (*execution.ExecutionResult, error)
	Close(ctx context.Context) error
}

ExecutionEngine executes profiles and returns results.

type FormatterOptions

type FormatterOptions struct {
	ProfilePath string // For SARIF: reference to profile location
	Indent      bool   // For JSON: pretty-print with indentation
}

FormatterOptions configures formatter behavior.

type LockfileRepository

type LockfileRepository interface {
	// Load reads a lockfile from the given path.
	// Returns nil, nil if lockfile doesn't exist.
	Load(ctx context.Context, path string) (*entities.Lockfile, error)

	// Save writes a lockfile to the given path.
	Save(ctx context.Context, lockfile *entities.Lockfile, path string) error

	// Exists checks if a lockfile exists at the given path.
	Exists(ctx context.Context, path string) (bool, error)
}

LockfileRepository handles lockfile persistence. This is a PORT - abstracts file system or other storage.

SOLID: Interface Segregation - focused only on lockfile I/O

type OutputFormatter

type OutputFormatter interface {
	Format(result *execution.ExecutionResult) error
}

OutputFormatter formats execution results.

type OutputFormatterFactory

type OutputFormatterFactory interface {
	// Create returns a formatter for the given format name.
	// Returns error if format is unknown.
	Create(format string, writer io.Writer, options FormatterOptions) (OutputFormatter, error)

	// SupportedFormats returns list of available format names.
	SupportedFormats() []string
}

OutputFormatterFactory creates formatters by name.

type OutputWriter

type OutputWriter interface {
	Write(ctx context.Context, data []byte, dest string) error
}

OutputWriter writes formatted output to destination.

type Plugin

type Plugin interface {
	// Describe returns plugin metadata including declared capabilities.
	Describe(ctx context.Context) (*PluginInfo, error)
}

Plugin represents a loaded WASM plugin that can be inspected and executed. This interface abstracts the concrete wasm.Plugin implementation.

type PluginDigester

type PluginDigester interface {
	// DigestBytes computes SHA-256 of raw bytes.
	DigestBytes(data []byte) string

	// DigestFile computes SHA-256 of a file.
	DigestFile(ctx context.Context, path string) (string, error)
}

PluginDigester computes digests for plugins. Separate from VersionResolver per Interface Segregation.

type PluginDirectoryResolver

type PluginDirectoryResolver interface {
	ResolvePluginDir(ctx context.Context) (string, error)
}

PluginDirectoryResolver resolves the plugin directory path.

type PluginInfo

type PluginInfo struct {
	Name         string
	Version      string
	Description  string
	Capabilities []capabilities.Capability
}

PluginInfo contains metadata about a plugin. This is the application-layer representation of plugin metadata.

type PluginRuntime

type PluginRuntime interface {
	// LoadPlugin compiles and caches a plugin from WASM bytes.
	LoadPlugin(ctx context.Context, name string, wasmBytes []byte) (Plugin, error)

	// Close releases runtime resources.
	Close(ctx context.Context) error
}

PluginRuntime abstracts the WASM runtime for plugin loading and management. This interface allows the application layer to work with plugins without depending on concrete infrastructure types like wasm.Runtime.

type PluginRuntimeFactory

type PluginRuntimeFactory interface {
	// NewRuntime creates a new plugin runtime for capability collection.
	NewRuntime(ctx context.Context) (PluginRuntime, error)

	// NewRuntimeWithCapabilities creates a runtime with granted capabilities.
	NewRuntimeWithCapabilities(
		ctx context.Context,
		caps map[string][]capabilities.Capability,
		memoryLimitMB int,
	) (PluginRuntime, error)
}

PluginRuntimeFactory creates runtime instances. This allows the application layer to create runtimes without importing infrastructure.

type ProfileLoader

type ProfileLoader interface {
	LoadProfile(path string) (*entities.Profile, error)
}

ProfileLoader loads profiles from storage.

type ProfileValidator

type ProfileValidator interface {
	Validate(profile *entities.Profile) error
	ValidateWithSchemas(ctx context.Context, profile *entities.Profile, runtime PluginRuntime) error
}

ProfileValidator validates profile structure and schemas.

type SecretResolver

type SecretResolver interface {
	// Resolve returns the secret value by name.
	// The resolved value is automatically tracked for redaction.
	Resolve(name string) (string, error)
}

SecretResolver resolves named secrets for profile interpolation. Implementations automatically track resolved values for redaction.

type SensitiveValueProvider

type SensitiveValueProvider interface {
	// Track registers a sensitive value to be protected (redacted).
	Track(value string)

	// AllValues returns all tracked sensitive values.
	AllValues() []string
}

SensitiveValueProvider tracks and provides all sensitive values for protection. This is a PORT - the application defines what it needs, infrastructure provides it.

type SystemConfigProvider

type SystemConfigProvider interface {
	LoadConfig(ctx context.Context, path string) (*system.Config, error)
}

SystemConfigProvider loads system configuration.

type VersionResolver

type VersionResolver interface {
	// Resolve converts a version constraint to an exact version.
	// Examples:
	//   "@1.0"   -> "1.0.x" (latest 1.0.x)
	//   "^1.2.0" -> "1.x.x >= 1.2.0"
	//   "~1.2.3" -> "1.2.x >= 1.2.3"
	Resolve(constraint string, available []string) (string, error)
}

VersionResolver resolves semver version constraints to exact versions. This is a PORT - application defines what it needs, infrastructure provides how.

SOLID: Interface Segregation - focused only on version resolution

Jump to

Keyboard shortcuts

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