guard

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package guard asks the user before the VM changes a file their machine runs on its own (direnv's .envrc when they enter the folder, the editor's tasks, git hooks' config): the shares' SFTP server calls Allow before each write (sshocker's Guard), in the hostagent. Files the agent edits as a matter of course (Makefile, package.json) are guarded only when the user lists them.

Index

Constants

View Source
const FileName = "guarded"

FileName is the list's file in agent-vm's state folder: one path a line, added to Defaults; "!path" removes one.

Variables

View Source
var Defaults = map[string]string{
	".envrc": "direnv runs it when you enter the folder.",

	".vscode/tasks.json":    "VS Code can run its tasks when the folder opens.",
	".vscode/settings.json": "VS Code reads commands from it (terminal profiles, tools to run).",
	".vscode/launch.json":   "VS Code runs it when you debug.",
	".vscode/mcp.json":      "VS Code starts the MCP servers it lists.",

	".devcontainer/devcontainer.json": "VS Code runs its initializeCommand on your machine when you reopen the folder in a container.",
	".devcontainer.json":              "VS Code runs its initializeCommand on your machine when you reopen the folder in a container.",

	".idea/runConfigurations": "JetBrains IDEs run these configurations on your machine.",
	".idea/watchers.xml":      "JetBrains IDEs run its file watchers on your machine each time you save.",
	".zed/settings.json":      "Zed starts the language servers it names.",
	".zed/tasks.json":         "Zed runs its tasks.",
	".dir-locals.el":          "Emacs applies its settings, which can evaluate code, when you open a file.",

	".claude/settings.json":       "Claude Code runs the hooks it lists on your machine.",
	".claude/settings.local.json": "Claude Code runs the hooks it lists on your machine.",
	".mcp.json":                   "Claude Code starts the MCP servers it lists.",
	".cursor/mcp.json":            "Cursor starts the MCP servers it lists.",
	".cursor/hooks.json":          "Cursor runs the hooks it lists on your machine.",
	".codex/config.toml":          "Codex starts the MCP servers and programs it lists.",
	".gemini/settings.json":       "Gemini CLI starts the MCP servers and hooks it lists.",

	".pre-commit-config.yaml": "pre-commit runs its hooks on your commits.",
	"lefthook.yml":            "lefthook runs its hooks on your commits.",
	".lefthook.yml":           "lefthook runs its hooks on your commits.",
	"lefthook.yaml":           "lefthook runs its hooks on your commits.",
	".lefthook.yaml":          "lefthook runs its hooks on your commits.",
	"lefthook-local.yml":      "lefthook runs its hooks on your commits.",
	".lefthook-local.yml":     "lefthook runs its hooks on your commits.",
	".husky":                  "Git runs these hooks on your commits.",
	".githooks":               "Git runs these hooks on your commits when core.hooksPath points here.",

	"mise.toml":          "mise runs its hooks and tasks when you enter the folder.",
	".mise.toml":         "mise runs its hooks and tasks when you enter the folder.",
	"mise.local.toml":    "mise runs its hooks and tasks when you enter the folder.",
	".mise.local.toml":   "mise runs its hooks and tasks when you enter the folder.",
	".mise":              "mise runs its config and tasks when you enter the folder.",
	".config/mise.toml":  "mise runs its hooks and tasks when you enter the folder.",
	".config/mise":       "mise runs its config and tasks when you enter the folder.",
	".yarnrc.yml":        "yarn runs the program its yarnPath and plugins name.",
	".yarn/releases":     "yarn runs these files.",
	".yarn/plugins":      "yarn runs these files.",
	".pnpmfile.cjs":      "pnpm runs it when you install.",
	".npmrc":             "npm can run the program its script-shell or git settings name.",
	".cargo/config.toml": "cargo can run the program its runner and wrapper settings name.",
	".cargo/config":      "cargo can run the program its runner and wrapper settings name.",
	".lfsconfig":         "git-lfs sends your files and credentials to the server it names.",
}

Defaults are guarded unless the user removes them, each with what runs it. A path naming a folder guards everything in it.

View Source
var WindowsDefaults = map[string]string{
	"*.library-ms":         "Explorer contacts the server it names when it shows it, and sends your NTLM hash.",
	"*.searchConnector-ms": "Explorer contacts the server it names when it shows it, and sends your NTLM hash.",
	"*.lnk":                "Explorer can contact the server its icon names when it shows it, and send your NTLM hash.",
	"*.url":                "Explorer can contact the server its icon names when it shows it, and send your NTLM hash.",
	"*.scf":                "Explorer contacts the server its icon names when it shows it, and sends your NTLM hash.",
	"desktop.ini":          "Explorer contacts the server it names when it shows the folder, and sends your NTLM hash.",
}

WindowsDefaults are guarded as well on a Windows host, where Explorer contacts the server a file names when it shows the file, and sends your NTLM hash (CVE-2025-24054 for .library-ms, CVE-2025-50154 and CVE-2025-59214 for .lnk, CVE-2024-43451 for .url). "*.ext" is any file with that extension.

Functions

This section is empty.

Types

type Guard

type Guard struct {
	// VM is named in the question.
	VM string
	// Paths, relative, matched anywhere in a written path as whole names,
	// compared as sshocker folds read-only names (case, normalization, ignorable
	// characters): each with why it matters ("" for one the user added).
	Paths map[string]string
	// Ask shows the question and returns the answer (desktop.Ask). ok false
	// when no one could be asked.
	Ask func(ctx context.Context, title, msg string) (allow, ok bool)
	// Tell says something without waiting (a refusal no one was asked).
	Tell func(title, msg string)
	// contains filtered or unexported fields
}

Guard asks about the writes to guarded paths.

func Load

func Load(stateDir, vm string) (*Guard, error)

Load is the guard of the VM vm: Defaults and the user's list.

func (*Guard) Allow

func (g *Guard) Allow(root, rel string, entry bool) bool

Allow reports whether the VM may write rel, under the share root: yes unless rel is guarded and the user says no, or cannot be asked. entry is sshocker's: rel is a name that is created, removed or moved, not a file whose content changes.

Jump to

Keyboard shortcuts

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