doctor

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSeverityLevel

func GetSeverityLevel(severity string) int

GetSeverityLevel converts severity string to numeric level for comparison. Higher numbers indicate more severe issues.

Types

type ConflictCheck

type ConflictCheck struct {
	// contains filtered or unexported fields
}

ConflictCheck detects filesystem conflicts before operations.

func NewConflictCheck

func NewConflictCheck(fs FS, targetDir string, packageLinks map[string][]string) *ConflictCheck

func (*ConflictCheck) Description

func (c *ConflictCheck) Description() string

func (*ConflictCheck) Name

func (c *ConflictCheck) Name() string

func (*ConflictCheck) Run

type ConflictPermissionCheck

type ConflictPermissionCheck struct {
	// contains filtered or unexported fields
}

ConflictPermissionCheck verifies write permissions for target directories.

func NewConflictPermissionCheck

func NewConflictPermissionCheck(fs FS, targetDir string) *ConflictPermissionCheck

func (*ConflictPermissionCheck) Description

func (c *ConflictPermissionCheck) Description() string

func (*ConflictPermissionCheck) Name

func (c *ConflictPermissionCheck) Name() string

func (*ConflictPermissionCheck) Run

type DiagnosticEngine

type DiagnosticEngine struct {
	// contains filtered or unexported fields
}

DiagnosticEngine manages and executes diagnostic checks.

func NewDiagnosticEngine

func NewDiagnosticEngine() *DiagnosticEngine

NewDiagnosticEngine creates a new diagnostic engine.

func (*DiagnosticEngine) RegisterCheck

func (e *DiagnosticEngine) RegisterCheck(check domain.DiagnosticCheck)

RegisterCheck adds a check to the engine.

func (*DiagnosticEngine) Run

Run executes the registered checks based on options.

type DiagnosticReport

type DiagnosticReport struct {
	Results       []domain.CheckResult
	OverallStatus domain.CheckStatus
	Duration      time.Duration
	StartTime     time.Time
}

DiagnosticReport aggregates results from all checks.

type DiagnosticStats

type DiagnosticStats struct {
	TotalLinks    int
	BrokenLinks   int
	OrphanedLinks int
	ManagedLinks  int
}

DiagnosticStats contains summary statistics.

type FS

type FS interface {
	Exists(ctx context.Context, path string) (bool, error)
	IsDir(ctx context.Context, path string) (bool, error)
	Lstat(ctx context.Context, name string) (fs.FileInfo, error)
	ReadDir(ctx context.Context, name string) ([]fs.DirEntry, error)
	ReadFile(ctx context.Context, name string) ([]byte, error)
	ReadLink(ctx context.Context, name string) (string, error)
	WriteFile(ctx context.Context, name string, data []byte, perm os.FileMode) error
	Remove(ctx context.Context, name string) error
	MkdirAll(ctx context.Context, path string, perm os.FileMode) error
	Stat(ctx context.Context, name string) (fs.FileInfo, error)
}

FS defines the filesystem abstraction interface needed by doctor checks.

type Issue

type Issue struct {
	Severity   domain.IssueSeverity
	Type       IssueType
	Path       string
	Message    string
	Suggestion string
}

Issue represents a diagnostic issue found during scanning.

type IssueType

type IssueType string

IssueType defines the type of issue.

const (
	// IssueBrokenLink indicates a symlink pointing to a non-existent target.
	IssueBrokenLink IssueType = "broken_link"
	// IssueOrphanedLink indicates a symlink not managed by any package.
	IssueOrphanedLink IssueType = "orphaned_link"
	// IssueWrongTarget indicates a symlink pointing to an unexpected target.
	IssueWrongTarget IssueType = "wrong_target"
)

type LinkHealthChecker

type LinkHealthChecker interface {
	CheckLink(ctx context.Context, pkgName, linkPath, packageDir string) LinkHealthResult
}

LinkHealthChecker defines the interface for checking link health.

type LinkHealthResult

type LinkHealthResult struct {
	IsHealthy  bool
	IssueType  IssueType
	Severity   domain.IssueSeverity
	Message    string
	Suggestion string
}

LinkHealthResult contains detailed health information for a single link.

type ManagedPackageCheck

type ManagedPackageCheck struct {
	// contains filtered or unexported fields
}

ManagedPackageCheck validates all packages managed by dot.

func NewManagedPackageCheck

func NewManagedPackageCheck(
	fs FS,
	manifestSvc ManifestLoader,
	healthChecker LinkHealthChecker,
	targetDir string,
	newTargetPath TargetPathCreator,
	isManifestNotFound ManifestNotFoundChecker,
) *ManagedPackageCheck

func (*ManagedPackageCheck) Description

func (c *ManagedPackageCheck) Description() string

func (*ManagedPackageCheck) Name

func (c *ManagedPackageCheck) Name() string

func (*ManagedPackageCheck) Run

type ManifestIntegrityCheck

type ManifestIntegrityCheck struct {
	// contains filtered or unexported fields
}

ManifestIntegrityCheck validates the manifest file itself.

func NewManifestIntegrityCheck

func NewManifestIntegrityCheck(
	fs FS,
	manifestSvc ManifestLoader,
	targetDir string,
	newTargetPath TargetPathCreator,
	isManifestNotFound ManifestNotFoundChecker,
) *ManifestIntegrityCheck

func (*ManifestIntegrityCheck) Description

func (c *ManifestIntegrityCheck) Description() string

func (*ManifestIntegrityCheck) Name

func (c *ManifestIntegrityCheck) Name() string

func (*ManifestIntegrityCheck) Run

type ManifestLoader

type ManifestLoader interface {
	Load(ctx context.Context, targetPath domain.TargetPath) domain.Result[manifest.Manifest]
	LoadManifest(ctx context.Context) (*manifest.Manifest, error)
}

ManifestLoader defines the interface for loading manifests.

type ManifestNotFoundChecker

type ManifestNotFoundChecker func(err error) bool

ManifestNotFoundChecker checks if an error is a manifest not found error.

type OrphanCheck

type OrphanCheck struct {
	// contains filtered or unexported fields
}

OrphanCheck scans for symlinks not managed by dot.

func NewOrphanCheck

func NewOrphanCheck(
	fs FS,
	manifestSvc ManifestLoader,
	targetDir string,
	config ScanConfig,
	newTargetPath TargetPathCreator,
) *OrphanCheck

func (*OrphanCheck) Description

func (c *OrphanCheck) Description() string

func (*OrphanCheck) Name

func (c *OrphanCheck) Name() string

func (*OrphanCheck) Run

type PatternCategory

type PatternCategory struct {
	Name        string
	Description string
	Patterns    []string // Glob patterns for targets
	Confidence  string   // "high", "medium", "low"
}

PatternCategory describes type of symlink based on its target.

func CategorizeSymlink(target string, categories []PatternCategory) *PatternCategory

CategorizeSymlink returns category for a symlink target, or nil if unknown.

func DefaultPatternCategories

func DefaultPatternCategories() []PatternCategory

DefaultPatternCategories returns hardcoded system patterns.

type PermissionCheck

type PermissionCheck struct {
	// contains filtered or unexported fields
}

PermissionCheck validates filesystem permissions for operations.

func NewPermissionCheck

func NewPermissionCheck(fs FS, targetDir string) *PermissionCheck

NewPermissionCheck creates a new permission check.

func (*PermissionCheck) Description

func (c *PermissionCheck) Description() string

func (*PermissionCheck) Name

func (c *PermissionCheck) Name() string

func (*PermissionCheck) Run

type PlatformCheck

type PlatformCheck struct {
	// contains filtered or unexported fields
}

PlatformCheck validates platform compatibility for packages.

func NewPlatformCheck

func NewPlatformCheck(fs FS, manifestSvc ManifestLoader, packageDir string) *PlatformCheck

NewPlatformCheck creates a new platform compatibility check.

func (*PlatformCheck) Description

func (c *PlatformCheck) Description() string

func (*PlatformCheck) Name

func (c *PlatformCheck) Name() string

func (*PlatformCheck) Run

type RunOptions

type RunOptions struct {
	// Names of specific checks to run. If empty, all checks are run.
	IncludeChecks []string
	// Parallel execution of independent checks
	Parallel bool
}

RunOptions configures the execution of checks.

type ScanConfig

type ScanConfig struct {
	Mode         ScanMode
	MaxDepth     int
	MaxWorkers   int
	MaxIssues    int
	ScopeToDirs  []string
	SkipPatterns []string
}

ScanConfig configures the behavior of diagnostic scans.

type ScanMode

type ScanMode int

ScanMode defines the depth of scanning for orphaned links.

const (
	// ScanOff disables orphan scanning.
	ScanOff ScanMode = iota
	// ScanScoped scans directories containing managed links (default).
	ScanScoped
	// ScanDeep performs full recursive scan with depth limits.
	ScanDeep
)

type SecretDetection

type SecretDetection struct {
	Path    string
	Pattern SensitivePattern
	Target  string
}

SecretDetection represents a detected potential secret.

func DetectSecrets

func DetectSecrets(links []string, patterns []SensitivePattern) []SecretDetection

DetectSecrets scans links for potential secrets using provided patterns. Returns a list of detections where sensitive files were found.

func DetectSecretsWithTargets

func DetectSecretsWithTargets(links map[string]string, patterns []SensitivePattern) []SecretDetection

DetectSecretsWithTargets scans links and their targets for potential secrets. This version allows checking both the link path and the target path.

func FilterBySeverity

func FilterBySeverity(detections []SecretDetection, minSeverity string) []SecretDetection

FilterBySeverity filters detections by minimum severity level.

type SensitivePattern

type SensitivePattern struct {
	Name        string
	Description string
	Patterns    []string
	Severity    string // "critical", "high", "medium"
}

SensitivePattern defines patterns that indicate potential secrets.

func DefaultSensitivePatterns

func DefaultSensitivePatterns() []SensitivePattern

DefaultSensitivePatterns returns patterns for detecting sensitive files.

type TargetPathCreator

type TargetPathCreator interface {
	NewTargetPath(path string) domain.Result[domain.TargetPath]
}

TargetPathCreator defines the interface for creating TargetPath.

Jump to

Keyboard shortcuts

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