diff --git a/scripts/vuln01_regression.sh b/scripts/vuln01_regression.sh index 3e62c58..179a59a 100755 --- a/scripts/vuln01_regression.sh +++ b/scripts/vuln01_regression.sh @@ -30,10 +30,12 @@ request() { if ! status="$(curl "${CURL_ARGS[@]}" -o "$body" -w '%{http_code}' "$url")"; then status="000" : > "$body" + printf '%s' "$status" > "$TMP_DIR/$name.status" printf '%-28s HTTP %s REQUEST_FAILED\n' "$name" "$status" printf '%s\n' "$body" return 0 fi + printf '%s' "$status" > "$TMP_DIR/$name.status" printf '%-28s HTTP %s\n' "$name" "$status" printf '%s\n' "$body" } @@ -107,7 +109,7 @@ else exit 1 fi -if php -r '$d=json_decode(file_get_contents($argv[1]), true); exit(is_array($d) && (($d["message"] ?? null) === "课程不存在") ? 0 : 1);' "$TMP_DIR/course-detail-missing.json"; then +if [[ "$(cat "$TMP_DIR/course-detail-missing.status")" == "404" ]] || php -r '$d=json_decode(file_get_contents($argv[1]), true); exit(is_array($d) && (($d["message"] ?? null) === "课程不存在") ? 0 : 1);' "$TMP_DIR/course-detail-missing.json"; then printf 'MISSING_COURSE_VALIDATION PASS\n' else printf 'MISSING_COURSE_VALIDATION FAIL\n'