[PATCH STABLE] tests-subrepo-git: use "f" to dump pwned.txt, for portability

Augie Fackler raf at durin42.com
Fri Jun 3 22:37:30 EDT 2016


On Thu, Jun 02, 2016 at 04:22:13PM -0700, danek.duvall at oracle.com wrote:
> # HG changeset patch
> # User Danek Duvall <danek.duvall at oracle.com>
> # Date 1464909524 25200
> #      Thu Jun 02 16:18:44 2016 -0700
> # Branch stable
> # Node ID b6f54f37514125e4c10c9a1c78d1e0b5c8f2f67b
> # Parent  e82ca7d0967cd10d92562820297c3413abe6fc29
> tests-subrepo-git: use "f" to dump pwned.txt, for portability

Queued for stable, thanks for cleaning this little mess up so diligently.

>
> Rather than sometimes using a complicated shell construct to dump pwned.txt
> (if it wasn't expected to exist, but might, if something were broken) or
> just cat (if it was expected to exist), just use the "f" utility, which
> will be consistent in its behavior across different platforms.
>
> Also make sure that *something* gets put into pwned.txt, even if we ended
> up typoing the message variable.
>
> diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t
> --- a/tests/test-subrepo-git.t
> +++ b/tests/test-subrepo-git.t
> @@ -1135,7 +1135,7 @@ make sure we show changed files, rather
>  test for Git CVE-2016-3068
>    $ hg init malicious-subrepository
>    $ cd malicious-subrepository
> -  $ echo "s = [git]ext::sh -c echo% \$PWNED_MSG% >pwned.txt" > .hgsub
> +  $ echo "s = [git]ext::sh -c echo% pwned:% \$PWNED_MSG% >pwned.txt" > .hgsub
>    $ git init s
>    Initialized empty Git repository in $TESTTMP/tc/malicious-subrepository/s/.git/
>    $ cd s
> @@ -1152,10 +1152,11 @@ test for Git CVE-2016-3068
>    Cloning into '$TESTTMP/tc/malicious-subrepository-protected/s'... (glob)
>    fatal: transport 'ext' not allowed
>    updating to branch default
> -  cloning subrepo s from ext::sh -c echo% $PWNED_MSG% >pwned.txt
> +  cloning subrepo s from ext::sh -c echo% pwned:% $PWNED_MSG% >pwned.txt
>    abort: git clone error 128 in s (in subrepo s)
>    [255]
> -  $ test -f pwned.txt && cat pwned.txt || true
> +  $ f -Dq pwned.txt
> +  pwned.txt: file not found
>
>  whitelisting of ext should be respected (that's the git submodule behaviour)
>    $ rm -f pwned.txt
> @@ -1167,8 +1168,8 @@ whitelisting of ext should be respected
>    Please make sure you have the correct access rights
>    and the repository exists.
>    updating to branch default
> -  cloning subrepo s from ext::sh -c echo% $PWNED_MSG% >pwned.txt
> +  cloning subrepo s from ext::sh -c echo% pwned:% $PWNED_MSG% >pwned.txt
>    abort: git clone error 128 in s (in subrepo s)
>    [255]
> -  $ cat pwned.txt
> -  you asked for it
> +  $ f -Dq pwned.txt
> +  pwned: you asked for it
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list