Skip to content

Commit a390617

Browse files
author
Ma Shimiao
committed
validation: add args validation for process
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
1 parent da4db68 commit a390617

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

validate.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ var (
4545
)
4646

4747
var bundleValidateCommand = cli.Command{
48-
Name: "validate",
49-
Usage: "validate a OCI bundle",
50-
Flags: bundleValidateFlags,
48+
Name: "validate",
49+
Usage: "validate a OCI bundle",
50+
Flags: bundleValidateFlags,
5151
Before: before,
5252
Action: func(context *cli.Context) error {
5353
inputPath := context.String("path")
@@ -170,6 +170,17 @@ func checkProcess(process rspec.Process, rootfs string) {
170170
}
171171
}
172172

173+
if len(process.Args) < 1 {
174+
logrus.Fatalf("args should not be empty")
175+
}
176+
command := process.Args[0]
177+
if filepath.IsAbs(command) {
178+
cmdPath := path.Join(rootfs, command)
179+
if _, err := os.Stat(cmdPath); err != nil {
180+
logrus.Fatalf("Cannot find the command path %q", cmdPath)
181+
}
182+
}
183+
173184
for index := 0; index < len(process.Capabilities); index++ {
174185
capability := process.Capabilities[index]
175186
if !capValid(capability) {

0 commit comments

Comments
 (0)