Skip to content

Commit 2ceaaaa

Browse files
oliwerGopher Bot
authored andcommitted
BUG/MINOR: runtime: Allow ExecuteRaw to run multiple commands at once
1 parent 0d07f35 commit 2ceaaaa

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
@@ -144,6 +144,10 @@ func (s *SingleRuntime) ExecuteRaw(command string) (string, error) {
144144

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

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

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

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

0 commit comments

Comments
 (0)