matchers

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildExtensionMatchersFromRules

func BuildExtensionMatchersFromRules(rules []types.Rule)

BuildExtensionMatchersFromRules creates extension matchers from rules

func BuildFileMatchersFromRules

func BuildFileMatchersFromRules(rules []types.Rule)

BuildFileMatchersFromRules creates file matchers from rules

func ClearExtensionMatchers

func ClearExtensionMatchers()

ClearExtensionMatchers clears all registered extension matchers (useful for testing)

func ClearFileMatchers

func ClearFileMatchers()

ClearFileMatchers clears all registered file matchers (useful for testing)

func MatchExtensions

func MatchExtensions(files []types.File) map[string][]string

MatchExtensions runs all extension matchers and returns matched techs Returns a map of tech -> reasons

func MatchFiles

func MatchFiles(files []types.File, currentPath, basePath string) map[string][]string

MatchFiles runs all file matchers and returns matched techs Returns a map of tech -> reasons

func RegisterExtensionMatcher

func RegisterExtensionMatcher(matcher ExtensionMatcher)

RegisterExtensionMatcher adds an extension matcher to the registry

func RegisterFileMatcher

func RegisterFileMatcher(matcher FileMatcher)

RegisterFileMatcher adds a file matcher to the registry

Types

type CompiledContentMatcher

type CompiledContentMatcher interface {
	// Match checks if the content matches, returns (matched, reason)
	Match(content string) (bool, string)

	// Tech returns the technology this matcher detects
	Tech() string
}

CompiledContentMatcher is a pre-compiled matcher ready for matching

type ContentMatcherRegistry

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

ContentMatcherRegistry manages compiled content matchers

func NewContentMatcherRegistry

func NewContentMatcherRegistry() *ContentMatcherRegistry

NewContentMatcherRegistry creates a new content matcher registry

func (*ContentMatcherRegistry) BuildFromRules

func (r *ContentMatcherRegistry) BuildFromRules(rules []types.Rule) error

BuildFromRules compiles content patterns from rules

func (*ContentMatcherRegistry) HasContentMatchers

func (r *ContentMatcherRegistry) HasContentMatchers(extension string) bool

HasContentMatchers checks if there are any content matchers for the given extension

func (*ContentMatcherRegistry) HasFileMatchers

func (r *ContentMatcherRegistry) HasFileMatchers(filename string) bool

HasFileMatchers checks if there are any content matchers for the given filename

func (*ContentMatcherRegistry) MatchContent

func (r *ContentMatcherRegistry) MatchContent(extension string, content string) map[string][]string

MatchContent checks if content matches any patterns for the given extension Returns map of tech -> reasons Stops after first match per tech (rule is satisfied with one pattern match)

func (*ContentMatcherRegistry) MatchFileContent

func (r *ContentMatcherRegistry) MatchFileContent(filename string, content string) map[string][]string

MatchFileContent checks if content matches any patterns for the given filename Returns map of tech -> reasons

func (*ContentMatcherRegistry) RegisterContentType

func (r *ContentMatcherRegistry) RegisterContentType(matcher ContentTypeMatcher)

RegisterContentType adds a custom content type matcher

type ContentTypeMatcher

type ContentTypeMatcher interface {
	// Type returns the content type identifier (e.g., "regex", "json-path", "json-schema")
	Type() string

	// Compile prepares the matcher from a content rule, returns error if invalid
	Compile(rule types.ContentRule, tech string) (CompiledContentMatcher, error)
}

ContentTypeMatcher is the interface for all content type matchers Implement this interface to add new content matching types

type ContentTypeRegistry

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

ContentTypeRegistry manages registered content type matchers

func NewContentTypeRegistry

func NewContentTypeRegistry() *ContentTypeRegistry

NewContentTypeRegistry creates a new registry with default matchers

func (*ContentTypeRegistry) Compile

Compile compiles a content rule using the appropriate matcher

func (*ContentTypeRegistry) Get

func (r *ContentTypeRegistry) Get(contentType string) ContentTypeMatcher

Get returns the matcher for a given type, or nil if not found

func (*ContentTypeRegistry) Register

func (r *ContentTypeRegistry) Register(matcher ContentTypeMatcher)

Register adds a content type matcher to the registry

func (*ContentTypeRegistry) SupportedTypes

func (r *ContentTypeRegistry) SupportedTypes() []string

SupportedTypes returns all registered content type names

type ExtensionMatcher

type ExtensionMatcher func(extensions []string) (tech string, matchedExt string, matched bool)

ExtensionMatcher is a function that matches file extensions and returns the matched tech

func GetExtensionMatchers

func GetExtensionMatchers() []ExtensionMatcher

GetExtensionMatchers returns all registered extension matchers

type FileMatcher

type FileMatcher func(files []types.File, currentPath, basePath string) (tech string, matchedFile string, matched bool)

FileMatcher is a function that matches files and returns the matched tech and file

func GetFileMatchers

func GetFileMatchers() []FileMatcher

GetFileMatchers returns all registered file matchers

type JSONPathContentMatcher

type JSONPathContentMatcher struct{}

JSONPathContentMatcher handles JSON path matching

func (*JSONPathContentMatcher) Compile

func (*JSONPathContentMatcher) Type

func (m *JSONPathContentMatcher) Type() string

type RegexContentMatcher

type RegexContentMatcher struct{}

RegexContentMatcher handles regex-based content matching (default type)

func (*RegexContentMatcher) Compile

func (*RegexContentMatcher) Type

func (m *RegexContentMatcher) Type() string

type XMLPathContentMatcher

type XMLPathContentMatcher struct{}

XMLPathContentMatcher handles XML XPath-like content matching

func (*XMLPathContentMatcher) Compile

func (*XMLPathContentMatcher) Type

func (m *XMLPathContentMatcher) Type() string

type YAMLPathContentMatcher

type YAMLPathContentMatcher struct{}

YAMLPathContentMatcher handles YAML path-based content matching Supports simple dot-notation paths like "$.name", "$.services.web"

func (*YAMLPathContentMatcher) Compile

func (*YAMLPathContentMatcher) Type

func (m *YAMLPathContentMatcher) Type() string

Jump to

Keyboard shortcuts

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