patternmining

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Miner

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

Miner performs pattern mining on subdomain data

func NewMiner

func NewMiner(opts *Options) *Miner

NewMiner creates a new pattern miner

func (*Miner) EstimateCount

func (m *Miner) EstimateCount(patterns []string) int64

EstimateCount estimates the number of subdomains that would be generated from patterns This uses the DFA's NumWords method to count without actually generating strings

func (*Miner) GenerateFromPatterns

func (m *Miner) GenerateFromPatterns(patterns []string) []string

GenerateFromPatterns generates subdomains from discovered patterns

func (*Miner) Mine

func (m *Miner) Mine() (*Result, error)

Mine discovers patterns from input domains

func (*Miner) SaveRules

func (m *Miner) SaveRules(result *Result, filename string) error

SaveRules writes discovered patterns and metadata to a single JSON file

type Options

type Options struct {
	// Input domains to analyze
	Domains []string
	// Target domain (e.g., "example.com")
	Target string
	// MinDistance is the minimum levenshtein distance for clustering
	MinDistance int
	// MaxDistance is the maximum levenshtein distance for clustering
	MaxDistance int
	// PatternThreshold is the threshold for pattern quality filtering
	PatternThreshold int
	// QualityRatio is the maximum ratio of synthetic/observed for pattern validation
	QualityRatio float64
	// MaxLength is the maximum pattern length
	MaxLength int
	// NgramsLimit limits the number of n-grams to process (0 = no limit)
	NgramsLimit int
}

Options contains pattern mining configuration

type PatternMetadata

type PatternMetadata struct {
	Mode        string   `json:"mode"`
	K           *int     `json:"k,omitempty"`
	Ngram       string   `json:"ngram,omitempty"`
	Prefix      string   `json:"prefix,omitempty"`
	ClusterSize int      `json:"cluster_size"`
	Nwords      int      `json:"nwords"`
	Ratio       float64  `json:"ratio"`
	Members     []string `json:"members,omitempty"`
}

PatternMetadata contains metadata about a discovered pattern

type Result

type Result struct {
	Patterns []string
	Metadata map[string]map[string]interface{}
}

Result contains discovered patterns and metadata

type RuleEntry

type RuleEntry struct {
	Pattern string           `json:"pattern"`
	Meta    *PatternMetadata `json:"meta"`
}

RuleEntry represents a pattern with its metadata

type RulesOutput

type RulesOutput struct {
	Steps []*StepGroup `json:"steps"`
}

RulesOutput is the top-level structure for saved rules

type StepGroup

type StepGroup struct {
	Step    string       `json:"step"`
	Entries []*RuleEntry `json:"entries"`
}

StepGroup represents a mining step with its discovered patterns

Jump to

Keyboard shortcuts

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