detector

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package detector provides typosquatting and threat detection algorithms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CharacterSubstitution

type CharacterSubstitution struct {
	Original    rune
	Substitutes []rune
	Type        string // "visual", "phonetic", "keyboard"
	Weight      float64
}

CharacterSubstitution represents common character substitution patterns

type CheckPackageResult

type CheckPackageResult struct {
	Threats  []types.Threat
	Warnings []types.Warning
}

type CommunityFlag

type CommunityFlag struct {
	Type        string    `json:"type"`
	Description string    `json:"description"`
	Reporter    string    `json:"reporter"`
	ReportedAt  time.Time `json:"reported_at"`
	Verified    bool      `json:"verified"`
}

CommunityFlag represents community-reported issues

type Engine

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

func New

func New(cfg *config.Config) *Engine

func (*Engine) AnalyzeDependency

func (e *Engine) AnalyzeDependency(dep types.Dependency, popularPackages []string, options *Options) ([]types.Threat, []types.Warning)

func (*Engine) CheckPackage

func (e *Engine) CheckPackage(ctx context.Context, name, registry string) (*CheckPackageResult, error)

func (*Engine) Version

func (e *Engine) Version() string

type EnhancedDetectionConfig

type EnhancedDetectionConfig struct {
	KeyboardProximityWeight  float64
	VisualSimilarityWeight   float64
	PhoneticSimilarityWeight float64
	MinSimilarityThreshold   float64
	MaxEditDistance          int
	EnableKeyboardAnalysis   bool
	EnableVisualAnalysis     bool
	EnablePhoneticAnalysis   bool
}

EnhancedDetectionConfig contains configuration for enhanced detection

type EnhancedSupplyChainDetector added in v1.0.1

type EnhancedSupplyChainDetector struct{}

func NewEnhancedSupplyChainDetector added in v1.0.1

func NewEnhancedSupplyChainDetector() *EnhancedSupplyChainDetector

func (*EnhancedSupplyChainDetector) DetectThreats added in v1.0.1

type EnhancedSupplyChainResult added in v1.0.1

type EnhancedSupplyChainResult struct {
	Package           string
	Registry          string
	ThreatType        string
	Severity          string
	ConfidenceScore   float64
	IsFiltered        bool
	Recommendations   []string
	SupplyChainRisk   float64
	FalsePositiveRisk float64
	FilterReasons     []string
	Evidence          []string
}

type EnhancedTyposquattingDetector

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

EnhancedTyposquattingDetector implements advanced typosquatting detection

func NewEnhancedTyposquattingDetector

func NewEnhancedTyposquattingDetector() *EnhancedTyposquattingDetector

NewEnhancedTyposquattingDetector creates a new enhanced detector

func (*EnhancedTyposquattingDetector) DetectEnhanced

func (etd *EnhancedTyposquattingDetector) DetectEnhanced(target types.Dependency, allPackages []string, threshold float64) []types.Threat

DetectEnhanced performs enhanced typosquatting detection

type HomoglyphDetector

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

HomoglyphDetector detects homoglyph-based typosquatting attacks

func NewHomoglyphDetector

func NewHomoglyphDetector() *HomoglyphDetector

NewHomoglyphDetector creates a new homoglyph detector

func (*HomoglyphDetector) Detect

func (hd *HomoglyphDetector) Detect(target types.Dependency, allPackages []string) []types.Threat

Detect finds potential homoglyph-based typosquatting

type KeyboardLayout

type KeyboardLayout struct {
	Name   string
	Layout map[rune][]rune // character -> adjacent characters
	Rows   []string        // keyboard rows for row-based analysis
}

KeyboardLayout represents different keyboard layouts for proximity analysis

type MalwareReport

type MalwareReport struct {
	Source      string    `json:"source"`
	Type        string    `json:"type"`
	Description string    `json:"description"`
	Confidence  float64   `json:"confidence"`
	ReportedAt  time.Time `json:"reported_at"`
}

MalwareReport represents a malware detection report

type Options

type Options struct {
	SimilarityThreshold float64
	DeepAnalysis        bool
}

type ReputationData

type ReputationData struct {
	PackageName     string                 `json:"package_name"`
	Registry        string                 `json:"registry"`
	ReputationScore float64                `json:"reputation_score"`
	TrustLevel      string                 `json:"trust_level"`
	DownloadCount   int64                  `json:"download_count"`
	MaintainerCount int                    `json:"maintainer_count"`
	LastUpdated     time.Time              `json:"last_updated"`
	CreatedAt       time.Time              `json:"created_at"`
	Vulnerabilities []VulnerabilityInfo    `json:"vulnerabilities"`
	MalwareReports  []MalwareReport        `json:"malware_reports"`
	CommunityFlags  []CommunityFlag        `json:"community_flags"`
	Metadata        map[string]interface{} `json:"metadata"`
	CachedAt        time.Time              `json:"cached_at"`
}

ReputationData holds reputation information for a package

type ReputationEngine

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

ReputationEngine analyzes package reputation using multiple data sources

func NewReputationEngine

func NewReputationEngine(cfg *config.Config) *ReputationEngine

NewReputationEngine creates a new reputation engine

func (*ReputationEngine) Analyze

func (re *ReputationEngine) Analyze(dep types.Dependency) []types.Threat

Analyze analyzes the reputation of a package (alias for AnalyzeReputation)

func (*ReputationEngine) AnalyzeReputation

func (re *ReputationEngine) AnalyzeReputation(dep types.Dependency) []types.Threat

AnalyzeReputation analyzes the reputation of a package

func (*ReputationEngine) ClearCache

func (re *ReputationEngine) ClearCache()

ClearCache clears the reputation cache

func (*ReputationEngine) GetCacheStats

func (re *ReputationEngine) GetCacheStats() map[string]interface{}

GetCacheStats returns cache statistics

type TyposquattingAnalysis

type TyposquattingAnalysis struct {
	KeyboardErrors     int
	VisualSimilarity   float64
	PhoneticSimilarity float64
	EditDistance       int
	Transpositions     int
	Insertions         int
	Deletions          int
	Substitutions      int
	PrimaryType        string
}

TyposquattingAnalysis contains detailed analysis of typosquatting type

type VulnerabilityInfo

type VulnerabilityInfo struct {
	CVE         string    `json:"cve"`
	Severity    string    `json:"severity"`
	Description string    `json:"description"`
	PublishedAt time.Time `json:"published_at"`
	FixedIn     string    `json:"fixed_in"`
}

VulnerabilityInfo represents a known vulnerability

Jump to

Keyboard shortcuts

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