ArmyCyberInstitute / cmgr

CTF Challenge Manager
Apache License 2.0
17 stars 9 forks source link

Directory hashing fails on symlinks #38

Closed zwade closed 2 years ago

zwade commented 2 years ago

Specifically, if the directory contains a symbolic link to another directory, then hashing will get confused and say (e.g.)

cmgr: [WARN:  could not hash source files: read /Users/zacharywade/Documents/work/pico/2022/react-tests/node_modules/live-art-client: is a directory]

(As you might be able to guess from the path, this is a problem for yarn projects which always put symlinks to workspaces in the node_modules directory)

jrolli commented 2 years ago

Thanks for the report. Can you include more details on the structure of the challenge directory that this failed on? I'm guessing that problem.md is located in ..../react-tests/ but I want to confirm before I look into the best way to gracefully handle this.

zwade commented 2 years ago

Yeah! Thanks for looking into this, here's a pretty minimal POC

mkdir poc && cd poc

mkdir folder
touch folder/file1
ln -s folder file2

cat > problem.md <<EOF
# Test
- namespace: cmgr/test
- type: custom
EOF

echo "FROM empty" > Dockerfile

cmgr update .