@@ -69,19 +69,25 @@ write_pack() {
6969 local expires_at=" $2 "
7070 local arch=" $3 "
7171 local include_artifact=" ${4:- yes} "
72+ local artifact_rel=" ${5:- artifacts/ fixture.module/ ${TOOL} -install.sh} "
7273 local output_dir=" $TEST_ROOT /$name "
7374 local pack_root=" $output_dir /acfs-offline-pack"
74- local artifact_rel=" artifacts/fixture.module/${TOOL} -install.sh"
7575 local artifact_path=" $pack_root /$artifact_rel "
7676 local artifact_size=" "
7777 local artifacts_json=" []"
7878
79- mkdir -p " $pack_root /artifacts/fixture.module "
79+ mkdir -p " $pack_root /artifacts"
8080 write_checksums " $pack_root /checksums.yaml" " $ARTIFACT_SHA "
8181
8282 if [[ " $include_artifact " == " yes" ]]; then
83+ mkdir -p " ${artifact_path%/* } "
8384 printf ' %s' " $CONTENT " > " $artifact_path "
8485 artifact_size=" $( acfs_security_file_size " $artifact_path " ) "
86+ elif [[ " $include_artifact " == " manifest-only" ]]; then
87+ artifact_size=" $( printf ' %s' " $CONTENT " | wc -c | tr -d ' [:space:]' ) "
88+ fi
89+
90+ if [[ " $include_artifact " == " yes" || " $include_artifact " == " manifest-only" ]]; then
8591 artifacts_json=" $(
8692 jq -n \
8793 --arg id " fixture.module:$TOOL " \
@@ -232,6 +238,19 @@ test_missing_artifact_is_refused() {
232238 expect_refusal_code " missing_artifact_is_refused" " $pack_root " " pack_unbundled_required_module"
233239}
234240
241+ test_symlink_parent_escape_is_refused () {
242+ local pack_root=" "
243+ local outside_dir=" $TEST_ROOT /outside-artifacts"
244+ local artifact_rel=" artifacts/escape-parent/${TOOL} -install.sh"
245+
246+ pack_root=" $( write_pack " symlink-parent-escape" " $FUTURE_EXPIRES " " $CURRENT_ARCH " manifest-only " $artifact_rel " ) "
247+ mkdir -p " $outside_dir "
248+ printf ' %s' " $CONTENT " > " $outside_dir /${TOOL} -install.sh"
249+ ln -s " $outside_dir " " $pack_root /artifacts/escape-parent"
250+
251+ expect_refusal_code " symlink_parent_escape_is_refused" " $pack_root " " pack_path_escape"
252+ }
253+
235254test_unsupported_arch_is_refused () {
236255 local pack_root=" "
237256
@@ -301,6 +320,7 @@ run_all_tests() {
301320 test_stale_pack_is_refused
302321 test_tampered_artifact_is_refused
303322 test_missing_artifact_is_refused
323+ test_symlink_parent_escape_is_refused
304324 test_unsupported_arch_is_refused
305325 test_missing_pack_fails_closed
306326 test_live_path_still_works_without_pack
0 commit comments