scanner

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetCategoriesConfig

func SetCategoriesConfig(config *types.CategoriesConfig)

SetCategoriesConfig sets the global categories configuration

func ShouldAddPrimaryTech

func ShouldAddPrimaryTech(rule types.Rule) bool

ShouldAddPrimaryTech determines if a rule should add primary tech when component is created Returns true if primary tech should be added, false otherwise

func ShouldCreateComponent

func ShouldCreateComponent(rule types.Rule) bool

ShouldCreateComponent determines if a rule should create a component Returns true if component should be created, false otherwise

func ShouldCreateEdges

func ShouldCreateEdges(rule types.Rule) bool

ShouldCreateEdges determines if a rule should create edges to its components Returns true if edges should be created, false otherwise

Types

type CodeStatsAnalyzer

type CodeStatsAnalyzer interface {
	// ProcessFile analyzes a file
	// language is the go-enry detected language name (used for grouping)
	// If content is provided it will be used, otherwise file is read
	ProcessFile(filename string, language string, content []byte)

	// ProcessFileForComponent analyzes a file for a specific component
	// componentID is used to group stats by component
	// language is the go-enry detected language name (used for grouping)
	// If content is provided it will be used, otherwise the file will be read
	ProcessFileForComponent(filename string, language string, content []byte, componentID string)

	// GetStats returns the aggregated statistics
	GetStats() interface{}

	// GetComponentStats returns statistics for a specific component
	GetComponentStats(componentID string) interface{}

	// IsEnabled returns whether code stats collection is enabled
	IsEnabled() bool

	// IsPerComponentEnabled returns whether per-component code stats collection is enabled
	IsPerComponentEnabled() bool
}

CodeStatsAnalyzer interface for code statistics collection

type ComponentRegistry

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

ComponentRegistry indexes components by their package identifiers per technology

func NewComponentRegistry

func NewComponentRegistry() *ComponentRegistry

NewComponentRegistry creates a new component registry

func (*ComponentRegistry) Register

func (r *ComponentRegistry) Register(component *types.Payload)

Register adds a component to the registry using registered package providers

type DependencyDetector

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

DependencyDetector handles dependency-based technology detection

func NewDependencyDetector

func NewDependencyDetector(rules []types.Rule) *DependencyDetector

NewDependencyDetector creates a new dependency detector

func (*DependencyDetector) AddPrimaryTechIfNeeded

func (d *DependencyDetector) AddPrimaryTechIfNeeded(payload *types.Payload, tech string)

AddPrimaryTechIfNeeded checks if a tech should be primary and adds it if needed

func (*DependencyDetector) MatchDependencies

func (d *DependencyDetector) MatchDependencies(packages []string, depType string) map[string][]string

MatchDependencies matches a list of package names against dependency patterns

type DependencyMatcher

type DependencyMatcher struct {
	Regex *regexp.Regexp
	Tech  string
	Type  string
}

DependencyMatcher represents a compiled dependency pattern

type LanguageDetector

type LanguageDetector struct{}

LanguageDetector handles language detection using go-enry (GitHub Linguist)

func NewLanguageDetector

func NewLanguageDetector() *LanguageDetector

NewLanguageDetector creates a new language detector

func (*LanguageDetector) DetectLanguage

func (d *LanguageDetector) DetectLanguage(filename string, content []byte) string

DetectLanguage detects the programming language from a filename and optional content Uses content analysis for ambiguous extensions (e.g., .md could be Markdown or GCC Machine Description) Returns the detected language or empty string if not detected

func (*LanguageDetector) GetLanguageType

func (d *LanguageDetector) GetLanguageType(language string) enry.Type

GetLanguageType returns the type of language (programming, markup, data, prose)

func (*LanguageDetector) IsLanguageFile

func (d *LanguageDetector) IsLanguageFile(filename string) bool

IsLanguageFile checks if a file should be considered for language detection Excludes binary files, images, and other non-source files

type Scanner

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

Scanner handles the recursive directory scanning and technology detection logic

func NewScanner

func NewScanner(path string) (*Scanner, error)

NewScanner creates a new scanner with the given options

func NewScannerWithExcludes

func NewScannerWithExcludes(path string, excludePatterns []string, verbose bool, useTreeView bool, traceTimings bool, traceRules bool) (*Scanner, error)

NewScannerWithExcludes creates a new scanner with exclusion patterns

func NewScannerWithOptions

func NewScannerWithOptions(path string, excludePatterns []string, verbose bool, useTreeView bool, traceTimings bool, traceRules bool, codeStats CodeStatsAnalyzer) (*Scanner, error)

NewScannerWithOptions creates a new scanner with all options including code stats

func NewScannerWithOptionsAndLogger

func NewScannerWithOptionsAndLogger(path string, excludePatterns []string, verbose bool, useTreeView bool, traceTimings bool, traceRules bool, codeStats CodeStatsAnalyzer, logger *slog.Logger, rootID string, mergedConfig *config.ScanConfig) (*Scanner, error)

NewScannerWithOptionsAndLogger creates a new scanner with all options including logger

func NewScannerWithOptionsAndRootID

func NewScannerWithOptionsAndRootID(path string, excludePatterns []string, verbose bool, useTreeView bool, traceTimings bool, traceRules bool, codeStats CodeStatsAnalyzer, rootID string) (*Scanner, error)

NewScannerWithOptionsAndRootID creates a new scanner with root ID override

func NewScannerWithSettings

func NewScannerWithSettings(path string, settings *config.Settings, mergedConfig *config.ScanConfig, logger *slog.Logger) (*Scanner, error)

NewScannerWithSettings creates a new scanner with full settings support

func (*Scanner) Scan

func (s *Scanner) Scan() (*types.Payload, error)

Scan performs the main analysis of the target directory

func (*Scanner) ScanFile

func (s *Scanner) ScanFile(fileName string) (*types.Payload, error)

ScanFile performs analysis on a single file, treating it as a directory with just that file

func (*Scanner) SetUseLockFiles

func (s *Scanner) SetUseLockFiles(use bool)

SetUseLockFiles sets whether lock files should be used for dependency resolution

func (*Scanner) UseLockFiles

func (s *Scanner) UseLockFiles() bool

UseLockFiles returns whether lock files should be used for dependency resolution

Directories

Path Synopsis
githubactions
Package githubactions implements GitHub Actions workflow detection as a plugin-based component detector.
Package githubactions implements GitHub Actions workflow detection as a plugin-based component detector.
php
Package parsers provides parsers for various dependency management files.
Package parsers provides parsers for various dependency management files.
Package semver provides semantic version parsing and comparison for multiple package ecosystems.
Package semver provides semantic version parsing and comparison for multiple package ecosystems.

Jump to

Keyboard shortcuts

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