Skip to content

Commit 2a29625

Browse files
author
Ma Shimiao
committed
validate: add args validation
Signed-off-by: Ma Shimiao <[email protected]>
1 parent 1bfd892 commit 2a29625

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

validate/validate.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,23 @@ func (v *Validator) CheckProcess() (msgs []string) {
218218
}
219219
}
220220

221+
if len(process.Args) == 0 {
222+
msgs = append(msgs, fmt.Sprintf("args must not be empty"))
223+
} else {
224+
if filepath.IsAbs(process.Args[0]) {
225+
var rootfsPath string
226+
if filepath.IsAbs(v.spec.Root.Path) {
227+
rootfsPath = v.spec.Root.Path
228+
} else {
229+
rootfsPath = filepath.Join(v.bundlePath, v.spec.Root.Path)
230+
}
231+
absPath := filepath.Join(rootfsPath, process.Args[0])
232+
if _, err := os.Stat(absPath); err != nil {
233+
msgs = append(msgs, err.Error())
234+
}
235+
}
236+
}
237+
221238
for index := 0; index < len(process.Capabilities); index++ {
222239
capability := process.Capabilities[index]
223240
if !capValid(capability) {

0 commit comments

Comments
 (0)