Skip to content

Commit 1fdee89

Browse files
Merge pull request #733 from Checkmarx/avis/azure-support
AST-45352 - Add support for Checkmarx Azure AI
2 parents c383fbf + 16da59b commit 1fdee89

File tree

19 files changed

+589
-112
lines changed

19 files changed

+589
-112
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ linters-settings:
1111
- github.com/CheckmarxDev/containers-resolver/pkg/containerResolver
1212
- github.com/Checkmarx/gen-ai-prompts/prompts/sast_result_remediation
1313
- github.com/spf13/viper
14-
- github.com/checkmarxDev/gpt-wrapper
14+
- github.com/Checkmarx/gen-ai-wrapper
1515
- github.com/spf13/cobra
1616
- github.com/pkg/errors
1717
- github.com/google

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ go 1.22.7
44

55
require (
66
github.com/Checkmarx/gen-ai-prompts v0.0.0-20240807143411-708ceec12b63
7+
github.com/Checkmarx/gen-ai-wrapper v1.0.2
78
github.com/CheckmarxDev/containers-resolver v1.0.14
89
github.com/MakeNowJust/heredoc v1.0.0
910
github.com/bouk/monkey v1.0.0
10-
github.com/checkmarxDev/gpt-wrapper v0.0.0-20230721160222-85da2fd1cc4c
1111
github.com/golang-jwt/jwt v3.2.2+incompatible
1212
github.com/gomarkdown/markdown v0.0.0-20241102151059-6bc1ffdc6e8c
1313
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
@@ -17,7 +17,7 @@ require (
1717
github.com/mssola/user_agent v0.6.0
1818
github.com/pkg/errors v0.9.1
1919
github.com/spf13/cobra v1.8.1
20-
github.com/spf13/viper v1.18.2
20+
github.com/spf13/viper v1.19.0
2121
github.com/stretchr/testify v1.9.0
2222
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80
2323
github.com/xeipuuv/gojsonschema v1.2.0
@@ -195,7 +195,7 @@ require (
195195
github.com/opencontainers/selinux v1.11.0 // indirect
196196
github.com/pborman/indent v1.2.1 // indirect
197197
github.com/pelletier/go-toml v1.9.5 // indirect
198-
github.com/pelletier/go-toml/v2 v2.2.1 // indirect
198+
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
199199
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
200200
github.com/pierrec/lz4/v4 v4.1.21 // indirect
201201
github.com/pjbgf/sha1cd v0.3.0 // indirect

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2
6262
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
6363
github.com/Checkmarx/gen-ai-prompts v0.0.0-20240807143411-708ceec12b63 h1:SCuTcE+CFvgjbIxUNL8rsdB2sAhfuNx85HvxImKta3g=
6464
github.com/Checkmarx/gen-ai-prompts v0.0.0-20240807143411-708ceec12b63/go.mod h1:MI6lfLerXU+5eTV/EPTDavgnV3owz3GPT4g/msZBWPo=
65+
github.com/Checkmarx/gen-ai-wrapper v1.0.2 h1:T6X40+4hYnwfDsvkjWs9VIcE6s1O+8DUu0+sDdCY3GI=
66+
github.com/Checkmarx/gen-ai-wrapper v1.0.2/go.mod h1:xwRLefezwNNnRGu1EjGS6wNiR9FVV/eP9D+oXwLViVM=
6567
github.com/CheckmarxDev/containers-resolver v1.0.14 h1:jOc1POn6XVETZtXMyer6Rp6K/MLfkuGCKgMk6ZLEf/w=
6668
github.com/CheckmarxDev/containers-resolver v1.0.14/go.mod h1:ne5YunT/hKQ7fnZejFVGodlfOUReNE7hZW2KLbpQi48=
6769
github.com/CycloneDX/cyclonedx-go v0.9.0 h1:inaif7qD8bivyxp7XLgxUYtOXWtDez7+j72qKTMQTb8=
@@ -195,8 +197,6 @@ github.com/charmbracelet/x/term v0.1.1 h1:3cosVAiPOig+EV4X9U+3LDgtwwAoEzJjNdwbXD
195197
github.com/charmbracelet/x/term v0.1.1/go.mod h1:wB1fHt5ECsu3mXYusyzcngVWWlu1KKUmmLhfgr/Flxw=
196198
github.com/charmbracelet/x/windows v0.1.0 h1:gTaxdvzDM5oMa/I2ZNF7wN78X/atWemG9Wph7Ika2k4=
197199
github.com/charmbracelet/x/windows v0.1.0/go.mod h1:GLEO/l+lizvFDBPLIOk+49gdX49L9YWMB5t+DZd0jkQ=
198-
github.com/checkmarxDev/gpt-wrapper v0.0.0-20230721160222-85da2fd1cc4c h1:oKI4C1dXYpi0B8pltDDzp1ZRiyeILv5enbp9h4ASQ3s=
199-
github.com/checkmarxDev/gpt-wrapper v0.0.0-20230721160222-85da2fd1cc4c/go.mod h1:l+0rISRGaps2HWkpvKbYPE1nsNx28vBj6bKorEm1M5o=
200200
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
201201
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
202202
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
@@ -763,8 +763,8 @@ github.com/pborman/indent v1.2.1/go.mod h1:FitS+t35kIYtB5xWTZAPhnmrxcciEEOdbyrrp
763763
github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
764764
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
765765
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
766-
github.com/pelletier/go-toml/v2 v2.2.1 h1:9TA9+T8+8CUCO2+WYnDLCgrYi9+omqKXyjDtosvtEhg=
767-
github.com/pelletier/go-toml/v2 v2.2.1/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
766+
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
767+
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
768768
github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI=
769769
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
770770
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI=
@@ -885,8 +885,8 @@ github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0
885885
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
886886
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
887887
github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM=
888-
github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ=
889-
github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
888+
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
889+
github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
890890
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
891891
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
892892
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=

internal/commands/chat-kics.go

Lines changed: 103 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ package commands
33
import (
44
"fmt"
55
"os"
6+
"strings"
67

8+
"github.com/Checkmarx/gen-ai-wrapper/pkg/message"
9+
"github.com/Checkmarx/gen-ai-wrapper/pkg/role"
10+
gptWrapper "github.com/Checkmarx/gen-ai-wrapper/pkg/wrapper"
711
"github.com/checkmarx/ast-cli/internal/commands/util/printer"
812
"github.com/checkmarx/ast-cli/internal/logger"
913
"github.com/checkmarx/ast-cli/internal/params"
1014
"github.com/checkmarx/ast-cli/internal/wrappers"
11-
"github.com/checkmarxDev/gpt-wrapper/pkg/connector"
12-
"github.com/checkmarxDev/gpt-wrapper/pkg/message"
13-
"github.com/checkmarxDev/gpt-wrapper/pkg/role"
14-
"github.com/checkmarxDev/gpt-wrapper/pkg/wrapper"
1515
"github.com/google/uuid"
1616
"github.com/pkg/errors"
1717
"github.com/spf13/cobra"
@@ -41,18 +41,24 @@ const dropLen = 4
4141

4242
const FileErrorFormat = "It seems that %s is not available for AI Guided Remediation. Please ensure that you have opened the correct workspace or the relevant file."
4343

44+
// chatModel model to use when calling the CheckmarxAI
45+
const checkmarxAiChatModel = "gpt-4"
46+
const tenantIDClaimKey = "tenant_id"
47+
const guidedRemediationFeatureNameKics = "cli-guided-remediation-kics"
48+
const guidedRemediationFeatureNameSast = "cli-guided-remediation-sast"
49+
4450
type OutputModel struct {
4551
ConversationID string `json:"conversationId"`
4652
Response []string `json:"response"`
4753
}
4854

49-
func ChatKicsSubCommand(chatWrapper wrappers.ChatWrapper) *cobra.Command {
55+
func ChatKicsSubCommand(chatWrapper wrappers.ChatWrapper, tenantWrapper wrappers.TenantConfigurationWrapper) *cobra.Command {
5056
chatKicsCmd := &cobra.Command{
5157
Use: "kics",
5258
Short: "Chat about KICS result with OpenAI models",
5359
Long: "Chat about KICS result with OpenAI models",
5460
Hidden: true,
55-
RunE: runChatKics(chatWrapper),
61+
RunE: runChatKics(chatWrapper, tenantWrapper),
5662
}
5763

5864
chatKicsCmd.Flags().String(params.ChatAPIKey, "", "OpenAI API key")
@@ -65,7 +71,6 @@ func ChatKicsSubCommand(chatWrapper wrappers.ChatWrapper) *cobra.Command {
6571
chatKicsCmd.Flags().String(params.ChatKicsResultVulnerability, "", "IaC result vulnerability name")
6672

6773
_ = chatKicsCmd.MarkFlagRequired(params.ChatUserInput)
68-
_ = chatKicsCmd.MarkFlagRequired(params.ChatAPIKey)
6974
_ = chatKicsCmd.MarkFlagRequired(params.ChatKicsResultFile)
7075
_ = chatKicsCmd.MarkFlagRequired(params.ChatKicsResultLine)
7176
_ = chatKicsCmd.MarkFlagRequired(params.ChatKicsResultSeverity)
@@ -74,27 +79,29 @@ func ChatKicsSubCommand(chatWrapper wrappers.ChatWrapper) *cobra.Command {
7479
return chatKicsCmd
7580
}
7681

77-
func runChatKics(chatKicsWrapper wrappers.ChatWrapper) func(cmd *cobra.Command, args []string) error {
82+
func runChatKics(
83+
chatKicsWrapper wrappers.ChatWrapper, tenantWrapper wrappers.TenantConfigurationWrapper,
84+
) func(cmd *cobra.Command, args []string) error {
7885
return func(cmd *cobra.Command, args []string) error {
79-
chatAPIKey, _ := cmd.Flags().GetString(params.ChatAPIKey)
8086
chatConversationID, _ := cmd.Flags().GetString(params.ChatConversationID)
81-
chatModel, _ := cmd.Flags().GetString(params.ChatModel)
8287
chatResultFile, _ := cmd.Flags().GetString(params.ChatKicsResultFile)
8388
chatResultLine, _ := cmd.Flags().GetString(params.ChatKicsResultLine)
8489
chatResultSeverity, _ := cmd.Flags().GetString(params.ChatKicsResultSeverity)
8590
chatResultVulnerability, _ := cmd.Flags().GetString(params.ChatKicsResultVulnerability)
8691
userInput, _ := cmd.Flags().GetString(params.ChatUserInput)
8792

88-
statefulWrapper := wrapper.NewStatefulWrapper(connector.NewFileSystemConnector(""), chatAPIKey, chatModel, dropLen, 0)
89-
90-
if chatConversationID == "" {
91-
chatConversationID = statefulWrapper.GenerateId().String()
93+
azureAiEnabled, checkmarxAiEnabled, tenantConfigurationResponses, err := getEngineSelection(cmd, tenantWrapper)
94+
if err != nil {
95+
return err
9296
}
9397

94-
id, err := uuid.Parse(chatConversationID)
98+
statefulWrapper, customerToken := CreateStatefulWrapper(cmd, azureAiEnabled, checkmarxAiEnabled, tenantConfigurationResponses)
99+
100+
tenantID := getTenantID(customerToken)
101+
102+
id, err := getKicsConversationID(cmd, chatConversationID, statefulWrapper)
95103
if err != nil {
96-
logger.PrintIfVerbose(err.Error())
97-
return outputError(cmd, id, errors.Errorf(ConversationIDErrorFormat, chatConversationID))
104+
return err
98105
}
99106

100107
chatResultCode, err := os.ReadFile(chatResultFile)
@@ -103,22 +110,96 @@ func runChatKics(chatKicsWrapper wrappers.ChatWrapper) func(cmd *cobra.Command,
103110
return outputError(cmd, id, errors.Errorf(FileErrorFormat, chatResultFile))
104111
}
105112

106-
newMessages := buildMessages(chatResultCode, chatResultVulnerability, chatResultLine, chatResultSeverity, userInput)
107-
response, err := chatKicsWrapper.Call(statefulWrapper, id, newMessages)
113+
newMessages := buildKicsMessages(chatResultCode, chatResultVulnerability, chatResultLine, chatResultSeverity, userInput)
114+
115+
responseContent, err := sendRequest(statefulWrapper, azureAiEnabled, checkmarxAiEnabled, tenantID, chatKicsWrapper, id, newMessages, customerToken, guidedRemediationFeatureNameKics)
108116
if err != nil {
109117
return outputError(cmd, id, err)
110118
}
111119

112-
responseContent := getMessageContents(response)
113-
114120
return printer.Print(cmd.OutOrStdout(), &OutputModel{
115121
ConversationID: id.String(),
116122
Response: responseContent,
117123
}, printer.FormatJSON)
118124
}
119125
}
120126

121-
func buildMessages(chatResultCode []byte,
127+
func getKicsConversationID(cmd *cobra.Command, chatConversationID string, statefulWrapper gptWrapper.StatefulWrapper) (uuid.UUID, error) {
128+
if chatConversationID == "" {
129+
chatConversationID = statefulWrapper.GenerateId().String()
130+
}
131+
132+
id, err := uuid.Parse(chatConversationID)
133+
if err != nil {
134+
logger.PrintIfVerbose(err.Error())
135+
return uuid.UUID{}, outputError(cmd, id, errors.Errorf(ConversationIDErrorFormat, chatConversationID))
136+
}
137+
return id, err
138+
}
139+
140+
func getTenantID(customerToken string) string {
141+
tenantID, _ := wrappers.ExtractFromTokenClaims(customerToken, tenantIDClaimKey)
142+
// remove from tenant id all the string before ::
143+
if strings.Contains(tenantID, "::") {
144+
tenantID = tenantID[strings.LastIndex(tenantID, "::")+2:]
145+
}
146+
return tenantID
147+
}
148+
149+
func sendRequest(statefulWrapper gptWrapper.StatefulWrapper, azureAiEnabled bool, checkmarxAiEnabled bool, tenantID string, chatKicsWrapper wrappers.ChatWrapper,
150+
id uuid.UUID, newMessages []message.Message, customerToken string, featureName string) (responseContent []string, err error) {
151+
requestID := statefulWrapper.GenerateId().String()
152+
153+
var response []message.Message
154+
155+
if azureAiEnabled || checkmarxAiEnabled {
156+
metadata := message.MetaData{
157+
TenantID: tenantID,
158+
RequestID: requestID,
159+
UserAgent: params.DefaultAgent,
160+
Feature: featureName,
161+
}
162+
if azureAiEnabled {
163+
logger.Printf("Sending message to Azure AI model for " + featureName + " guided remediation. RequestID: " + requestID)
164+
} else {
165+
logger.Printf("Sending message to Checkmarx AI model for " + featureName + " guided remediation. RequestID: " + requestID)
166+
}
167+
response, err = chatKicsWrapper.SecureCall(statefulWrapper, id, newMessages, &metadata, customerToken)
168+
if err != nil {
169+
return nil, err
170+
}
171+
} else { // if chatgpt is enabled or no engine is enabled
172+
logger.Printf("Sending message to ChatGPT model for " + featureName + " guided remediation. RequestID: " + requestID)
173+
response, err = chatKicsWrapper.Call(statefulWrapper, id, newMessages)
174+
if err != nil {
175+
return nil, err
176+
}
177+
}
178+
179+
responseContent = getMessageContents(response)
180+
return responseContent, nil
181+
}
182+
183+
func getEngineSelection(cmd *cobra.Command, tenantWrapper wrappers.TenantConfigurationWrapper) (azureAiEnabled, checkmarxAiEnabled bool,
184+
tenantConfigurationResponses *[]*wrappers.TenantConfigurationResponse, err error) {
185+
if !isCxOneAPIKeyAvailable() {
186+
azureAiEnabled = false
187+
checkmarxAiEnabled = false
188+
logger.Printf("CxOne API key is not available, ChatGPT model will be used for guided remediation.")
189+
} else {
190+
var err error
191+
tenantConfigurationResponses, err = GetTenantConfigurationResponses(tenantWrapper)
192+
if err != nil {
193+
return false, false, nil, outputError(cmd, uuid.Nil, err)
194+
}
195+
196+
azureAiEnabled = isAzureAiGuidedRemediationEnabled(tenantConfigurationResponses)
197+
checkmarxAiEnabled = isCheckmarxAiGuidedRemediationEnabled(tenantConfigurationResponses)
198+
}
199+
return azureAiEnabled, checkmarxAiEnabled, tenantConfigurationResponses, nil
200+
}
201+
202+
func buildKicsMessages(chatResultCode []byte,
122203
chatResultVulnerability, chatResultLine, chatResultSeverity, userInput string) []message.Message {
123204
var newMessages []message.Message
124205
newMessages = append(newMessages, message.Message{

internal/commands/chat-kics_test.go

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import (
66
"strings"
77
"testing"
88

9+
"github.com/checkmarx/ast-cli/internal/params"
10+
"github.com/checkmarx/ast-cli/internal/wrappers"
11+
"github.com/checkmarx/ast-cli/internal/wrappers/mock"
912
"github.com/google/uuid"
13+
"github.com/spf13/viper"
1014
"gotest.tools/assert"
1115
)
1216

@@ -49,7 +53,6 @@ func TestChatKicsInvalidFile(t *testing.T) {
4953
func TestChatKicsCorrectResponse(t *testing.T) {
5054
buffer, err := executeRedirectedTestCommand("chat", "kics",
5155
"--conversation-id", uuid.New().String(),
52-
"--chat-apikey", "apiKey",
5356
"--user-input", "userInput",
5457
"--result-file", "./data/Dockerfile",
5558
"--result-line", "0",
@@ -61,3 +64,76 @@ func TestChatKicsCorrectResponse(t *testing.T) {
6164
s := strings.ToLower(string(output))
6265
assert.Assert(t, strings.Contains(s, "mock"), s)
6366
}
67+
68+
func TestChatKicsAzureAICorrectResponse(t *testing.T) {
69+
mock.TenantConfiguration = []*wrappers.TenantConfigurationResponse{
70+
{
71+
Key: "scan.config.plugins.ideScans",
72+
Value: "true",
73+
},
74+
{
75+
Key: "scan.config.plugins.azureAiGuidedRemediation",
76+
Value: "true",
77+
},
78+
{
79+
Key: "scan.config.plugins.aiGuidedRemediationAiEngine",
80+
Value: "azureai",
81+
},
82+
}
83+
origAPIKey := viper.GetString(params.AstAPIKey)
84+
viper.Set(params.AstAPIKey, "SomeKey")
85+
86+
buffer, err := executeRedirectedTestCommand("chat", "kics",
87+
"--conversation-id", uuid.New().String(),
88+
"--user-input", "userInput",
89+
"--result-file", "./data/Dockerfile",
90+
"--result-line", "0",
91+
"--result-severity", "LOW",
92+
"--result-vulnerability", "Vulnerability")
93+
assert.NilError(t, err)
94+
output, err := io.ReadAll(buffer)
95+
assert.NilError(t, err)
96+
s := strings.ToLower(string(output))
97+
98+
mock.TenantConfiguration = []*wrappers.TenantConfigurationResponse{}
99+
viper.Set(params.AstAPIKey, origAPIKey)
100+
101+
assert.Assert(t, strings.Contains(s, "mock message from securecall"), s)
102+
}
103+
104+
func TestChatKicsCheckmarxAICorrectResponse(t *testing.T) {
105+
mock.TenantConfiguration = []*wrappers.TenantConfigurationResponse{
106+
{
107+
Key: "scan.config.plugins.ideScans",
108+
Value: "true",
109+
},
110+
{
111+
Key: "scan.config.plugins.checkmarxAiGuidedRemediation",
112+
Value: "true",
113+
},
114+
{
115+
Key: "scan.config.plugins.aiGuidedRemediationAiEngine",
116+
Value: "checkmarxai",
117+
},
118+
}
119+
origAPIKey := viper.GetString(params.AstAPIKey)
120+
viper.Set(params.AstAPIKey, "SomeKey")
121+
122+
buffer, err := executeRedirectedTestCommand("chat", "kics",
123+
"--conversation-id", uuid.New().String(),
124+
"--chat-apikey", "apiKey",
125+
"--user-input", "userInput",
126+
"--result-file", "./data/Dockerfile",
127+
"--result-line", "0",
128+
"--result-severity", "LOW",
129+
"--result-vulnerability", "Vulnerability")
130+
assert.NilError(t, err)
131+
output, err := io.ReadAll(buffer)
132+
assert.NilError(t, err)
133+
s := strings.ToLower(string(output))
134+
135+
mock.TenantConfiguration = []*wrappers.TenantConfigurationResponse{}
136+
viper.Set(params.AstAPIKey, origAPIKey)
137+
138+
assert.Assert(t, strings.Contains(s, "mock message from securecall"), s)
139+
}

0 commit comments

Comments
 (0)