Skip to content
Merged
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 @@ -8,9 +8,9 @@ tools:
- codacy-enigma-cli@0.0.1-main.8.49310c3
- dartanalyzer@3.7.2
- eslint@8.57.0
- lizard@1.17.19
- lizard@1.17.31
- pmd@6.55.0
- pylint@3.3.6
- revive@1.7.0
- semgrep@1.78.0
- trivy@0.59.1
- trivy@0.65.0
4 changes: 2 additions & 2 deletions cmd/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func init() {
rootCmd.AddCommand(analyzeCmd)
}

func loadsToolAndPatterns(toolName string) (domain.Tool, []domain.PatternConfiguration) {
func loadsToolAndPatterns(toolName string, onlyEnabledPatterns bool) (domain.Tool, []domain.PatternConfiguration) {
var toolsResponse, err = codacyclient.GetToolsVersions()
if err != nil {
fmt.Println("Error:", err)
Expand All @@ -251,7 +251,7 @@ func loadsToolAndPatterns(toolName string) (domain.Tool, []domain.PatternConfigu
}
}
var patterns []domain.PatternConfiguration
patterns, err = codacyclient.GetDefaultToolPatternsConfig(domain.InitFlags{}, tool.Uuid)
patterns, err = codacyclient.GetDefaultToolPatternsConfig(domain.InitFlags{}, tool.Uuid, onlyEnabledPatterns)
if err != nil {
fmt.Println("Error:", err)
return domain.Tool{}, []domain.PatternConfiguration{}
Expand Down
4 changes: 2 additions & 2 deletions cmd/configsetup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func CreateToolConfigurationFile(toolName string, flags domain.InitFlags) error
return fmt.Errorf("tool '%s' not found in supported tools", toolName)
}

patternsConfig, err := codacyclient.GetDefaultToolPatternsConfig(flags, toolUuid)
patternsConfig, err := codacyclient.GetDefaultToolPatternsConfig(flags, toolUuid, true)
if err != nil {
return fmt.Errorf("failed to get default patterns: %w", err)
}
Expand Down Expand Up @@ -734,7 +734,7 @@ func createDefaultConfigurationsForSpecificTools(discoveredToolNames map[string]
// createToolConfigurationsForUUIDs creates tool configurations for specific UUIDs
func createToolConfigurationsForUUIDs(uuids []string, toolsConfigDir string, initFlags domain.InitFlags) error {
for _, uuid := range uuids {
patternsConfig, err := codacyclient.GetDefaultToolPatternsConfig(initFlags, uuid)
patternsConfig, err := codacyclient.GetDefaultToolPatternsConfig(initFlags, uuid, true)
if err != nil {
logToolConfigWarning(uuid, "Failed to get default patterns", err)
continue
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.59.1",
"trivy@0.65.0",
"pylint@3.3.6",
"pmd@7.11.0",
},
Expand Down
3 changes: 2 additions & 1 deletion cmd/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ func processSarif(sarif Sarif) [][]map[string]interface{} {

for _, run := range sarif.Runs {
var toolName = getToolName(strings.ToLower(run.Tool.Driver.Name), run.Tool.Driver.Version)
tool, patterns := loadsToolAndPatterns(toolName)
tool, patterns := loadsToolAndPatterns(toolName, false)

for _, result := range run.Results {
modifiedType := tool.Prefix + strings.Replace(result.RuleID, "/", "_", -1)
pattern := getPatternByID(patterns, modifiedType)
Expand Down
7 changes: 5 additions & 2 deletions codacy-client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,11 @@ func parsePatternConfigurations(response []byte) ([]domain.PatternConfiguration,
}

// GetDefaultToolPatternsConfig fetches the default patterns for a tool
func GetDefaultToolPatternsConfig(initFlags domain.InitFlags, toolUUID string) ([]domain.PatternConfiguration, error) {
baseURL := fmt.Sprintf("%s/api/v3/tools/%s/patterns?enabled=true", CodacyApiBase, toolUUID)
func GetDefaultToolPatternsConfig(initFlags domain.InitFlags, toolUUID string, onlyEnabledPatterns bool) ([]domain.PatternConfiguration, error) {
baseURL := fmt.Sprintf("%s/api/v3/tools/%s/patterns", CodacyApiBase, toolUUID)
if onlyEnabledPatterns {
baseURL += "?enabled=true"
}

return getAllPages(baseURL, initFlags, parseDefaultPatternConfigurations)
}
Expand Down
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 @@ -6,8 +6,8 @@ runtimes:
tools:
- dartanalyzer@3.7.2
- eslint@8.57.0
- lizard@1.17.19
- lizard@1.17.31
- pmd@7.11.0
- pylint@3.3.6
- semgrep@1.78.0
- trivy@0.59.1
- trivy@0.65.0
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 @@ -4,8 +4,8 @@ runtimes:
- python@3.11.11
tools:
- eslint@8.57.0
- lizard@1.17.19
- lizard@1.17.31
- pmd@6.55.0
- pylint@3.3.7
- semgrep@1.78.0
- trivy@0.59.1
- trivy@0.65.0
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 @@ -7,9 +7,9 @@ runtimes:
tools:
- dartanalyzer@3.7.2
- eslint@8.57.0
- lizard@1.17.19
- lizard@1.17.31
- pmd@7.11.0
- pylint@3.3.6
- revive@1.7.0
- semgrep@1.78.0
- trivy@0.59.1
- trivy@0.65.0
2 changes: 1 addition & 1 deletion plugins/tools/lizard/plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: lizard
description: Lizard is an extensible Cyclomatic Complexity Analyzer for many programming languages.
default_version: 1.17.19
default_version: 1.17.31
runtime: python
runtime_binaries:
package_manager: python3
Expand Down
2 changes: 1 addition & 1 deletion plugins/tools/lizard/test/src/.codacy/codacy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
runtimes:
- python@3.11.11
tools:
- lizard@1.17.19
- lizard@1.17.31
2 changes: 1 addition & 1 deletion plugins/tools/trivy/plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: trivy
description: Trivy is a comprehensive security scanner for containers and other artifacts.
default_version: 0.59.1
default_version: 0.65.0
download:
url_template: "https://github.com/aquasecurity/trivy/releases/download/v{{.Version}}/trivy_{{.Version}}_{{.OS}}-{{.Arch}}.{{.Extension}}"
file_name_template: "trivy_{{.Version}}_{{.OS}}_{{.Arch}}"
Expand Down
2 changes: 1 addition & 1 deletion plugins/tools/trivy/test/expected.sarif
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
"informationUri": "https://github.com/aquasecurity/trivy",
"name": "Trivy",
"rules": null,
"version": "0.59.1"
"version": "0.65.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/tools/trivy/test/src/.codacy/codacy.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
runtimes:
tools:
- trivy@0.59.1
- trivy@0.65.0
2 changes: 1 addition & 1 deletion tools/lizard/test/lizardRunner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestRunLizardWithSarifOutput(t *testing.T) {

// Construct the path to the Lizard binary
globalCache := filepath.Join(homeDirectory, ".cache", "codacy")
lizardBinary := filepath.Join(globalCache, "tools/lizard@1.17.19/venv/bin/python")
lizardBinary := filepath.Join(globalCache, "tools/lizard@1.17.31/venv/bin/python")

// Construct the path to the test file
complexPyPath := filepath.Join(currentDir, "complex.py")
Expand Down
2 changes: 1 addition & 1 deletion tools/testdata/repositories/trivy/expected.sarif
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}
}
],
"version": "0.59.1"
"version": "0.65.0"
}
},
"results": [
Expand Down
Loading