@@ -27,6 +27,7 @@ type Config struct {
2727 Enabled bool
2828 DBPath string
2929 ModelPath string
30+ EmbeddingsPath string // Path to embeddings models directory
3031 SimilarityThreshold float32
3132 EphemeralStore bool
3233 LLMEndpoint string
@@ -44,8 +45,17 @@ func NewPipeline(config *Config) (*Pipeline, error) {
4445 embeddingGen := embeddings .NewEmbeddingGenerator (config .Enabled )
4546
4647 // Initialize BGE embeddings with ONNX model
47- if config .Enabled && config .ModelPath != "" {
48- modelsDir := filepath .Dir (config .ModelPath )
48+ // Use EmbeddingsPath if specified, otherwise try to derive from ModelPath, or default to .gosecretscanner/models
49+ if config .Enabled {
50+ var modelsDir string
51+ if config .EmbeddingsPath != "" {
52+ modelsDir = config .EmbeddingsPath
53+ } else if config .ModelPath != "" {
54+ modelsDir = filepath .Dir (config .ModelPath )
55+ } else {
56+ modelsDir = ".gosecretscanner/models"
57+ }
58+
4959 if err := embeddingGen .Initialize (modelsDir ); err != nil {
5060 // Non-fatal: fall back to hash-based embeddings
5161 fmt .Printf ("Warning: failed to initialize BGE embeddings, using hash-based fallback: %v\n " , err )
@@ -105,12 +115,15 @@ func (p *Pipeline) VerifyFinding(
105115 return nil , fmt .Errorf ("failed to parse file: %w" , err )
106116 }
107117
118+ // Get surrounding code context (±5 lines)
119+ surroundingCode := p .parser .GetContext (content , lineNumber , 5 )
120+
108121 // Create code context
109122 codeContext := & llm.CodeContext {
110123 FilePath : filePath ,
111124 Language : parsed .Language ,
112125 Function : p .findFunction (parsed , lineNumber ),
113- SurroundingCode : line ,
126+ SurroundingCode : surroundingCode ,
114127 Imports : parsed .Imports ,
115128 IsTest : parsed .IsTest ,
116129 }
0 commit comments