Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( DefaultDetectors = []Detector{ RubyDetector, GoDetector, JavascriptDetector, PythonDetector, } DetectorsByFlag = map[string]Detector{ "django": DjangoDetector, "flask": FlaskDetector, "go": GoDetector, "javascript": JavascriptDetector, "python": PythonDetector, "rails": RailsDetector, "ruby": RubyDetector, "sinatra": SinatraDetector, } PositiveDetectionMessage = "%s project detected with confidence level %s!\n" )
var DjangoDetector = &FileDetector{ Title: "django", Paths: DjangoFiles, FollowUpDetectors: nil, AnchorCategory: anchorcli.CategoryPython, }
var DjangoFiles []string = []string{"requirements.txt", "manage.py"}
Python Frameworks
var FlaskDetector = &FileDetector{ Title: "flask", Paths: FlaskFiles, FollowUpDetectors: nil, AnchorCategory: anchorcli.CategoryPython, }
var FlaskFiles []string = []string{"requirements.txt", "app.py"}
var GoDetector = &FileDetector{ Title: "go", Paths: []string{"main.go", "go.mod", "go.sum"}, FollowUpDetectors: nil, AnchorCategory: anchorcli.CategoryGo, }
GoDetector is a Go detector
var JavascriptDetector = &FileDetector{ Title: "javascript", Paths: []string{"package.json", "index.js", "app.js"}, FollowUpDetectors: nil, AnchorCategory: anchorcli.CategoryJavascript, }
JavascriptDetector is a JavaScript detector
var PythonDetector = &FileDetector{ Title: "python", Paths: []string{"requirements.txt"}, FollowUpDetectors: []Detector{DjangoDetector, FlaskDetector}, AnchorCategory: anchorcli.CategoryPython, }
PythonDetector is a Python detector with Django and Flask follow-up detectors
var RailsDetector = &FileDetector{ Title: "rails", Paths: RailsFiles, FollowUpDetectors: nil, AnchorCategory: anchorcli.CategoryRuby, }
var RailsFiles []string = []string{"Gemfile", "Rakefile", "config.ru", "app", "config", "db", "lib", "public", "vendor"}
Ruby Frameworks
var RubyDetector = &FileDetector{ Title: "ruby", Paths: []string{"Gemfile", "Gemfile.lock", "Rakefile"}, FollowUpDetectors: []Detector{RailsDetector, SinatraDetector}, AnchorCategory: anchorcli.CategoryRuby, }
RubyDetector is a detector for Ruby projects.
var SinatraDetector = &FileDetector{ Title: "sinatra", Paths: SinatraFiles, FollowUpDetectors: nil, AnchorCategory: anchorcli.CategoryRuby, RequiredFiles: []string{"app.rb"}, }
var SinatraFiles []string = []string{"Gemfile", "config.ru", "app.rb"}
var SupportedPackageManagers = []PackageManager{ RubyGemsPkgManager, NPMPkgManager, YarnPkgManager, }
Functions ¶
This section is empty.
Types ¶
type Confidence ¶
type Confidence int
Confidence represents the confidence score
const ( High Confidence = 100 Medium Confidence = 60 Low Confidence = 40 None Confidence = 0 )
Different confidence levels
func (Confidence) String ¶
func (s Confidence) String() string
Confidence.String() returns the string representation of the confidence level
type Detector ¶
type Detector interface {
GetTitle() string
Detect(directory string) (Match, error)
FollowUp() []Detector
}
Detector interface represents a project detector
type FileDetector ¶
type FileDetector struct {
Title string
Paths []string
RequiredFiles []string
FollowUpDetectors []Detector
FileSystem fs.StatFS
AnchorCategory *anchorcli.Category
}
FileDetector is a generic file-based project detector
func (FileDetector) Detect ¶
func (fd FileDetector) Detect(directory string) (Match, error)
Detect checks if the directory contains any of the specified files
func (FileDetector) FollowUp ¶
func (fd FileDetector) FollowUp() []Detector
FollowUp returns additional detectors
func (FileDetector) GetTitle ¶
func (fd FileDetector) GetTitle() string
GetTitle returns the name of the detector
type Match ¶
type Match struct {
Detector Detector
Detected bool
Confidence Confidence
// MissingRequiredFiles represents a list of files that are required but missing.
MissingRequiredFiles []string
FollowUpDetectors []Detector
Details string
AnchorCategory *anchorcli.Category
}
Match holds the detection result, confidence, and follow-up detectors
type PackageManager ¶
type PackageManager string
const ( RubyGemsPkgManager PackageManager = "rubygems" NPMPkgManager PackageManager = "npm" YarnPkgManager PackageManager = "yarn" )
func (PackageManager) String ¶
func (pm PackageManager) String() string
type PackageManagerManifest ¶
type PackageManagerManifest string
const ( Gemfile PackageManagerManifest = "Gemfile" GemfileLock PackageManagerManifest = "Gemfile.lock" PackageJSON PackageManagerManifest = "package.json" PackageLockJSON PackageManagerManifest = "package-lock.json" YarnLock PackageManagerManifest = "yarn.lock" )
func (PackageManagerManifest) String ¶
func (pmm PackageManagerManifest) String() string