@@ -65,8 +65,15 @@ func FilterRulesFromFile(rulesFilePath string, config []domain.PatternConfigurat
6565
6666// GetSemgrepConfig gets the Semgrep configuration based on the pattern configuration
6767func GetSemgrepConfig (config []domain.PatternConfiguration ) ([]byte , error ) {
68- // Get the default rules file location
69- rulesFile := filepath .Join ("plugins" , "tools" , "semgrep" , "rules.yaml" )
68+ // Get the executable's directory
69+ execPath , err := os .Executable ()
70+ if err != nil {
71+ return nil , fmt .Errorf ("failed to get executable path: %w" , err )
72+ }
73+ execDir := filepath .Dir (execPath )
74+
75+ // Get the default rules file location relative to the executable
76+ rulesFile := filepath .Join (execDir , "plugins" , "tools" , "semgrep" , "rules.yaml" )
7077
7178 // Check if it exists and config is not empty
7279 if _ , err := os .Stat (rulesFile ); err == nil && len (config ) > 0 {
@@ -80,8 +87,15 @@ func GetSemgrepConfig(config []domain.PatternConfiguration) ([]byte, error) {
8087
8188// GetDefaultSemgrepConfig gets the default Semgrep configuration
8289func GetDefaultSemgrepConfig () ([]byte , error ) {
83- // Get the default rules file location
84- rulesFile := filepath .Join ("plugins" , "tools" , "semgrep" , "rules.yaml" )
90+ // Get the executable's directory
91+ execPath , err := os .Executable ()
92+ if err != nil {
93+ return nil , fmt .Errorf ("failed to get executable path: %w" , err )
94+ }
95+ execDir := filepath .Dir (execPath )
96+
97+ // Get the default rules file location relative to the executable
98+ rulesFile := filepath .Join (execDir , "plugins" , "tools" , "semgrep" , "rules.yaml" )
8599
86100 // If the file exists, return its contents
87101 if _ , err := os .Stat (rulesFile ); err == nil {
0 commit comments