adobe / aio-cli-plugin-asset-compute

Asset Compute Plugin for Adobe I/O Command Line Interface
Apache License 2.0
1 stars 7 forks source link

`util.prepareInOutDir()` should precreate `out/errors` to support optional extra files created by ShellScriptWorker #77

Closed adamcin closed 2 years ago

adamcin commented 2 years ago

Expected Behaviour

When testing a shellscript worker, it may be necessary to check for the presence or content of the out/errors/error.json and out/errors/type.txt output files defined by the ShellScriptWorker.prepareMetadata() function. A test script should have the ability to open these files for reading, in the same way that the out/rendition0.png file can be read.

Actual Behaviour

However, when running npm test in a CI environment under a different user than the docker daemon, the asset-compute plugin fails to ensure that the out/errors directory is pre-created with the execute bit allowed for everyone, which makes it possible for the docker user to create it with a more restrictive umask, leading to a situation like this:

$ sudo ls -laF /home/circleci/repo/.nui/2022_04_21T17_51_03_056Z/out
total 208
drwxrwxrwx 3 circleci       circleci         4096 Apr 21 17:51 ./
drwxrwxr-x 6 circleci       circleci         4096 Apr 21 17:51 ../
drwxrw-rw- 2 circleci-admin circleci-admin   4096 Apr 21 17:51 errors/
-rwxrw-rw- 1 circleci-admin circleci-admin 198804 Apr 21 17:51 rendition0.ai*

In the above example, even though the errors/ directory and its children are readable by everyone, the lack of the execute bit makes it impossible for the circleci user to open the directory to read the contents of those nested files.

Reproduce Scenario (including but not limited to)

  1. Set up a circleci pipeline using the default machine (linux) runner, where the docker agent is running as circleci-admin and the shell is running as circleci.
  2. Run npm test on a shellscript worker project where worker.sh writes content to either $errorfile or $typefile, for example:
mkdir -p "$(dirname "$typefile")"
echo "image/png" > "$typefile"
  1. Attempt to read the contents of the out/errors/type.txt file in the validate script
expect_typefile="$(dirname "${BASH_SOURCE[0]}")/type.txt"
typefile="$(dirname "$2")/errors/type.txt"
cmp -s "${expect_typefile}" "${typefile}"
  1. Confirm

Platform and Version

Links

adamcin commented 2 years ago

Verified fixed in v2.0.3 with merge of #79 and #80