Documentation
¶
Overview ¶
Package validationmode provides the fail-closed, disposable host boundary used by production-engine validation scenarios.
Index ¶
- Constants
- Variables
- func NormalizeHKCU(key string) (string, error)
- func NormalizeProductionAuthoredPath(value string) string
- func ResolvePortablePath(root, portable string) (string, error)
- type Change
- type ChangeKind
- type Context
- func (context *Context) Activate() (func() error, error)
- func (context *Context) Descriptor() Descriptor
- func (context *Context) DisplayHostPath(absolute string, policy HostPathPolicy) (string, error)
- func (context *Context) DisplayPath(absolute string) (string, error)
- func (context *Context) GlobSandboxPattern(pattern string) ([]string, error)
- func (context *Context) GoString() string
- func (context *Context) MapHKCU(key string) (string, error)
- func (context *Context) NewPackageDriver() (*PackageDriver, error)
- func (context *Context) OriginalEnvironment(name string) (value string, set bool, managed bool)
- func (context *Context) OriginalHostPath(authored string, policy HostPathPolicy) (string, error)
- func (context *Context) RegistryNamespace() string
- func (context *Context) ResolveHostPath(authored string, policy HostPathPolicy) (string, error)
- func (context *Context) ResolveHostPattern(authored string, policy HostPathPolicy) (string, error)
- func (context *Context) Root() string
- func (context *Context) String() string
- func (context *Context) ValidateSandboxPath(absolute string) error
- func (context *Context) VirtualRoot(name string) (string, bool)
- type Descriptor
- type HostPathPolicy
- type Inventory
- type PackageDriver
- func (value *PackageDriver) Detect(ref string) (bool, string, error)
- func (value *PackageDriver) DetectBatch(refs []string) (map[string]driver.DetectResult, error)
- func (value *PackageDriver) DetectBatchSource(refs []string, source string) (map[string]driver.DetectResult, error)
- func (value *PackageDriver) DetectSource(ref, source string) (bool, string, error)
- func (value *PackageDriver) EnumerateInstalled() ([]driver.InstalledPackage, error)
- func (value *PackageDriver) ExternalCallCount() uint64
- func (value *PackageDriver) Install(ref string) (*driver.InstallResult, error)
- func (value *PackageDriver) InstallSource(ref, source string) (*driver.InstallResult, error)
- func (value *PackageDriver) InstallVersion(ref, version string) (*driver.InstallResult, error)
- func (value *PackageDriver) InstallVersionSource(ref, version, source string) (*driver.InstallResult, error)
- func (value *PackageDriver) Name() string
- func (value *PackageDriver) ReinstallVersion(ref, version string) (*driver.InstallResult, error)
- func (value *PackageDriver) ReinstallVersionSource(ref, version, source string) (*driver.InstallResult, error)
- func (value *PackageDriver) Uninstall(ref string) (*driver.UninstallResult, error)
- func (value *PackageDriver) UninstallSource(ref, source string) (*driver.UninstallResult, error)
- type ProtectedPath
- type ProtectedRegistry
- type RegistryChange
- type RegistryFixture
- func (*RegistryFixture) Cleanup() error
- func (*RegistryFixture) Materialize(string) error
- func (*RegistryFixture) ProveAbsent(string) error
- func (*RegistryFixture) Remove(string) error
- func (*RegistryFixture) Replace(string, RegistryState) error
- func (*RegistryFixture) Snapshot(string) (RegistryState, error)
- type RegistryGuard
- type RegistryKey
- type RegistryState
- type RegistryValue
- type WriteGuard
Constants ¶
const ( TestModeEnvironment = "ENDSTATE_TESTMODE" RootEnvironment = "ENDSTATE_ROOT" )
const ( RegistryTypeString uint32 = 1 RegistryTypeBinary uint32 = 3 RegistryTypeDWORD uint32 = 4 )
Variables ¶
var ( ErrInvalidActivation = errors.New("invalid validation-mode activation") ErrUnsafeRoot = errors.New("unsafe validation root") ErrInvalidDescriptor = errors.New("invalid validation-mode descriptor") ErrUnsafePath = errors.New("unsafe validation path") ErrUnsafeRegistry = errors.New("unsafe validation registry key") ErrPackageIdentity = errors.New("package identity is outside validation inventory") ErrInvalidState = errors.New("invalid validation package state") ErrGuardOverlap = errors.New("validation and protected paths overlap") ErrUnsafeGuardPath = errors.New("unsafe filesystem guard path") ErrGuardBudget = errors.New("validation guard budget exceeded") ErrGuardChanged = errors.New("protected validation target changed") )
Functions ¶
func NormalizeHKCU ¶
NormalizeHKCU validates and canonicalizes semantic current-user identity. PowerShell's HKCU:\ spelling is accepted only at this boundary.
func NormalizeProductionAuthoredPath ¶
NormalizeProductionAuthoredPath maps supported production home paths to the canonical declared alias form.
func ResolvePortablePath ¶
ResolvePortablePath resolves a portable payload or bundle path beneath an explicit existing root.
Types ¶
type Change ¶
type Change struct {
Path string
Kind ChangeKind
}
type ChangeKind ¶
type ChangeKind string
const ( ChangeCreated ChangeKind = "created" ChangeDeleted ChangeKind = "deleted" ChangeType ChangeKind = "type" ChangeContent ChangeKind = "content" )
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context contains validation authority. Its host paths are intentionally available only through methods and have no JSON or text representation.
func ActivateFromEnvironment ¶
ActivateFromEnvironment loads validation mode, creates its derived roots, installs their environment aliases, and returns an idempotent restoration.
func LoadFromEnvironment ¶
LoadFromEnvironment validates validation-mode authority without mutating the filesystem, environment, package state, or host. A nil context means inactive.
func (*Context) Activate ¶
Activate installs the already-loaded context's disposable environment aliases without rereading activation variables or descriptor authority.
func (*Context) Descriptor ¶
func (context *Context) Descriptor() Descriptor
Descriptor returns a defensive copy of the trusted descriptor.
func (*Context) DisplayHostPath ¶
func (context *Context) DisplayHostPath(absolute string, policy HostPathPolicy) (string, error)
DisplayHostPath uses explicit instance provenance when available; ordinary dynamic aliases retain their authored alias identity.
func (*Context) DisplayPath ¶
DisplayPath projects an absolute validation path to a non-sensitive token.
func (*Context) GlobSandboxPattern ¶
GlobSandboxPattern evaluates an already-expanded detector pattern only inside validation-owned virtual roots. Every returned match is canonical, link-free, and revalidated for containment before it can become production instance evidence.
func (*Context) NewPackageDriver ¶
func (context *Context) NewPackageDriver() (*PackageDriver, error)
NewPackageDriver opens or initializes the descriptor-bound disposable state.
func (*Context) OriginalEnvironment ¶
OriginalEnvironment returns the pre-activation value without making Context itself serializable or printable with host paths.
func (*Context) OriginalHostPath ¶
func (context *Context) OriginalHostPath(authored string, policy HostPathPolicy) (string, error)
OriginalHostPath transfers a validated authored suffix to the corresponding environment value captured before activation. Wildcards protect their non-wildcard parent prefix. Callers must never serialize the returned path.
func (*Context) RegistryNamespace ¶
RegistryNamespace returns the disposable HKCU namespace identity.
func (*Context) ResolveHostPath ¶
func (context *Context) ResolveHostPath(authored string, policy HostPathPolicy) (string, error)
ResolveHostPath resolves a Windows-authored path using only Context aliases.
func (*Context) ResolveHostPattern ¶
func (context *Context) ResolveHostPattern(authored string, policy HostPathPolicy) (string, error)
ResolveHostPattern resolves a capture-side host pattern through the same alias and instance authority as ResolveHostPath while retaining wildcard syntax for matching. The non-wildcard probe is resolved first, so traversal, unknown aliases, hardcoded paths, and linked parents fail closed.
func (*Context) ValidateSandboxPath ¶
ValidateSandboxPath accepts only link-free materialized paths under one validation virtual root or a narrowly owned engine runtime location.
type Descriptor ¶
type Descriptor struct {
SchemaVersion int `json:"schemaVersion"`
ScenarioID string `json:"scenarioId"`
Nonce string `json:"nonce"`
ModuleID string `json:"moduleId"`
Inventory Inventory `json:"inventory"`
DynamicRoots []string `json:"dynamicRoots,omitempty"`
}
Descriptor is the data-only authority for one validation scenario.
type HostPathPolicy ¶
type HostPathPolicy struct {
AllowRoot bool
DynamicRoot string
InstanceRoot string
InstanceAlias string
}
HostPathPolicy controls the two deliberate host-path exceptions.
type Inventory ¶
type Inventory struct {
AppID string `json:"appId"`
Driver string `json:"driver"`
Ref string `json:"ref"`
DisplayName string `json:"displayName"`
Version string `json:"version,omitempty"`
Source string `json:"source,omitempty"`
InitialState string `json:"initialState"`
}
Inventory describes the single disposable package visible to the scenario.
type PackageDriver ¶
type PackageDriver struct {
// contains filtered or unexported fields
}
PackageDriver is a data-only implementation of all production package capability interfaces. It has no process or network runner.
func (*PackageDriver) DetectBatch ¶
func (value *PackageDriver) DetectBatch(refs []string) (map[string]driver.DetectResult, error)
func (*PackageDriver) DetectBatchSource ¶
func (value *PackageDriver) DetectBatchSource(refs []string, source string) (map[string]driver.DetectResult, error)
func (*PackageDriver) DetectSource ¶
func (value *PackageDriver) DetectSource(ref, source string) (bool, string, error)
func (*PackageDriver) EnumerateInstalled ¶
func (value *PackageDriver) EnumerateInstalled() ([]driver.InstalledPackage, error)
func (*PackageDriver) ExternalCallCount ¶
func (value *PackageDriver) ExternalCallCount() uint64
ExternalCallCount is a testable invariant: this driver has no external runner.
func (*PackageDriver) Install ¶
func (value *PackageDriver) Install(ref string) (*driver.InstallResult, error)
func (*PackageDriver) InstallSource ¶
func (value *PackageDriver) InstallSource(ref, source string) (*driver.InstallResult, error)
func (*PackageDriver) InstallVersion ¶
func (value *PackageDriver) InstallVersion(ref, version string) (*driver.InstallResult, error)
func (*PackageDriver) InstallVersionSource ¶
func (value *PackageDriver) InstallVersionSource(ref, version, source string) (*driver.InstallResult, error)
func (*PackageDriver) Name ¶
func (value *PackageDriver) Name() string
func (*PackageDriver) ReinstallVersion ¶
func (value *PackageDriver) ReinstallVersion(ref, version string) (*driver.InstallResult, error)
func (*PackageDriver) ReinstallVersionSource ¶
func (value *PackageDriver) ReinstallVersionSource(ref, version, source string) (*driver.InstallResult, error)
func (*PackageDriver) Uninstall ¶
func (value *PackageDriver) Uninstall(ref string) (*driver.UninstallResult, error)
func (*PackageDriver) UninstallSource ¶
func (value *PackageDriver) UninstallSource(ref, source string) (*driver.UninstallResult, error)
type ProtectedPath ¶
type ProtectedPath struct{ Path, Label string }
type ProtectedRegistry ¶
type RegistryChange ¶
type RegistryChange struct {
Label string
Kind ChangeKind
}
type RegistryFixture ¶
type RegistryFixture struct{}
func NewRegistryFixture ¶
func NewRegistryFixture(*Context) (*RegistryFixture, error)
func (*RegistryFixture) Cleanup ¶
func (*RegistryFixture) Cleanup() error
func (*RegistryFixture) Materialize ¶
func (*RegistryFixture) Materialize(string) error
func (*RegistryFixture) ProveAbsent ¶
func (*RegistryFixture) ProveAbsent(string) error
func (*RegistryFixture) Remove ¶
func (*RegistryFixture) Remove(string) error
func (*RegistryFixture) Replace ¶
func (*RegistryFixture) Replace(string, RegistryState) error
func (*RegistryFixture) Snapshot ¶
func (*RegistryFixture) Snapshot(string) (RegistryState, error)
type RegistryGuard ¶
type RegistryGuard struct{}
func NewRegistryGuard ¶
func NewRegistryGuard(*Context) *RegistryGuard
func (*RegistryGuard) Check ¶
func (*RegistryGuard) Check() ([]RegistryChange, error)
func (*RegistryGuard) Protect ¶
func (*RegistryGuard) Protect(values []ProtectedRegistry) error
func (*RegistryGuard) Seal ¶
func (*RegistryGuard) Seal()
type RegistryKey ¶
type RegistryKey struct {
Path string
Values []RegistryValue
}
RegistryKey is one relative key and all of its values. The empty Path is the authored root and the empty Name is that key's default value.
type RegistryState ¶
type RegistryState struct {
// contains filtered or unexported fields
}
RegistryState is an immutable, canonical snapshot of a registry subtree.
func NewRegistryState ¶
func NewRegistryState(keys []RegistryKey) (RegistryState, error)
NewRegistryState validates and canonically orders a registry subtree.
func (RegistryState) Equal ¶
func (state RegistryState) Equal(other RegistryState) bool
Equal compares canonical registry identity, type, and raw data exactly.
func (RegistryState) Keys ¶
func (state RegistryState) Keys() []RegistryKey
Keys returns a defensive copy of the canonical registry keys.
type RegistryValue ¶
RegistryValue is one exact Windows registry value in a disposable fixture.
type WriteGuard ¶
type WriteGuard struct {
// contains filtered or unexported fields
}
WriteGuard records protected filesystem trees without mutating them.
func NewWriteGuard ¶
func NewWriteGuard(allowed string, protected []string) (*WriteGuard, error)
NewWriteGuard validates disjoint boundaries and snapshots protected paths.
func (*WriteGuard) Check ¶
func (guard *WriteGuard) Check() ([]Change, error)
Check returns deterministic protected-path changes since construction.
func (*WriteGuard) Label ¶
func (guard *WriteGuard) Label(path string) string
Label returns the non-sensitive label associated with a changed absolute path.
func (*WriteGuard) Protect ¶
func (guard *WriteGuard) Protect(values []ProtectedPath) error
Protect registers and snapshots additional paths before mutation begins.
func (*WriteGuard) ProtectedCount ¶
func (guard *WriteGuard) ProtectedCount() int
func (*WriteGuard) Seal ¶
func (guard *WriteGuard) Seal()
Seal closes registration. Protect after Seal is rejected so a late snapshot can never erase evidence of a mutation.