Skip to content

Commit b55ad94

Browse files
oliwerGopher Bot
authored andcommitted
BUG/MINOR: runtime: Allow ExecuteRaw to run multiple commands at once
1 parent fd363b5 commit b55ad94

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

runtime/runtime_single_client.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ func (s *SingleRuntime) ExecuteRaw(command string) (string, error) {
143143

144144
// Execute executes command on runtime API
145145
func (s *SingleRuntime) Execute(command string) error {
146+
// Make sure to only execute a single command.
147+
if strings.ContainsAny(command, ";") {
148+
return ErrRuntimeInvalidChar
149+
}
146150
rawdata, err := s.ExecuteRaw(command)
147151
if err != nil {
148152
return fmt.Errorf("%w [%s]", err, command)
@@ -157,6 +161,10 @@ func (s *SingleRuntime) Execute(command string) error {
157161
}
158162

159163
func (s *SingleRuntime) ExecuteWithResponse(command string) (string, error) {
164+
// Make sure to only execute a single command.
165+
if strings.ContainsAny(command, ";") {
166+
return "", ErrRuntimeInvalidChar
167+
}
160168
rawdata, err := s.ExecuteRaw(command)
161169
if err != nil {
162170
return "", fmt.Errorf("%w [%s]", err, command)
@@ -171,15 +179,15 @@ func (s *SingleRuntime) ExecuteWithResponse(command string) (string, error) {
171179
}
172180

173181
func (s *SingleRuntime) ExecuteMaster(command string) (string, error) {
182+
// Make sure to only execute a single command.
183+
if strings.ContainsAny(command, ";") {
184+
return "", ErrRuntimeInvalidChar
185+
}
174186
// allow one retry if connection breaks temporarily
175187
return s.executeRaw(command, 1, masterSocket)
176188
}
177189

178190
func (s *SingleRuntime) executeRaw(command string, retry int, socket socketType) (string, error) {
179-
// Make sure to only execute a single command.
180-
if strings.ContainsAny(command, ";") {
181-
return "", ErrRuntimeInvalidChar
182-
}
183191
result, err := s.readFromSocket(command, socket)
184192
if err != nil && retry > 0 {
185193
retry--

0 commit comments

Comments
 (0)