Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .codacy/codacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ tools:
- pmd@6.55.0
- pylint@3.3.9
- revive@1.12.0
- semgrep@1.78.0
- trivy@0.66.0
- opengrep@1.16.2
- trivy@0.69.3
- dartanalyzer@3.7.2
6 changes: 3 additions & 3 deletions cmd/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ var versionedToolNames = map[string]map[int]string{

var simpleToolAliases = map[string]string{
"lizard": "Lizard",
"semgrep": "Semgrep",
"opengrep": "Opengrep",
"pylint": "pylintpython3",
Comment on lines 274 to 277
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getToolName is called with strings.ToLower(run.Tool.Driver.Name) when processing SARIF uploads, but Opengrep's SARIF driver name is typically "Opengrep OSS". With the current alias map, "opengrep oss" won't be normalized to "Opengrep", so loadsToolAndPatterns won't find the tool and uploads can silently contain no issues. Consider normalizing SARIF tool names (e.g., strip a trailing " oss" / take the first token) or adding an explicit alias for "opengrep oss" -> "Opengrep".

Copilot uses AI. Check for mistakes.
"trivy": "Trivy",
}
Comment on lines 274 to 279
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getToolName now has an explicit alias for Opengrep, but TestGetToolName doesn't include any cases for opengrep (or the SARIF driver variant like "opengrep oss"). Adding test cases here would help prevent regressions in SARIF upload/analyze flows that rely on this mapping.

Copilot uses AI. Check for mistakes.
Expand Down Expand Up @@ -405,9 +405,9 @@ func runToolByName(toolName string, workDirectory string, pathsToCheck []string,
case "dartanalyzer":
binaryPath := tool.Binaries[tool.Runtime]
return tools.RunDartAnalyzer(workDirectory, tool.InstallDir, binaryPath, pathsToCheck, outputFile, outputFormat)
case "semgrep":
case "opengrep":
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runToolByName no longer handles the "semgrep" tool name, but the repository still ships the plugins/tools/semgrep plugin and plugins.GetSupportedTools() will report it as supported. This means users with existing codacy.yaml configs that still reference semgrep will pass validation but fail at runtime with "unsupported tool". Consider keeping a case "semgrep" that routes to Opengrep (or otherwise adding an explicit alias/normalization so semgrep configs keep working).

Suggested change
case "opengrep":
case "opengrep", "semgrep":

Copilot uses AI. Check for mistakes.
binaryPath := tool.Binaries[toolName]
return tools.RunSemgrep(workDirectory, binaryPath, pathsToCheck, outputFile, outputFormat)
return tools.RunOpengrep(workDirectory, binaryPath, pathsToCheck, outputFile, outputFormat)
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetSupportedTools() will still report semgrep as supported because plugins/tools/semgrep/plugin.yaml is still embedded, but runToolByName no longer has a case "semgrep". This leads to a confusing flow where validateToolName("semgrep") succeeds and then execution fails with “unsupported tool: semgrep”. Either keep a semgrep case (possibly delegating to opengrep for backwards compatibility) or remove/stop embedding the semgrep plugin so it’s not advertised as supported.

Suggested change
return tools.RunOpengrep(workDirectory, binaryPath, pathsToCheck, outputFile, outputFormat)
return tools.RunOpengrep(workDirectory, binaryPath, pathsToCheck, outputFile, outputFormat)
case "semgrep":
// Backwards compatibility: delegate semgrep to opengrep if available,
// otherwise fall back to a semgrep binary if defined.
binaryPath, ok := tool.Binaries["opengrep"]
if !ok {
binaryPath = tool.Binaries["semgrep"]
}
return tools.RunOpengrep(workDirectory, binaryPath, pathsToCheck, outputFile, outputFormat)

Copilot uses AI. Check for mistakes.
case "lizard":
binaryPath := tool.Binaries[tool.Runtime]
return lizard.RunLizard(workDirectory, binaryPath, pathsToCheck, outputFile, outputFormat)
Expand Down
2 changes: 1 addition & 1 deletion cmd/analyze_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func TestToolConfigFileNameMapCompleteness(t *testing.T) {
"pmd": constants.PMDConfigFileName,
"pylint": constants.PylintConfigFileName,
"dartanalyzer": constants.DartAnalyzerConfigFileName,
"semgrep": constants.SemgrepConfigFileName,
"opengrep": constants.OpengrepConfigFileName,
"revive": constants.ReviveConfigFileName,
"lizard": constants.LizardConfigFileName,
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func TestToolConfigFileNameMap(t *testing.T) {
"pmd": constants.PMDConfigFileName,
"pylint": constants.PylintConfigFileName,
"dartanalyzer": constants.DartAnalyzerConfigFileName,
"semgrep": constants.SemgrepConfigFileName,
"opengrep": constants.OpengrepConfigFileName,
"revive": constants.ReviveConfigFileName,
"lizard": constants.LizardConfigFileName,
}
Expand Down
20 changes: 10 additions & 10 deletions cmd/configsetup/tool_creators.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var toolConfigRegistry = map[string]ToolConfigCreator{
domain.PMD7: &pmd7ConfigCreator{},
domain.PyLint: &pylintConfigCreator{},
domain.DartAnalyzer: &dartAnalyzerConfigCreator{},
domain.Semgrep: &semgrepConfigCreator{},
domain.Opengrep: &opengrepConfigCreator{},
domain.Lizard: &lizardConfigCreator{},
domain.Revive: &reviveConfigCreator{},
}
Expand Down Expand Up @@ -121,23 +121,23 @@ func (d *dartAnalyzerConfigCreator) GetConfigFileName() string {
}
func (d *dartAnalyzerConfigCreator) GetToolName() string { return "Dart Analyzer" }

// semgrepConfigCreator implements ToolConfigCreator for Semgrep
type semgrepConfigCreator struct{}
// opengrepConfigCreator implements ToolConfigCreator for Opengrep
type opengrepConfigCreator struct{}

func (s *semgrepConfigCreator) CreateConfig(toolsConfigDir string, patterns []domain.PatternConfiguration) error {
configData, err := tools.GetSemgrepConfig(patterns)
func (s *opengrepConfigCreator) CreateConfig(toolsConfigDir string, patterns []domain.PatternConfiguration) error {
configData, err := tools.GetOpengrepConfig(patterns)
if err != nil {
return fmt.Errorf("failed to create Semgrep config: %v", err)
return fmt.Errorf("failed to create Opengrep config: %v", err)
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error wrap uses %v, which loses the underlying error for callers that want to unwrap/inspect it. Use %w when returning the error so it can be unwrapped (consistent with other error returns in this file).

Suggested change
return fmt.Errorf("failed to create Opengrep config: %v", err)
return fmt.Errorf("failed to create Opengrep config: %w", err)

Copilot uses AI. Check for mistakes.
}
err = writeConfigFile(filepath.Join(toolsConfigDir, constants.SemgrepConfigFileName), configData)
err = writeConfigFile(filepath.Join(toolsConfigDir, constants.OpengrepConfigFileName), configData)
if err == nil {
fmt.Println("Semgrep configuration created based on Codacy settings")
fmt.Println("Opengrep configuration created based on Codacy settings")
}
return err
}

func (s *semgrepConfigCreator) GetConfigFileName() string { return constants.SemgrepConfigFileName }
func (s *semgrepConfigCreator) GetToolName() string { return "Semgrep" }
func (s *opengrepConfigCreator) GetConfigFileName() string { return constants.OpengrepConfigFileName }
func (s *opengrepConfigCreator) GetToolName() string { return "Opengrep" }

// lizardConfigCreator implements ToolConfigCreator for Lizard
type lizardConfigCreator struct{}
Expand Down
2 changes: 1 addition & 1 deletion cmd/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestConfigFileTemplate(t *testing.T) {
"node@22.2.0",
"python@3.11.11",
"eslint@8.57.0",
"trivy@0.66.0",
"trivy@0.69.3",
"pylint@3.3.6",
"pmd@7.11.0",
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var sarifShortNameMap = map[string]string{
"Trivy": "trivy",
"Pylint": "pylintpython3",
"dartanalyzer": "dartanalyzer",
"Semgrep": "semgrep",
"Opengrep": "opengrep",
"Lizard": "lizard",
"revive": "revive",
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sarifShortNameMap no longer includes a mapping for "Semgrep". If a SARIF file was generated by Semgrep (or by older CLI versions) the upload flow may fail to resolve the tool short name/patterns. Either keep the "Semgrep": "semgrep" entry for backward compatibility, or ensure Semgrep is fully removed/unsupported end-to-end (including supported tools and docs).

Suggested change
"revive": "revive",
"revive": "revive",
"Semgrep": "semgrep",

Copilot uses AI. Check for mistakes.
}
Expand Down
93 changes: 73 additions & 20 deletions config/tools-installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"codacy/cli-v2/utils"
"codacy/cli-v2/utils/logger"
"fmt"
"io"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -297,29 +298,43 @@ func installDownloadBasedTool(toolInfo *plugins.ToolInfo) error {
return fmt.Errorf("failed to create installation directory: %w", err)
}

// Extract based on file extension
logger.Debug("Extracting tool", logrus.Fields{
"tool": toolInfo.Name,
"version": toolInfo.Version,
"fileName": fileName,
"extractDirectory": toolInfo.InstallDir,
})
isArchive := strings.HasSuffix(fileName, ".zip") || strings.HasSuffix(fileName, ".tar.gz") || strings.HasSuffix(fileName, ".tgz")

if strings.HasSuffix(fileName, ".zip") {
err = utils.ExtractZip(file.Name(), toolInfo.InstallDir)
} else {
err = utils.ExtractTarGz(file, toolInfo.InstallDir)
}
if isArchive {
// Extract based on file extension
logger.Debug("Extracting tool", logrus.Fields{
"tool": toolInfo.Name,
"version": toolInfo.Version,
"fileName": fileName,
"extractDirectory": toolInfo.InstallDir,
})

if err != nil {
return fmt.Errorf("failed to extract tool: %w", err)
}
if strings.HasSuffix(fileName, ".zip") {
err = utils.ExtractZip(file.Name(), toolInfo.InstallDir)
} else {
err = utils.ExtractTarGz(file, toolInfo.InstallDir)
}

if err != nil {
return fmt.Errorf("failed to extract tool: %w", err)
}

// Make sure all binaries are executable
for _, binaryPath := range toolInfo.Binaries {
err = os.Chmod(filepath.Join(toolInfo.InstallDir, filepath.Base(binaryPath)), constants.DefaultDirPerms)
if err != nil && !os.IsNotExist(err) {
return fmt.Errorf("failed to make binary executable: %w", err)
// Make sure all binaries are executable
for _, binaryPath := range toolInfo.Binaries {
err = os.Chmod(filepath.Join(toolInfo.InstallDir, filepath.Base(binaryPath)), constants.DefaultDirPerms)
if err != nil && !os.IsNotExist(err) {
return fmt.Errorf("failed to make binary executable: %w", err)
}
}
} else {
// Bare binary — copy directly to the binary destination path
logger.Debug("Installing bare binary", logrus.Fields{
"tool": toolInfo.Name,
"version": toolInfo.Version,
"downloadPath": downloadPath,
})
if err = installBareBinary(downloadPath, toolInfo); err != nil {
return fmt.Errorf("failed to install binary: %w", err)
Comment on lines +329 to +337
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the bare-binary branch, the previously opened file handle is unused (and installBareBinary re-opens the same path). Consider only opening the downloaded file inside the archive-extraction branch, or change installBareBinary to accept an io.Reader/already-open *os.File to avoid redundant opens and simplify control flow.

Copilot uses AI. Check for mistakes.
}
}

Expand All @@ -330,6 +345,44 @@ func installDownloadBasedTool(toolInfo *plugins.ToolInfo) error {
return nil
}

// installBareBinary copies a downloaded bare binary to its destination path and makes it executable.
func installBareBinary(downloadPath string, toolInfo *plugins.ToolInfo) error {
var destPath string
for _, p := range toolInfo.Binaries {
destPath = p
break
}
Comment on lines +351 to +354
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

installBareBinary picks the destination by taking the first value from the toolInfo.Binaries map. Map iteration order is non-deterministic, so this can select the wrong destination if a tool ever declares multiple binaries. Consider selecting a specific key (e.g., toolInfo.Binaries[toolInfo.Name]) or explicitly erroring unless exactly one binary destination is defined.

Suggested change
for _, p := range toolInfo.Binaries {
destPath = p
break
}
// Prefer a binary whose key matches the tool name, if present.
if p, ok := toolInfo.Binaries[toolInfo.Name]; ok && p != "" {
destPath = p
} else {
// Fallback: if there is exactly one binary entry, use that.
switch len(toolInfo.Binaries) {
case 0:
// Handled below as "no binary destination defined".
case 1:
for _, p := range toolInfo.Binaries {
destPath = p
break
}
default:
return fmt.Errorf("multiple binary destinations defined for tool %s and none matches its name", toolInfo.Name)
}
}

Copilot uses AI. Check for mistakes.
if destPath == "" {
return fmt.Errorf("no binary destination defined for tool %s", toolInfo.Name)
}
Comment on lines +350 to +357
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

installBareBinary selects the destination by taking the first value from toolInfo.Binaries, which is a map (iteration order is random). This can become nondeterministic/incorrect if a download-based tool ever defines multiple binaries. Consider selecting a specific key (e.g., tool name) or explicitly erroring unless exactly one binary path is defined.

Suggested change
var destPath string
for _, p := range toolInfo.Binaries {
destPath = p
break
}
if destPath == "" {
return fmt.Errorf("no binary destination defined for tool %s", toolInfo.Name)
}
if len(toolInfo.Binaries) == 0 {
return fmt.Errorf("no binary destination defined for tool %s", toolInfo.Name)
}
if len(toolInfo.Binaries) > 1 {
return fmt.Errorf("multiple binary destinations defined for tool %s; bare binary install supports exactly one", toolInfo.Name)
}
var destPath string
for _, p := range toolInfo.Binaries {
destPath = p
}

Copilot uses AI. Check for mistakes.

if err := os.MkdirAll(filepath.Dir(destPath), constants.DefaultDirPerms); err != nil {
return fmt.Errorf("failed to create binary directory: %w", err)
}
Comment on lines +359 to +361
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

destPath comes from toolInfo.Binaries, which is built using path.Join (forward slashes). Using filepath.Dir(destPath)/os.Create(destPath) here can produce inconsistent results on Windows when paths contain mixed separators. Consider normalizing destPath with filepath.FromSlash/filepath.Clean (or constructing binary paths with filepath.Join consistently) before creating directories/files.

Copilot uses AI. Check for mistakes.

src, err := os.Open(downloadPath)
if err != nil {
return fmt.Errorf("failed to open downloaded binary: %w", err)
}
defer src.Close()

dst, err := os.Create(destPath)
if err != nil {
return fmt.Errorf("failed to create binary file: %w", err)
}
defer dst.Close()

if _, err = io.Copy(dst, src); err != nil {
return fmt.Errorf("failed to copy binary: %w", err)
}

if err = os.Chmod(destPath, constants.DefaultDirPerms); err != nil {
return fmt.Errorf("failed to make binary executable: %w", err)
}

return nil
}

func installPythonTool(name string, toolInfo *plugins.ToolInfo) error {
logger.Debug("Starting Python tool installation", logrus.Fields{
"tool": toolInfo.Name,
Expand Down
4 changes: 2 additions & 2 deletions constants/tool_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const (
PMDConfigFileName = "ruleset.xml"
PylintConfigFileName = "pylint.rc"
DartAnalyzerConfigFileName = "analysis_options.yaml"
SemgrepConfigFileName = "semgrep.yaml"
OpengrepConfigFileName = "semgrep.yaml"
ReviveConfigFileName = "revive.toml"
LizardConfigFileName = "lizard.yaml"
)
Expand All @@ -24,7 +24,7 @@ var ToolConfigFileNames = map[string]string{
"pmd": PMDConfigFileName,
"pylint": PylintConfigFileName,
"dartanalyzer": DartAnalyzerConfigFileName,
"semgrep": SemgrepConfigFileName,
"opengrep": OpengrepConfigFileName,
"revive": ReviveConfigFileName,
"lizard": LizardConfigFileName,
}
4 changes: 2 additions & 2 deletions domain/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (
PMD7 string = "ed7e8287-707d-485a-a0cb-e211004432c2"
PyLint string = "31677b6d-4ae0-4f56-8041-606a8d7a8e61"
DartAnalyzer string = "d203d615-6cf1-41f9-be5f-e2f660f7850f"
Semgrep string = "6792c561-236d-41b7-ba5e-9d6bee0d548b"
Opengrep string = "6792c561-236d-41b7-ba5e-9d6bee0d548b"
Lizard string = "76348462-84b3-409a-90d3-955e90abfb87"
Revive string = "bd81d1f4-1406-402d-9181-1274ee09f1aa"
)
Expand All @@ -48,6 +48,6 @@ var SupportedToolsMetadata = map[string]ToolInfo{
Trivy: {Name: "trivy", Priority: 0},
DartAnalyzer: {Name: "dartanalyzer", Priority: 0},
Lizard: {Name: "lizard", Priority: 0},
Semgrep: {Name: "semgrep", Priority: 0},
Opengrep: {Name: "opengrep", Priority: 0},
Revive: {Name: "revive", Priority: 0},
}
4 changes: 2 additions & 2 deletions integration-tests/config-discover/expected/codacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tools:
- dartanalyzer@3.7.2
- eslint@8.57.0
- lizard@1.17.31
- opengrep@1.16.2
- pmd@7.11.0
- pylint@3.3.6
- semgrep@1.78.0
- trivy@0.66.0
- trivy@0.69.3
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ tools:
languages: [Go]
extensions: [.go]
files: []
- name: semgrep
- name: opengrep
languages: [Apex, C, CPP, CSharp, Dockerfile, Go, Java, Javascript, Kotlin, PHP, PLSQL, Python, Ruby, Rust, SQL, Scala, Shell, Swift, Terraform, TypeScript, YAML]
extensions: [.bash, .c, .cc, .cls, .cpp, .cs, .cxx, .dockerfile, .fnc, .gemspec, .go, .h, .hpp, .ino, .java, .jbuilder, .js, .jsm, .jsx, .kt, .kts, .mjs, .opal, .pck, .php, .pkb, .pkh, .pks, .plb, .pld, .plh, .pls, .podspec, .prc, .py, .rake, .rb, .rlib, .rs, .scala, .sh, .sql, .swift, .tf, .tpb, .tps, .trg, .trigger, .ts, .tsx, .tyb, .typ, .vue, .yaml, .yml]
extensions: [.bash, .c, .cc, .cls, .cpp, .cs, .cxx, .dockerfile, .env, .fnc, .gemspec, .go, .h, .hpp, .ino, .java, .jbuilder, .js, .jsm, .jsx, .kt, .kts, .mjs, .opal, .pck, .php, .pkb, .pkh, .pks, .plb, .pld, .plh, .pls, .podspec, .prc, .py, .rake, .rb, .rlib, .rs, .scala, .sh, .sql, .swift, .tf, .tpb, .tps, .trg, .trigger, .ts, .tsx, .tyb, .typ, .vue, .yaml, .yml]
files: []
- name: trivy
languages: [C, CPP, CSharp, Dart, Dockerfile, Elixir, Go, JSON, Java, Javascript, PHP, Python, Ruby, Rust, Scala, Swift, Terraform, TypeScript, XML, YAML]
extensions: [.c, .cc, .cpp, .cs, .cxx, .dart, .dockerfile, .ex, .exs, .gemspec, .go, .h, .hpp, .ino, .java, .jbuilder, .js, .jsm, .json, .jsx, .mjs, .opal, .php, .podspec, .pom, .py, .rake, .rb, .rlib, .rs, .scala, .swift, .tf, .ts, .tsx, .vue, .wsdl, .xml, .xsl, .yaml, .yml]
files: [.deps.json, Berksfile, Capfile, Cargo.lock, Cheffile, Directory.Packages.props, Dockerfile, Fastfile, Gemfile, Gemfile.lock, Guardfile, Package.resolved, Packages.props, Pipfile.lock, Podfile, Podfile.lock, Rakefile, Thorfile, Vagabondfile, Vagrantfile, build.sbt.lock, composer.lock, conan.lock, config.ru, go.mod, gradle.lockfile, mix.lock, package-lock.json, package.json, packages.config, packages.lock.json, pnpm-lock.yaml, poetry.lock, pom.xml, pubspec.lock, requirements.txt, uv.lock, yarn.lock]
extensions: [.c, .cc, .cpp, .cs, .cxx, .dart, .dockerfile, .env, .ex, .exs, .gemspec, .go, .h, .hpp, .ino, .java, .jbuilder, .js, .jsm, .json, .jsx, .mjs, .opal, .php, .podspec, .pom, .py, .rake, .rb, .rlib, .rs, .scala, .swift, .tf, .ts, .tsx, .vue, .wsdl, .xml, .xsl, .yaml, .yml]
files: [.deps.json, .env, .env.dev, .env.development, .env.prod, .env.production, .env.staging, Berksfile, Capfile, Cargo.lock, Cheffile, Directory.Packages.props, Dockerfile, Fastfile, Gemfile, Gemfile.lock, Guardfile, Package.resolved, Packages.props, Pipfile.lock, Podfile, Podfile.lock, Rakefile, Thorfile, Vagabondfile, Vagrantfile, build.sbt.lock, composer.lock, conan.lock, config.ru, go.mod, gradle.lockfile, mix.lock, package-lock.json, package.json, packages.config, packages.lock.json, pnpm-lock.yaml, poetry.lock, pom.xml, pubspec.lock, requirements.txt, uv.lock, yarn.lock]
4 changes: 2 additions & 2 deletions integration-tests/init-with-token/expected/codacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ runtimes:
tools:
- eslint@8.57.0
- lizard@1.17.31
- opengrep@1.16.2
- pmd@6.55.0
- pylint@3.3.9
- semgrep@1.78.0
- trivy@0.66.0
- trivy@0.69.3
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tools:
languages: [Python]
extensions: [.py]
files: []
- name: semgrep
- name: opengrep
languages: [Java, Javascript, Python]
extensions: [.java, .js, .jsm, .jsx, .mjs, .py, .vue]
files: []
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/init-without-token/expected/codacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ tools:
- dartanalyzer@3.7.2
- eslint@8.57.0
- lizard@1.17.31
- opengrep@1.16.2
- pmd@7.11.0
- pylint@3.3.6
- revive@1.7.0
- semgrep@1.78.0
- trivy@0.66.0
- trivy@0.69.3
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ tools:
languages: [Go]
extensions: [.go]
files: []
- name: semgrep
- name: opengrep
languages: [Apex, C, CPP, CSharp, Dockerfile, Go, Java, Javascript, Kotlin, PHP, PLSQL, Python, Ruby, Rust, SQL, Scala, Shell, Swift, Terraform, TypeScript, YAML]
extensions: [.bash, .c, .cc, .cls, .cpp, .cs, .cxx, .dockerfile, .fnc, .gemspec, .go, .h, .hpp, .ino, .java, .jbuilder, .js, .jsm, .jsx, .kt, .kts, .mjs, .opal, .pck, .php, .pkb, .pkh, .pks, .plb, .pld, .plh, .pls, .podspec, .prc, .py, .rake, .rb, .rlib, .rs, .scala, .sh, .sql, .swift, .tf, .tpb, .tps, .trg, .trigger, .ts, .tsx, .tyb, .typ, .vue, .yaml, .yml]
extensions: [.bash, .c, .cc, .cls, .cpp, .cs, .cxx, .dockerfile, .env, .fnc, .gemspec, .go, .h, .hpp, .ino, .java, .jbuilder, .js, .jsm, .jsx, .kt, .kts, .mjs, .opal, .pck, .php, .pkb, .pkh, .pks, .plb, .pld, .plh, .pls, .podspec, .prc, .py, .rake, .rb, .rlib, .rs, .scala, .sh, .sql, .swift, .tf, .tpb, .tps, .trg, .trigger, .ts, .tsx, .tyb, .typ, .vue, .yaml, .yml]
files: []
- name: trivy
languages: [C, CPP, CSharp, Dart, Dockerfile, Elixir, Go, JSON, Java, Javascript, PHP, Python, Ruby, Rust, Scala, Swift, Terraform, TypeScript, XML, YAML]
extensions: [.c, .cc, .cpp, .cs, .cxx, .dart, .dockerfile, .ex, .exs, .gemspec, .go, .h, .hpp, .ino, .java, .jbuilder, .js, .jsm, .json, .jsx, .mjs, .opal, .php, .podspec, .pom, .py, .rake, .rb, .rlib, .rs, .scala, .swift, .tf, .ts, .tsx, .vue, .wsdl, .xml, .xsl, .yaml, .yml]
files: [.deps.json, Berksfile, Capfile, Cargo.lock, Cheffile, Directory.Packages.props, Dockerfile, Fastfile, Gemfile, Gemfile.lock, Guardfile, Package.resolved, Packages.props, Pipfile.lock, Podfile, Podfile.lock, Rakefile, Thorfile, Vagabondfile, Vagrantfile, build.sbt.lock, composer.lock, conan.lock, config.ru, go.mod, gradle.lockfile, mix.lock, package-lock.json, package.json, packages.config, packages.lock.json, pnpm-lock.yaml, poetry.lock, pom.xml, pubspec.lock, requirements.txt, uv.lock, yarn.lock]
extensions: [.c, .cc, .cpp, .cs, .cxx, .dart, .dockerfile, .env, .ex, .exs, .gemspec, .go, .h, .hpp, .ino, .java, .jbuilder, .js, .jsm, .json, .jsx, .mjs, .opal, .php, .podspec, .pom, .py, .rake, .rb, .rlib, .rs, .scala, .swift, .tf, .ts, .tsx, .vue, .wsdl, .xml, .xsl, .yaml, .yml]
files: [.deps.json, .env, .env.dev, .env.development, .env.prod, .env.production, .env.staging, Berksfile, Capfile, Cargo.lock, Cheffile, Directory.Packages.props, Dockerfile, Fastfile, Gemfile, Gemfile.lock, Guardfile, Package.resolved, Packages.props, Pipfile.lock, Podfile, Podfile.lock, Rakefile, Thorfile, Vagabondfile, Vagrantfile, build.sbt.lock, composer.lock, conan.lock, config.ru, go.mod, gradle.lockfile, mix.lock, package-lock.json, package.json, packages.config, packages.lock.json, pnpm-lock.yaml, poetry.lock, pom.xml, pubspec.lock, requirements.txt, uv.lock, yarn.lock]
1 change: 1 addition & 0 deletions plugins/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type DownloadConfig struct {
FileNameTemplate string `yaml:"file_name_template"`
Extension ExtensionConfig `yaml:"extension"`
ArchMapping map[string]string `yaml:"arch_mapping"`
OSArchMapping map[string]string `yaml:"os_arch_mapping"`
OSMapping map[string]string `yaml:"os_mapping"`
ReleaseVersion string `yaml:"release_version,omitempty"`
}
Expand Down
6 changes: 5 additions & 1 deletion plugins/tool-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,12 @@ func ProcessTools(configs []ToolConfig, toolDir string, runtimes map[string]*Run

// Handle download configuration for directly downloaded tools
if pluginConfig.Download.URLTemplate != "" {
// Get the mapped architecture
// Get the mapped architecture, with optional OS-specific override
mappedArch := GetMappedArch(pluginConfig.Download.ArchMapping, runtime.GOARCH)
osArchKey := fmt.Sprintf("%s_%s", runtime.GOOS, runtime.GOARCH)
if override, ok := pluginConfig.Download.OSArchMapping[osArchKey]; ok {
mappedArch = override
}

// Get the mapped OS
mappedOS := GetMappedOS(pluginConfig.Download.OSMapping, runtime.GOOS)
Expand Down
2 changes: 1 addition & 1 deletion plugins/tool-utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func TestGetSupportedTools(t *testing.T) {
"pylint",
"trivy",
"dartanalyzer",
"semgrep",
"opengrep",
"lizard",
"codacy-enigma-cli",
"revive",
Expand Down
17 changes: 17 additions & 0 deletions plugins/tools/opengrep/embedded/opengrep.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Package embedded provides access to embedded Opengrep rules.
package embedded

import "embed"

//go:embed rules.yaml
var rulesFS embed.FS

// GetOpengrepRules returns the embedded Opengrep rules.
// Opengrep is compatible with the semgrep rule format, so the same rules are used.
func GetOpengrepRules() []byte {
data, err := rulesFS.ReadFile("rules.yaml")
if err != nil {
panic(err) // This should never happen as the file is embedded
}
return data
}
Loading
Loading