glob

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package glob implements the Glob tool: a workspace-contained, denied-path-excluding filename search over WalkDir-discovered entries. Preparation emits one direct filesystem.read requirement for the canonical walked root using the tree match encoding, so a durable tree rule covers it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Glob

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

Glob searches workspace filenames against a glob pattern. It depends only on the workspace root and the narrow loop.ReadGuard (least privilege).

func NewGlob

func NewGlob(root string, guard loop.ReadGuard, opts ...GlobOption) *Glob

NewGlob constructs a Glob bound to the workspace root and read guard.

func (*Glob) AuditSummary

func (g *Glob) AuditSummary(argsJSON string) string

AuditSummary returns a redacted one-line summary: the pattern (and root if present) only — never any matched path contents.

func (*Glob) Info

func (g *Glob) Info(context.Context) (*tool.ToolInfo, error)

Info returns Glob's self-description. Name MUST equal "Glob".

func (*Glob) InvokableRun

func (g *Glob) InvokableRun(ctx context.Context, _ string) (*tool.ToolResult, error)

InvokableRun executes the PREPARED artifact bound to this call — the raw argsJSON is never reparsed, so mutating it after preparation changes nothing; without its artifact the tool fails closed. It walks the approved root, matches each workspace-relative path against the prepared pattern, EXCLUDES any path DeniedRead reports, caps results, and returns a newline-separated list. Every failure is a tool-result string.

func (*Glob) PrepareCall

func (g *Glob) PrepareCall(_ context.Context, executionID uuid.UUID, argsJSON string) (tool.Request, tool.PreparedArtifact, error)

PrepareCall decodes and validates the untrusted arguments ONCE, resolves the canonical walk root ONCE, and returns the typed request — ONE filesystem.read requirement for the walked root (plain canonical path as Scope for profile routing, canonical tree encoding as Match for durable tree rules, empty grant pair) — plus the typed artifact InvokableRun executes. Invalid input fails here and never reaches the permission gate.

type GlobOption

type GlobOption func(*Glob)

GlobOption configures a Glob at construction (functional-options pattern, matching grep.GrepOption / readfile.ReadFileOption).

func WithHostReads

func WithHostReads() GlobOption

WithHostReads lets an absolute search root resolve OUTSIDE the workspace instead of being rejected at prepare time -- the Glob counterpart to readfile.WithHostReads() / grep.WithHostReads(). It does not itself grant anything: an uncontained resolved search root still emits the same filesystem.read requirement PrepareCall always has, so the consumer's bound access source makes the actual Allow/Deny/Gated decision. A RELATIVE "../" traversal is never widened by this option -- only a literal absolute path argument can resolve outside the workspace. Matched paths in an uncontained (host) walk are displayed relative to the SEARCHED directory itself, not the workspace root.

Jump to

Keyboard shortcuts

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