Skip to content

Commit

Permalink
validate: add args validation
Browse files Browse the repository at this point in the history
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
  • Loading branch information
Ma Shimiao committed Jan 10, 2017
1 parent 1bfd892 commit 2a29625
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,23 @@ func (v *Validator) CheckProcess() (msgs []string) {
}
}

if len(process.Args) == 0 {
msgs = append(msgs, fmt.Sprintf("args must not be empty"))
} else {
if filepath.IsAbs(process.Args[0]) {
var rootfsPath string
if filepath.IsAbs(v.spec.Root.Path) {
rootfsPath = v.spec.Root.Path
} else {
rootfsPath = filepath.Join(v.bundlePath, v.spec.Root.Path)
}
absPath := filepath.Join(rootfsPath, process.Args[0])
if _, err := os.Stat(absPath); err != nil {
msgs = append(msgs, err.Error())
}
}
}

for index := 0; index < len(process.Capabilities); index++ {
capability := process.Capabilities[index]
if !capValid(capability) {
Expand Down

0 comments on commit 2a29625

Please sign in to comment.