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 ¶
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 ¶
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.
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.