Documentation
¶
Overview ¶
-- internal/cli/audit.go --
-- internal/cli/check.go --
-- internal/cli/diff_logic.go --
-- internal/cli/index.go --
-- internal/cli/interfaces.go --
-- internal/cli/migrate.go --
-- internal/cli/sandbox_adapter.go --
-- internal/cli/scan.go --
-- internal/cli/stats.go --
-- internal/cli/utils.go --
Index ¶
- Constants
- func CalculateTopologyDelta(oldT, newT *topology.FunctionTopology) (string, int)
- func CollectFiles(fsys FileSystem, target string) ([]string, error)
- func CompareFunctions(funcName string, oldResult, newResult diff.FingerprintResult) models.FunctionDiff
- func ComputeDiff(fsys FileSystem, oldFile, newFile string) (*models.DiffOutput, error)
- func ExitError(err error)
- func GetPathSize(fsys FileSystem, path string) (int64, error)
- func HumanizeBytes(bytes int64) string
- func IsJSON(path string) bool
- func LoadAndFingerprint(fsys FileSystem, filename string) ([]diff.FingerprintResult, error)
- func PrepareSandboxDB(originalPath string) (string, func(), error)
- func ProcessFile(fsys FileSystem, filename string, strictMode bool, scanner SignatureScanner) models.FileOutput
- func ProcessFilesParallel(fsys FileSystem, files []string, strictMode bool, scanner SignatureScanner) ([]models.FileOutput, bool, error)
- func ResolveDBPath(path string) string
- func RunAudit(w io.Writer, oldFile, newFile, commitMsg, apiKey, model, apiBase string) (int, error)
- func RunCheck(target string, strictMode bool, enableScan bool, dbPath string, noSandbox bool) error
- func RunCheckLogic(fsys FileSystem, target string, strictMode bool, enableScan bool, ...) error
- func RunDiff(oldFile, newFile string, noSandbox bool) error
- func RunDiffLogic(fsys FileSystem, oldFile, newFile string) error
- func RunIndex(target, name, severity, category, dbPath string) error
- func RunIndexJSON(target string, results []diff.FingerprintResult, ...) ([]detection.Signature, int, error)
- func RunIndexPebble(target string, results []diff.FingerprintResult, ...) ([]detection.Signature, int, error)
- func RunMigrate(fromPath, toPath string) error
- func RunScan(target string, opts models.ScanOptions, noSandbox bool) error
- func RunScanDeps(pkgLoader PackageLoader, target string, opts models.ScanOptions, ...) ([]detection.ScanResult, int, []string, error)
- func RunScanLogic(fsys FileSystem, pkgLoader PackageLoader, target string, ...) error
- func RunScanParallel(fsys FileSystem, files []string, scanner SignatureScanner, exactOnly bool) ([]detection.ScanResult, int, error)
- func RunStats(dbPath string) error
- func SandboxExec(sb Sandboxer, stdout, stderr io.Writer, command string, args []string, ...) error
- func ShortFunctionName(fullName string) string
- func SuggestCommand(cmd string) string
- type FileSystem
- type PackageLoader
- type RealFileSystem
- func (fs RealFileSystem) Abs(path string) (string, error)
- func (fs RealFileSystem) Getwd() (string, error)
- func (fs RealFileSystem) Open(name string) (fs.File, error)
- func (fs RealFileSystem) ReadFile(name string) ([]byte, error)
- func (fs RealFileSystem) Stat(name string) (os.FileInfo, error)
- func (fs RealFileSystem) WalkDir(root string, fn fs.WalkDirFunc) error
- type RealPackageLoader
- type RealSandboxer
- type Sandboxer
- type SignatureScanner
Constants ¶
const (
MaxSourceFileSize = 10 * 1024 * 1024
)
Variables ¶
This section is empty.
Functions ¶
func CalculateTopologyDelta ¶
func CalculateTopologyDelta(oldT, newT *topology.FunctionTopology) (string, int)
func CollectFiles ¶
func CollectFiles(fsys FileSystem, target string) ([]string, error)
Recursively finds Go files using the provided FileSystem.
func CompareFunctions ¶
func CompareFunctions(funcName string, oldResult, newResult diff.FingerprintResult) models.FunctionDiff
func ComputeDiff ¶
func ComputeDiff(fsys FileSystem, oldFile, newFile string) (*models.DiffOutput, error)
func GetPathSize ¶
func GetPathSize(fsys FileSystem, path string) (int64, error)
Calculates the size of a file or recursively sums the size of a directory.
func HumanizeBytes ¶
func LoadAndFingerprint ¶
func LoadAndFingerprint(fsys FileSystem, filename string) ([]diff.FingerprintResult, error)
This reads a file and generates semantic fingerprints using the provided FS.
func PrepareSandboxDB ¶ added in v3.2.0
PrepareSandboxDB ensures a database is usable inside the sandbox. If running sandboxed (where mounts are typically ReadOnly), PebbleDB fails to lock. This copies the DB to a secure, writable temp directory. Returns: newPath, cleanupFunc, error
func ProcessFile ¶
func ProcessFile(fsys FileSystem, filename string, strictMode bool, scanner SignatureScanner) models.FileOutput
func ProcessFilesParallel ¶ added in v3.2.0
func ProcessFilesParallel(fsys FileSystem, files []string, strictMode bool, scanner SignatureScanner) ([]models.FileOutput, bool, error)
func ResolveDBPath ¶
func RunCheckLogic ¶
func RunDiffLogic ¶
func RunDiffLogic(fsys FileSystem, oldFile, newFile string) error
func RunIndexJSON ¶
func RunIndexPebble ¶
func RunMigrate ¶
func RunScanDeps ¶
func RunScanDeps(pkgLoader PackageLoader, target string, opts models.ScanOptions, scanner SignatureScanner) ([]detection.ScanResult, int, []string, error)
func RunScanLogic ¶
func RunScanLogic(fsys FileSystem, pkgLoader PackageLoader, target string, opts models.ScanOptions) error
func RunScanParallel ¶
func RunScanParallel(fsys FileSystem, files []string, scanner SignatureScanner, exactOnly bool) ([]detection.ScanResult, int, error)
func SandboxExec ¶
func SandboxExec(sb Sandboxer, stdout, stderr io.Writer, command string, args []string, inputs ...string) error
elegates the current command to the sandbox with explicit mount points.
func ShortFunctionName ¶
func SuggestCommand ¶
Types ¶
type FileSystem ¶
type FileSystem interface {
Stat(name string) (os.FileInfo, error)
Open(name string) (fs.File, error)
Getwd() (string, error)
Abs(path string) (string, error)
WalkDir(root string, fn fs.WalkDirFunc) error
ReadFile(name string) ([]byte, error)
}
FileSystem abstracts OS file operations to enable hermetic testing.
type PackageLoader ¶
type PackageLoader interface {
Load(cfg *packages.Config, patterns ...string) ([]*packages.Package, error)
}
PackageLoader abstracts the go/packages loading for dependency scanning.
type RealFileSystem ¶
type RealFileSystem struct{}
RealFileSystem implements FileSystem using the actual OS.
func (RealFileSystem) Getwd ¶
func (fs RealFileSystem) Getwd() (string, error)
func (RealFileSystem) WalkDir ¶
func (fs RealFileSystem) WalkDir(root string, fn fs.WalkDirFunc) error
type RealSandboxer ¶
type RealSandboxer struct{}
Implements the Sandboxer interface using the internal sandbox package.
func (RealSandboxer) IsSandboxed ¶
func (rs RealSandboxer) IsSandboxed() bool
type Sandboxer ¶
type Sandboxer interface {
IsSandboxed() bool
Run(ctx context.Context, cfg sandbox.Config, stdout, stderr io.Writer) error
}
Sandboxer abstracts the process isolation mechanism.
type SignatureScanner ¶
type SignatureScanner interface {
ScanTopology(topo *topology.FunctionTopology, funcName string) ([]detection.ScanResult, error)
ScanTopologyExact(topo *topology.FunctionTopology, funcName string) (*detection.ScanResult, error)
Close() error
}
SignatureScanner abstracts the underlying database backend (PebbleDB or JSON).