Skip to content

Commit f24ac3f

Browse files
committed
move trivy files
1 parent dbadf36 commit f24ac3f

19 files changed

+381
-302
lines changed

cmd/analyze.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"codacy/cli-v2/tools"
66
"codacy/cli-v2/tools/eslint"
77
"codacy/cli-v2/tools/pmd"
8+
"codacy/cli-v2/tools/trivy"
89
"encoding/json"
910
"fmt"
1011
"io"
@@ -199,10 +200,10 @@ func runEslintAnalysis(workDirectory string, pathsToCheck []string, autoFix bool
199200
}
200201

201202
func runTrivyAnalysis(workDirectory string, pathsToCheck []string, outputFile string, outputFormat string) {
202-
trivy := config.Config.Tools()["trivy"]
203-
trivyBinary := trivy.Binaries["trivy"]
203+
tool := config.Config.Tools()["trivy"]
204+
trivyBinary := tool.Binaries["trivy"]
204205

205-
err := tools.RunTrivy(workDirectory, trivyBinary, pathsToCheck, outputFile, outputFormat)
206+
err := trivy.RunTrivy(workDirectory, trivyBinary, pathsToCheck, outputFile, outputFormat)
206207
if err != nil {
207208
log.Fatalf("Error running Trivy: %v", err)
208209
}

cmd/init.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"codacy/cli-v2/tools"
66
"codacy/cli-v2/tools/eslint"
77
"codacy/cli-v2/tools/pmd"
8+
"codacy/cli-v2/tools/trivy"
89
"encoding/json"
910
"errors"
1011
"fmt"
@@ -329,7 +330,7 @@ func createTrivyConfigFile(config CodacyToolConfiguration) error {
329330
trivyDomainConfiguration := convertAPIToolConfigurationForTrivy(config)
330331

331332
// Use the shared CreateTrivyConfig function to generate the config content
332-
trivyConfigurationString := tools.CreateTrivyConfig(trivyDomainConfiguration)
333+
trivyConfigurationString := trivy.CreateTrivyConfig(trivyDomainConfiguration)
333334

334335
// Write to file
335336
return os.WriteFile("trivy.yaml", []byte(trivyConfigurationString), 0644)
@@ -379,7 +380,7 @@ func convertAPIToolConfigurationForTrivy(config CodacyToolConfiguration) tools.T
379380
func createDefaultTrivyConfigFile() error {
380381
// Use empty tool configuration to get default settings
381382
emptyConfig := tools.ToolConfiguration{}
382-
content := tools.CreateTrivyConfig(emptyConfig)
383+
content := trivy.CreateTrivyConfig(emptyConfig)
383384

384385
// Write to file
385386
return os.WriteFile("trivy.yaml", []byte(content), 0644)

tools/test/eslint/.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "parser": "espree", "rules": { "semi": ["error", "always"] } }

tools/test/eslint/config.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"env": {},
3+
"globals": {},
4+
"parser": null,
5+
"parserOptions": {},
6+
"plugins": [],
7+
"rules": {
8+
"prefer-const": [
9+
"error"
10+
],
11+
"semi": [
12+
"error",
13+
"always"
14+
]
15+
},
16+
"settings": {},
17+
"ignorePatterns": []
18+
}

tools/test/eslint/eslint.sarif

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"version": "2.1.0",
3+
"$schema": "http://json.schemastore.org/sarif-2.1.0-rtm.5",
4+
"runs": [
5+
{
6+
"tool": {
7+
"driver": {
8+
"name": "ESLint",
9+
"informationUri": "https://eslint.org",
10+
"rules": [],
11+
"version": "9.3.0"
12+
}
13+
},
14+
"artifacts": [
15+
{
16+
"location": {
17+
"uri": "file:///Users/lorenzo/codacy/github/codacy-cli-v2/tools/testdata/repositories/test1/src/eslint.config.mjs"
18+
}
19+
},
20+
{
21+
"location": {
22+
"uri": "file:///Users/lorenzo/codacy/github/codacy-cli-v2/tools/testdata/repositories/test1/src/test.js"
23+
}
24+
}
25+
],
26+
"results": []
27+
}
28+
]
29+
}

tools/test/eslint/expected.sarif

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"version": "2.1.0",
3+
"$schema": "http://json.schemastore.org/sarif-2.1.0-rtm.5",
4+
"runs": [
5+
{
6+
"tool": {
7+
"driver": {
8+
"name": "ESLint",
9+
"informationUri": "https://eslint.org",
10+
"rules": [],
11+
"version": "9.3.0"
12+
}
13+
},
14+
"artifacts": [
15+
{
16+
"location": {
17+
"uri": "file:///Users/lorenzo/codacy/github/codacy-cli-v2/tools/testdata/repositories/test1/src/eslint.config.mjs"
18+
}
19+
},
20+
{
21+
"location": {
22+
"uri": "file:///Users/lorenzo/codacy/github/codacy-cli-v2/tools/testdata/repositories/test1/src/test.js"
23+
}
24+
}
25+
],
26+
"results": []
27+
}
28+
]
29+
}

tools/test/eslint/sarif.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"version": "2.1.0",
3+
"$schema": "http://json.schemastore.org/sarif-2.1.0-rtm.5",
4+
"runs": [
5+
{
6+
"tool": {
7+
"driver": {
8+
"name": "ESLint",
9+
"informationUri": "https://eslint.org",
10+
"rules": [],
11+
"version": "9.3.0"
12+
}
13+
},
14+
"artifacts": [
15+
{
16+
"location": {
17+
"uri": "file:///Users/lorenzo/codacy/github/codacy-cli-v2/tools/testdata/repositories/test1/src/eslint.config.mjs"
18+
}
19+
},
20+
{
21+
"location": {
22+
"uri": "file:///Users/lorenzo/codacy/github/codacy-cli-v2/tools/testdata/repositories/test1/src/test.js"
23+
}
24+
}
25+
],
26+
"results": []
27+
}
28+
]
29+
}

tools/test/eslint/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
var foo = "bar"
2+
foo = "baz"

tools/test/pmd/RulesBreaker.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
/**
3+
* This class demonstrates various PMD rule violations.
4+
* It is used for testing PMD's rule detection capabilities.
5+
*
6+
* @author Codacy Test Team
7+
* @version 1.0
8+
*/
9+
10+
package tools.testdata.repositories.pmd;
11+
12+
/**
13+
* A class that demonstrates PMD rule violations.
14+
*/
15+
public class RulesBreaker {
16+
17+
// Breaking naming convention rules
18+
private int x;
19+
20+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Codacy PMD Ruleset"
3+
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
6+
<description>Codacy PMD Ruleset</description>
7+
8+
<rule ref="category/java/codestyle.xml/AtLeastOneConstructor"/>
9+
<rule ref="category/java/design.xml/UnusedPrivateField"/>
10+
<rule ref="category/java/design.xml/LoosePackageCoupling">
11+
<properties>
12+
<property name="packages" value="java.util,java.io"/>
13+
</properties>
14+
</rule>
15+
</ruleset>

0 commit comments

Comments
 (0)