Skip to content

Commit cf42188

Browse files
committedNov 13, 2023
fix: ToolExecution Patterns should now be optional
1 parent 1bc2379 commit cf42188

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed
 

‎.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2.1
22

33
orbs:
4-
codacy: codacy/base@10.10.1
4+
codacy: codacy/base@10.11.0
55

66
jobs:
77
unit_test:

‎tool.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func newToolExecution(runConfig RunConfiguration) (*ToolExecution, error) {
5252
})
5353
// If there is no configured tool that matches the container's tool definition, patterns will be nil. The underlying tool will know what to do in that case.
5454
// Otherwise we guarantee that the configured patterns have all the required parameters as specified in the container's tool definition.
55-
if exists {
55+
if exists && configuredTool.Patterns != nil {
5656
p := patternsWithDefaultParameters(*toolDefinition, configuredTool)
5757
patterns = &p
5858
}
@@ -72,10 +72,10 @@ func newToolExecution(runConfig RunConfiguration) (*ToolExecution, error) {
7272
func patternsWithDefaultParameters(toolDefinition, configuredTool ToolDefinition) []Pattern {
7373

7474
var patterns []Pattern
75-
for _, configuredToolPattern := range configuredTool.Patterns {
75+
for _, configuredToolPattern := range *configuredTool.Patterns {
7676

7777
// Configured pattern exists in the tool definition patterns
78-
toolDefinitionPattern, exists := lo.Find(toolDefinition.Patterns, func(item Pattern) bool {
78+
toolDefinitionPattern, exists := lo.Find(*toolDefinition.Patterns, func(item Pattern) bool {
7979
return configuredToolPattern.ID == item.ID
8080
})
8181

@@ -109,7 +109,7 @@ type ToolDefinition struct {
109109
Name string `json:"name"`
110110
Version string `json:"version,omitempty"`
111111
// Patterns contains all of the tool's supported patterns.
112-
Patterns []Pattern `json:"patterns"`
112+
Patterns *[]Pattern `json:"patterns"`
113113
}
114114

115115
// loadToolDefinition loads tool information from the tool definition file.

‎tool_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestNewToolExecution(t *testing.T) {
1919
ToolDefinition: ToolDefinition{
2020
Name: "gorevive",
2121
Version: "1.0.0",
22-
Patterns: []Pattern{
22+
Patterns: &[]Pattern{
2323
{
2424
ID: "foo",
2525
Category: "ErrorProne",
@@ -85,7 +85,7 @@ func TestNewToolExecution_NoMatchingToolConfigured(t *testing.T) {
8585
ToolDefinition: ToolDefinition{
8686
Name: "trivy",
8787
Version: "1.0.0",
88-
Patterns: []Pattern{
88+
Patterns: &[]Pattern{
8989
{
9090
ID: "secret",
9191
Category: "Security",

0 commit comments

Comments
 (0)
Please sign in to comment.