Documentation
¶
Overview ¶
Package host discovers what the local machine provides to programs: shells, mounted filesystems, web view runtimes and host resource capacity (CPU, memory, storage, power and container state). Discovery reads paths and permissions; it never launches what it finds.
The native checks the host-requirements resolver needs (FilesystemAt, ExecutableAccess, DirectoryWritable) are exported here, because they are OS mechanisms; the resolver itself and the graph vocabulary are in res/graph.
Index ¶
- Constants
- func DirectoryWritable(path string) error
- func Environment() string
- func ExecutableAccess(path string) error
- func IsExecutable(path string) bool
- func PathKey(path string) string
- func RedactSource(source string) string
- func WebviewIdentity(item WebviewInfo) string
- type ContainerInfo
- type FilesystemInfo
- type FilesystemSpace
- type PowerInfo
- type ResourceInfo
- type ShellInfo
- type StorageInfo
- type WebviewInfo
Constants ¶
const ( // ContainerDetected, ContainerNone, and ContainerUnsupported are the only // container states. Unsupported means the platform exposes no safe local // signal, not that the process is outside a container. ContainerDetected = "detected" ContainerNone = "none" ContainerUnsupported = "unsupported" )
const ( PowerStateCharging = "charging" PowerStateDischarging = "discharging" PowerStateCharged = "charged" PowerStateUnknown = "unknown" )
PowerState values.
Variables ¶
This section is empty.
Functions ¶
func DirectoryWritable ¶
DirectoryWritable reports whether the calling user may create entries in the directory at path, without creating a probe file.
func Environment ¶
func Environment() string
Environment identifies the host environment the observations were made in. Graph records carry it so a consumer can tell when they came from somewhere else.
func ExecutableAccess ¶
ExecutableAccess reports whether the calling user may execute the file at path. It does not run it.
func IsExecutable ¶
IsExecutable reports whether path is a regular file the calling user may execute.
func PathKey ¶
PathKey returns the key under which a host path is compared and recorded: the cleaned path, lower-cased on Windows.
func RedactSource ¶
RedactSource removes URL credentials from a filesystem source.
func WebviewIdentity ¶
func WebviewIdentity(item WebviewInfo) string
WebviewIdentity returns the key that identifies a web view across scans: its name, scope and location.
Types ¶
type ContainerInfo ¶
type ContainerInfo struct {
Detected bool `json:"detected"`
State string `json:"state"`
Evidence []string `json:"evidence"`
}
ContainerInfo reports whether this process runs inside a container and which local markers support that conclusion. Evidence is a sorted list of stable names, not file contents or environment values.
type FilesystemInfo ¶
type FilesystemInfo struct {
MountPoint string `json:"mount_point"`
Source string `json:"source"`
Type string `json:"type"`
ReadOnly bool `json:"read_only"`
Space *FilesystemSpace `json:"space,omitempty"`
Label string `json:"label,omitempty"`
DriveKind string `json:"drive_kind,omitempty"`
DetailError string `json:"detail_error,omitempty"`
}
FilesystemInfo describes a mounted filesystem visible to this process. Space is nil when the OS cannot provide it. This is not a list of unmounted disks or a filesystem-driver catalog. Source never includes URL credentials.
func DiscoverFilesystems ¶
func DiscoverFilesystems(ctx context.Context) ([]FilesystemInfo, error)
DiscoverFilesystems reads the native mount inventory and available space. It observes the caller's mount namespace and permissions, including when CTX itself runs inside a container. It does not traverse filesystem contents.
func FilesystemAt ¶
func FilesystemAt(ctx context.Context, path string) (FilesystemInfo, error)
FilesystemAt describes the mounted filesystem that contains path, in the same terms as DiscoverFilesystems. It reports an error where the platform cannot answer.
type FilesystemSpace ¶
type FilesystemSpace struct {
TotalBytes uint64 `json:"total_bytes"`
FreeBytes uint64 `json:"free_bytes"`
AvailableBytes uint64 `json:"available_bytes"`
}
FilesystemSpace is a point-in-time capacity observation, in bytes. Available space is what the calling user can allocate; it can differ from free space. On Windows, total space is also limited by any quota on the calling user.
type PowerInfo ¶
type PowerInfo struct {
State string `json:"state"` // charging, discharging, charged, unknown
Percentage int `json:"percentage"` // 0-100
TimeRemainingSeconds int64 `json:"time_remaining_seconds,omitempty"`
}
PowerInfo describes battery/power state. All fields are zero when the platform does not expose them.
type ResourceInfo ¶
type ResourceInfo struct {
OS string `json:"os"`
Architecture string `json:"architecture"`
ObservedAt time.Time `json:"observed_at"`
LogicalCPUs int `json:"logical_cpus"`
CPUCapacity float64 `json:"cpu_capacity"`
CPUStatus proc.CollectionStatus `json:"cpu_status"`
MemoryBytes uint64 `json:"memory_bytes"`
MemoryCapacityBytes uint64 `json:"memory_capacity_bytes"`
MemoryStatus proc.CollectionStatus `json:"memory_status"`
Storage []StorageInfo `json:"storage,omitempty"`
Power *PowerInfo `json:"power,omitempty"`
Container ContainerInfo `json:"container"`
Uptime *time.Duration `json:"uptime,omitempty"`
BootTime *time.Time `json:"boot_time,omitempty"`
UptimeStatus proc.CollectionStatus `json:"uptime_status"`
}
ResourceInfo is a point-in-time observation of the local machine's computing resources. Container-adjusted values never guess: a field whose native source is unavailable carries a non-complete status instead of the host value.
It is local host state only. Network shape stays in res/system/service/network and is never duplicated here.
func DiscoverResources ¶
func DiscoverResources(ctx context.Context) (ResourceInfo, error)
DiscoverResources observes the local machine's CPU, memory, container state, storage, power/battery, and uptime. It reads local files and system counters only: no command is launched, no network is contacted, and no identity or protocol is attached.
type ShellInfo ¶
type ShellInfo struct {
Name string `json:"name"`
Path string `json:"path"`
ResolvedPath string `json:"resolved_path"`
ConfiguredDefault bool `json:"configured_default"`
Sources []string `json:"sources"`
}
ShellInfo describes an executable available to this host user. Discovery checks paths and permissions without launching the executable. The configured default is an environment declaration, not proof of the current process.
func DiscoverShells ¶
DiscoverShells finds registered shells, standard shell executable names on PATH, platform shell locations, and a configured SHELL/ComSpec executable. Registered and configured paths can identify shells with arbitrary names.
type StorageInfo ¶
type StorageInfo struct {
Device string `json:"device"`
MountPoint string `json:"mount_point"`
TotalBytes uint64 `json:"total_bytes"`
AvailableBytes uint64 `json:"available_bytes"`
Type string `json:"type,omitempty"`
ReadOnly bool `json:"read_only,omitempty"`
}
StorageInfo describes one mounted storage volume visible to the process.
type WebviewInfo ¶
type WebviewInfo struct {
Name string `json:"name"`
Engine string `json:"engine"`
API string `json:"api"`
Version string `json:"version,omitempty"`
ABIVersion string `json:"abi_version,omitempty"`
Architecture string `json:"architecture,omitempty"`
Location string `json:"location"`
ResolvedPath string `json:"resolved_path,omitempty"`
Scope string `json:"scope"`
Source string `json:"source"`
DetailError string `json:"detail_error,omitempty"`
}
WebviewInfo describes evidence of a shared web rendering runtime. Discovery does not load the runtime or establish that a particular app can use it. Location is a framework/library path or a Windows registry location. Version is the runtime version; ABIVersion is a library API/ABI generation, not the underlying WebKit or Chromium version.
func DiscoverWebviews ¶
func DiscoverWebviews(ctx context.Context) ([]WebviewInfo, error)
DiscoverWebviews inventories host webview runtimes without launching a browser, reading app profiles, or depending on installed ext adapters.