ytsaurus icon indicating copy to clipboard operation
ytsaurus copied to clipboard

Detect empty executable files in operations

Open koct9i opened this issue 9 months ago • 0 comments

Operation command is executed as shell script. https://ytsaurus.tech/docs/en/user-guide/data-processing/operations/operations-options#user_script_options

Posix shell has a confusing behavior for non-binary executable files without "#!" -- it silently executes them as a script: https://linux.die.net/man/1/bash

If this execution fails because the file is not in executable format, and the file is not a directory, it is assumed to be a shell script, a file containing shell commands.

I.e. any empty file always executes successfully.

It seems the only way to avoid that confusion is an adding sanity check for executable files in "file_paths": https://ytsaurus.tech/docs/en/user-guide/data-processing/operations/operations-options#files

For now "size > 0" should be enough.

But we could check file magic as well - might be useful for cross-arch cross-os operations.

koct9i avatar May 24 '24 10:05 koct9i