scanner

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 10 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 scanner walks a project directory and evaluates .env files for the three MVP checks: gitignore coverage, file permissions, and secret-like values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindEnvFiles

func FindEnvFiles(root string) ([]string, error)

FindEnvFiles walks root and returns paths to every file that looks like an environment file, skipping common vendor/build directories.

func IsGitTracked

func IsGitTracked(root, target string) bool

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

func IsIgnored(root, target string) bool

IsIgnored reports whether target (a path under root) is covered by any .gitignore between root and target's directory. This uses simple pattern matching (exact name, "*.env*"-style globs, and a leading "/" anchor) — it covers the vast majority of real .gitignore entries for env files without needing a full gitignore-spec implementation.

func Run

func Run(root string, cfg *config.Config) (report.Result, error)

Run performs the full envaudit scan over root and returns a combined Result across all three MVP checks: gitignore coverage, permissions, and secret-like values.

func ScanEnvFileValues

func ScanEnvFileValues(path string, cfg *config.Config) ([]report.Finding, error)

ScanEnvFileValues reads path line by line and returns one Finding per value that looks like a real (non-placeholder) secret.

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.

Jump to

Keyboard shortcuts

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