protect

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const PrivatePathsFile = "private-paths"

PrivatePathsFile is the filename inside .envault/ that stores registered patterns.

Variables

View Source
var ErrPatternNotFound = fmt.Errorf("pattern not found in private-paths")

ErrPatternNotFound is returned when RemovePattern cannot find the target.

Functions

func AddPattern

func AddPattern(repoRoot, pattern string) error

AddPattern registers pattern in .envault/private-paths. Idempotent.

func ContainsProtectedPath

func ContainsProtectedPath(text string, patterns []string) (pattern, token string, found bool)

ContainsProtectedPath checks whether the given text (typically a Bash command string) contains any token that matches a protected pattern. Returns the first matching pattern and the matched token, or ("", "", false). This is a best-effort heuristic; adversarial bypass coverage is in v0.8.4.

func LoadPatterns

func LoadPatterns(repoRoot string) ([]string, error)

LoadPatterns reads .envault/private-paths and returns the list of patterns. Returns an empty slice (not an error) when the file does not exist.

func MatchesAny

func MatchesAny(targetPath string, patterns []string) (string, bool)

MatchesAny checks whether targetPath matches any of the given patterns. Returns the first matching pattern and true, or ("", false) if no match. Matching strategy (in order):

  1. filepath.Match(pattern, targetPath) — exact or glob match on full path
  2. filepath.Match(pattern, filepath.Base(targetPath)) — basename match for simple names
  3. Prefix directory match: pattern "config/" matches "config/secrets.json"

func RemovePattern

func RemovePattern(repoRoot, pattern string) error

RemovePattern deletes pattern from .envault/private-paths. Returns ErrPatternNotFound if the pattern is not registered.

Types

This section is empty.

Jump to

Keyboard shortcuts

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