Documentation
¶
Overview ¶
Package extractor provides signature extraction from scanned files.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExtractOptions ¶
type ExtractOptions struct {
// IncludePrivate whether to include non-exported/private signatures.
IncludePrivate bool
// IncludeBody whether to include function/method bodies.
IncludeBody bool
// IncludeImports whether to include import/export statements.
IncludeImports bool
// IncludeCalls whether to include function call references.
IncludeCalls bool
// Concurrency is the number of concurrent workers.
// 0 = auto (runtime.NumCPU()), 1 = sequential.
Concurrency int
// MaxFileSize is the maximum file size in bytes for TOCTOU re-check.
// If positive, file content size is verified after reading.
MaxFileSize int64
}
ExtractOptions configures the extraction behavior.
func DefaultExtractOptions ¶ added in v0.18.0
func DefaultExtractOptions() *ExtractOptions
DefaultExtractOptions returns ExtractOptions with sensible defaults. Concurrency defaults to 0 (auto = runtime.NumCPU()).
Example ¶
package main
import (
"fmt"
"github.com/indigo-net/Brf.it/pkg/extractor"
)
func main() {
opts := extractor.DefaultExtractOptions()
fmt.Println(opts.Concurrency)
fmt.Println(opts.IncludePrivate)
fmt.Println(opts.IncludeBody)
}
Output: 0 false false
type ExtractResult ¶
type ExtractResult struct {
// Files is the list of extracted files.
Files []ExtractedFile
// TotalSignatures is the total number of signatures extracted.
TotalSignatures int
// TotalSize is the total size of processed files.
TotalSize int64
// ErrorCount is the number of files that had errors.
ErrorCount int
}
ExtractResult contains the results of an extraction operation.
type ExtractedFile ¶
type ExtractedFile struct {
// Path is the file path.
Path string
// Language is the detected language.
Language string
// Signatures is the list of extracted signatures.
Signatures []parser.Signature
// RawImports is the list of raw import/export statement text.
RawImports []string
// Calls is the list of function call references.
Calls []parser.FunctionCall
// Size is the file size in bytes.
Size int64
// Error is any error that occurred during extraction.
Error error
}
ExtractedFile represents a file with its extracted signatures.
type Extractor ¶
type Extractor interface {
// Extract extracts signatures from the given scan result.
// The context controls cancellation and timeout for the extraction.
Extract(ctx context.Context, scanResult *scanner.ScanResult, opts *ExtractOptions) (*ExtractResult, error)
}
Extractor defines the interface for signature extraction.
type FileExtractor ¶
type FileExtractor struct {
// contains filtered or unexported fields
}
FileExtractor implements Extractor using Scanner and Parser Registry.
func NewDefaultFileExtractor ¶
func NewDefaultFileExtractor() *FileExtractor
NewDefaultFileExtractor creates a FileExtractor with the default registry.
func NewFileExtractor ¶
func NewFileExtractor(registry *parser.Registry) *FileExtractor
NewFileExtractor creates a new FileExtractor with the given registry.
func (*FileExtractor) Extract ¶
func (e *FileExtractor) Extract(ctx context.Context, scanResult *scanner.ScanResult, opts *ExtractOptions) (*ExtractResult, error)
Extract implements Extractor interface.