gitremote

package
v0.7.11 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package gitremote deterministically detects the git remotes configured in a local directory tree, so Wardyn can ground a composed run's GitHub grant on the workspace's ACTUAL remotes rather than an LLM guess.

It is read-only and runs NO subprocess: it parses .git/config and .gitmodules as plain files (so it can never trigger a git hook or a malicious include.path / core.fsmonitor in a repo's config). The walk is bounded (depth, .git count, file size), never follows symlinks, reads REGULAR files only (a FIFO named .gitmodules would otherwise block the scan's goroutine forever), and fails safe — any error yields fewer/zero detected repos, never a grant on uncertainty.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectGitHubRepos

func DetectGitHubRepos(root string) (github []string, otherHosts []string)

DetectGitHubRepos walks root (bounded, no symlink following) and returns the sorted, de-duplicated set of github.com "owner/repo" remotes found in .git/config and .gitmodules files, plus the sorted set of non-GitHub remote HOSTS (for an operator warning). It never returns an error: detection is best-effort and fail-safe.

func FieldSafe added in v0.7.4

func FieldSafe(s string) bool

FieldSafe reports whether s carries no control character and no whitespace. It is THE predicate for both doors that judge an attacker-influenceable repo slug or remote URL: this package's classify(), and internal/api's repoFieldSafe, which delegates here.

One predicate, deliberately (B11a-F10). The previous local copy carried a FIXED whitespace list and a comment claiming to mirror repoFieldSafe — which had since moved to unicode.IsSpace, so every Unicode space separator (U+2000..U+200A, U+3000, …) passed here while the api door rejected it. Two doors judging one value by different rules is how a detected remote reaches a grant the authoring door would have refused.

func OpenRegular added in v0.7.4

func OpenRegular(p string) (*os.File, error)

OpenRegular opens a file for reading that is PROVABLY an ordinary file and is never reached through a symlink. It is the shared door for every read a workspace walk performs, because every such walk runs on an HTTP handler goroutine with no ctx and over a tree the scanned party controls.

O_NOFOLLOW refuses a symlinked final component (the walk skips links everywhere else, so this is the one remaining place a tree could point the scanner at a file outside itself). O_NONBLOCK makes open(2) RETURN on a FIFO instead of waiting forever for a writer — one such file wedged the request permanently — and the fstat is what then decides nothing is read from it. That order is also race-free: the flags pick what gets opened and the fstat judges the thing actually opened, so there is no path-based window between the two.

The caller closes. The caller also bounds what it reads: this says WHAT may be opened, never HOW MUCH comes back.

func ResolveRoot added in v0.7.4

func ResolveRoot(root string) string

ResolveRoot canonicalises a scan root before a walk: cleaned, and with every symlink in it resolved. It is the ONE line that keeps a walk's own view of a workspace and the sandbox's mount of it talking about the same directory — dispatch bind-mounts the RESOLVED tree, so a scanner that stops at the link describes a tree the run never sees.

Resolution failure (a broken link, a directory the daemon cannot traverse) falls back to the cleaned path: the walk then finds nothing, which is the fail-safe answer both callers already treat as "no evidence", never a claim about a tree nobody read. Shared with internal/workspacescan, whose CollectFacts had the identical bug on the identical locator.

func ToSorted

func ToSorted(m map[string]struct{}) []string

ToSorted dedupes and sorts a set into a slice, nil if empty. Shared with internal/workspacescan, which already imports this package.

Types

This section is empty.

Jump to

Keyboard shortcuts

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