acquia / cli

Acquia CLI
GNU General Public License v2.0
42 stars 47 forks source link

CLI-1403: Some symlinks broken symlinks are wrongly present in artifact #1799

Open regilero opened 2 days ago

regilero commented 2 days ago

Description

By untracked folder I mean a folder excluded in the .gitignore file which is used in acli push:artifact to exclude some of the folders.

To Reproduce

mkdir allowed
mkdir crap
cd allowed
touch allowed
ln -s ../crap ln_crap_dir
ln -s ../crap/crap ln_crap_file
ln -s ../broken/link broken1
cd ../crap
touch crap
ln -s ../allowed/ ln_allowed_dir
ln -s ../allowed/allowed ln_allowed_file
ln -s ../broken/link broken2
cd ..
# Here we say we want allowed directory and not the crap directory in the artifact:
echo "/crap" >> .gitignore

> ls -alh crap/
total 13K
drwxrwxrwx 1 www-data www-data    0 Sep 18 11:02 .
drwxrwxrwx 1 www-data www-data 8.0K Sep 18 11:02 ..
lrwxr-xr-x 1 www-data www-data 1.1K Sep 18 11:02 broken2 -> ../broken/link
-rwxr-xr-x 1 www-data www-data    0 Sep 18 11:02 crap
lrwxr-xr-x 1 www-data www-data 1.1K Sep 18 11:02 ln_allowed_dir -> ../allowed/
lrwxr-xr-x 1 www-data www-data 1.1K Sep 18 11:02 ln_allowed_file -> ../allowed/allowed
> ls -alh allowed/
total 13K
drwxrwxrwx 1 www-data www-data    0 Sep 18 11:02 .
drwxrwxrwx 1 www-data www-data 8.0K Sep 18 11:02 ..
-rwxr-xr-x 1 www-data www-data    0 Sep 18 11:02 allowed
lrwxr-xr-x 1 www-data www-data 1.1K Sep 18 11:02 broken1 -> ../broken/link
lrwxr-xr-x 1 www-data www-data 1.1K Sep 18 11:02 ln_crap_dir -> ../crap
lrwxr-xr-x 1 www-data www-data 1.1K Sep 18 11:02 ln_crap_file -> ../crap/crap

After artifact generation:

> acli push:artifact  -n  -vvv  --no-clone  --no-push

> ls -alh /tmp/acli-push-artifact/crap/
total 0
drwxr-xr-x  2 www-data www-data 100 Sep 18 11:03 .
drwxr-xr-x 21 www-data www-data 740 Sep 18 11:04 ..
lrwxrwxrwx  1 www-data www-data  14 Sep 18 11:03 broken2 -> ../broken/link
lrwxrwxrwx  1 www-data www-data  11 Sep 18 11:03 ln_allowed_dir -> ../allowed/
lrwxrwxrwx  1 www-data www-data  18 Sep 18 11:03 ln_allowed_file -> ../allowed/allowed
> ls -alh /tmp/acli-push-artifact/allowed
total 0
drwxr-xr-x  2 www-data www-data  80 Sep 18 11:03 .
drwxr-xr-x 21 www-data www-data 740 Sep 18 11:04 ..
-rwxr-xr-x  1 www-data www-data   0 Sep 18 11:02 allowed
lrwxrwxrwx  1 www-data www-data  14 Sep 18 11:03 broken1 -> ../broken/link

Expected behavior

The fact that the broken link was keeped is subject of debate, maybe this link will activate on the targeted env for the artifact.

IMHO we should have a --allow-symlinks options in the artifact generation command, and then all symlinks in the forbidden directory should not be kept and crap/ should not be in the artifact, and all the symlinks in allowed/ should be present in the artifact (even the ones to crap/ and broken links) if we --allow-symlinks and none if we do not.