Skip to content

Commit 094d3ed

Browse files
feat: enhance semgrep configuration handling
- Implemented logic to check for the existence of a custom Semgrep configuration file (.semgrep.yml) and use it if available. - Default to using the 'auto' configuration only if no custom config file is found.
1 parent 1aed4c6 commit 094d3ed

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tools/semgrepRunner.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package tools
22

33
import (
4+
"codacy/cli-v2/config"
45
"codacy/cli-v2/plugins"
56
"fmt"
67
"os"
@@ -18,8 +19,13 @@ func RunSemgrep(workDirectory string, toolInfo *plugins.ToolInfo, files []string
1819
cmdArgs = append(cmdArgs, "--sarif")
1920
}
2021

21-
// add --config auto
22-
cmdArgs = append(cmdArgs, "--config", "auto")
22+
// Check if a config file exists in the expected location and use it if present
23+
if configFile, exists := ConfigFileExists(config.Config, ".semgrep.yml"); exists {
24+
cmdArgs = append(cmdArgs, "--config", configFile)
25+
} else {
26+
// add --config auto only if no config file exists
27+
cmdArgs = append(cmdArgs, "--config", "auto")
28+
}
2329

2430
// Add files to analyze - if no files specified, analyze current directory
2531
if len(files) > 0 {

0 commit comments

Comments
 (0)