Documentation
¶
Overview ¶
Package scanner walks a project directory and evaluates .env files for the three MVP checks: gitignore coverage, file permissions, and secret-like values.
Index ¶
- func FindEnvFiles(root string) ([]string, error)
- func GitTrackedSet(root string) map[string]bool
- func IsGitTracked(root, target string) bool
- func IsIgnored(root, target string) bool
- func Run(root string, cfg *config.Config) (report.Result, error)
- func ScanEnvFileValues(path string, cfg *config.Config) ([]report.Finding, error)
- type PermissionResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindEnvFiles ¶
FindEnvFiles walks root and returns paths to every file that looks like an environment file, skipping common vendor/build directories.
func GitTrackedSet ¶ added in v1.1.0
GitTrackedSet runs `git ls-files` once and returns the set of tracked files, so a scan can check every .env file against a single invocation instead of spawning one subprocess per file. Returns an empty set (not an error) when git isn't available or root isn't a repo.
func IsGitTracked ¶
IsGitTracked reports whether target is currently tracked by git — i.e. it has already been committed at some point, which is the critical case: an ignore rule added *after* a commit does not remove history. Returns false (not an error) if git isn't available or root isn't a repo, so envaudit still works outside of git projects.
func IsIgnored ¶
IsIgnored reports whether target (a path under root) is covered by any .gitignore between root and target's directory. The closest .gitignore that has a matching rule wins, matching git's own precedence.
Types ¶
type PermissionResult ¶
type PermissionResult struct {
Mode os.FileMode
TooOpen bool
Reason string
Applicable bool // false on platforms where this check doesn't apply (Windows)
}
PermissionResult describes how open a file's permissions are.
func CheckPermission ¶
func CheckPermission(path string) (PermissionResult, error)
maxRecommendedMode is the most permissive mode envaudit considers acceptable for a file that may contain secrets: owner read/write, nothing for group/other (0600). 0640 (owner rw, group r) is allowed too, since some team setups rely on group read via a shared deploy user — anything with "other" bits set, or group-write, is flagged.