Skip to content

Commit 9becc27

Browse files
committed
Reject other characters
1 parent 1fc583c commit 9becc27

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/batches/batch_spec.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,24 +169,24 @@ func parseBatchSpec(schema string, data []byte) (*BatchSpec, error) {
169169

170170
for i, step := range spec.Steps {
171171
for _, mount := range step.Mount {
172-
if strings.Contains(mount.Path, invalidMountCharacters) {
172+
if strings.ContainsAny(mount.Path, invalidMountCharacters) {
173173
errs = errors.Append(errs, NewValidationError(errors.Newf("step %d mount path contains invalid characters", i+1)))
174174
}
175-
if strings.Contains(mount.Mountpoint, invalidMountCharacters) {
175+
if strings.ContainsAny(mount.Mountpoint, invalidMountCharacters) {
176176
errs = errors.Append(errs, NewValidationError(errors.Newf("step %d mount mountpoint contains invalid characters", i+1)))
177177
}
178178
}
179179
for name := range step.Files {
180-
if strings.Contains(name, invalidMountCharacters) {
180+
if strings.ContainsAny(name, invalidMountCharacters) {
181181
errs = errors.Append(errs, NewValidationError(errors.Newf("step %d files target path contains invalid characters", i+1)))
182182
}
183183
}
184184
}
185185

186186
return &spec, errs
187187
}
188-
189-
const invalidMountCharacters = ","
188+
// docker uses Golang's `encoding/csv` library to parse arguments passed to `--mount`
189+
const invalidMountCharacters = ",\"\n\r"
190190

191191
func (on *OnQueryOrRepository) String() string {
192192
if on.RepositoriesMatchingQuery != "" {

0 commit comments

Comments
 (0)