Skip to content

Commit ce9f57b

Browse files
chore: Update Trivy version to 0.47.0 and remove unused SARIF conversion function
1 parent 7db65fd commit ce9f57b

File tree

2 files changed

+1
-54
lines changed

2 files changed

+1
-54
lines changed

.codacy/codacy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ runtimes:
22
33
tools:
44
5-
- trivy@0.46.0
5+
- trivy@0.47.0

tools/trivyRunner.go

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

33
import (
4-
"encoding/json"
54
"fmt"
65
"os"
76
"os/exec"
@@ -56,55 +55,3 @@ func RunTrivy(repositoryToAnalyseDirectory string, trivyBinary string, pathsToCh
5655
// If outputting to file, just run the command
5756
return cmd.Run()
5857
}
59-
60-
// TrivyJsonToSarif converts Trivy JSON output to SARIF format
61-
// Note: This function is not needed when using Trivy's built-in SARIF output
62-
// but is included for completeness if you need custom conversions
63-
func TrivyJsonToSarif(trivyJsonFile string, sarifOutputFile string) error {
64-
// Read Trivy JSON output
65-
data, err := os.ReadFile(trivyJsonFile)
66-
if err != nil {
67-
return fmt.Errorf("failed to read Trivy JSON file: %w", err)
68-
}
69-
70-
// Parse Trivy JSON
71-
var trivyResults map[string]interface{}
72-
if err := json.Unmarshal(data, &trivyResults); err != nil {
73-
return fmt.Errorf("failed to parse Trivy JSON: %w", err)
74-
}
75-
76-
// Build SARIF structure
77-
sarif := map[string]interface{}{
78-
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
79-
"version": "2.1.0",
80-
"runs": []map[string]interface{}{
81-
{
82-
"tool": map[string]interface{}{
83-
"driver": map[string]interface{}{
84-
"name": "Trivy",
85-
"informationUri": "https://github.com/aquasecurity/trivy",
86-
"semanticVersion": "1.0.0",
87-
"rules": []interface{}{},
88-
},
89-
},
90-
"results": []interface{}{},
91-
},
92-
},
93-
}
94-
95-
// Convert results and rules (simplified implementation)
96-
// In a real implementation, you would iterate through Trivy results
97-
// and convert each one to SARIF format
98-
99-
// Write SARIF output
100-
sarifData, err := json.MarshalIndent(sarif, "", " ")
101-
if err != nil {
102-
return fmt.Errorf("failed to marshal SARIF data: %w", err)
103-
}
104-
105-
if err := os.WriteFile(sarifOutputFile, sarifData, 0644); err != nil {
106-
return fmt.Errorf("failed to write SARIF file: %w", err)
107-
}
108-
109-
return nil
110-
}

0 commit comments

Comments
 (0)