#!/bin/sh # Regression tests from the audits of September and October 2026. Each case # is a config, repository or request that used to crash cgit, end it inside # git, or hand a visitor something other than what was asked for. test_description='Check the audit regressions' . ./setup.sh test_expect_success 'set up a repository and a config to vary' ' mkrepo repos/rob 3 && sha=$(git -C repos/rob rev-parse HEAD~1) && { echo "virtual-root=/" && echo "cache-size=0" && echo "snapshots=tar.gz" && echo "repo.url=rob" && echo "repo.path=$PWD/repos/rob/.git" } >robrc ' robq() { CGIT_CONFIG="$PWD/robrc" QUERY_STRING="$1" cgit; } test_expect_success 'a repository without a path answers 404' ' { echo "virtual-root=/" && echo "cache-size=0" && echo "repo.url=nopath" && echo "repo.url=emptypath" && echo "repo.path=" } >nopathrc && for r in nopath emptypath do CGIT_CONFIG="$PWD/nopathrc" QUERY_STRING="url=$r/log/" cgit >tmp && grep "^Status: 404 Not Found" tmp && grep "Failed to open $r: Not a valid git repository" tmp || return 1 done ' # The index dates a repository from files under its path, and one without a # path has none, whatever sits in the working directory. test_expect_success 'a repository without a path has no age on the index' ' mkdir -p "(null)/refs/heads" && >"(null)/refs/heads/master" && CGIT_CONFIG="$PWD/nopathrc" QUERY_STRING="url=" cgit >tmp && grep "" tmp && ! grep "