Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions builder/internal/commands/build_image_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,18 @@ func BuildImageCommand() int {
return handleErrorDuringBuild(build, "", fmt.Errorf("tester dir (%s) does not exist", testerDir))
}

testShPath := filepath.Join(testerDir, "test.sh")
fileInfo, err := os.Stat(testShPath)
if os.IsNotExist(err) {
return handleErrorDuringBuild(build, "", fmt.Errorf("test.sh does not exist in tester dir (%s)", testerDir))
}
if err != nil {
return handleErrorDuringBuild(build, "", fmt.Errorf("failed to stat test.sh in tester dir (%s): %w", testerDir, err))
}
if fileInfo.Mode()&0111 == 0 {
return handleErrorDuringBuild(build, "", fmt.Errorf("test.sh is not executable in tester dir (%s)", testerDir))
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing check that test.sh is a regular file

The validation checks existence and executable permissions but doesn't verify that test.sh is a regular file. If test.sh is a directory (which typically has execute bits set for traversal), the check fileInfo.Mode()&0111 == 0 passes, but attempting to execute it as a script later will fail. Adding a check like fileInfo.Mode().IsRegular() would catch this case and provide a clearer error message upfront.

Fix in Cursor Fix in Web


if _, err := os.Stat(testRunnerDir); os.IsNotExist(err) {
return handleErrorDuringBuild(build, "", fmt.Errorf("test runner dir (%s) does not exist", testRunnerDir))
}
Expand Down
Loading