You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
garble/testdata/scripts
Daniel Martí af517a20f8 make the handling of import paths more robust
First, make isPrivate panic on malformed import paths, since that should
never happen. This catches the errors that some users had run into with
packages like gopkg.in/yaml.v2 and github.com/satori/go.uuid:

	panic: malformed import path "gopkg.in/garbletest%2ev2": invalid char '%'

This seems to trigger when a module path contains a dot after the first
element, *and* that module is fetched via the proxy. This results in the
toolchain URL-encoding the second dot, and garble ends up seeing that
encoded path.

We reproduce this behavior with a fake gopkg.in module added to the test
module proxy. Using yaml.v2 directly would have been easier, but it's
pretty large. Note that we tried a replace directive, but that does not
trigger the URL-encoding bug.

Also note that we do not obfuscate the gopkg.in package; that's fine, as
the isPrivate path validity check catches the bug either way.

For now, make initImport use url.PathUnescape to work around this issue.
The underlying bug is likely in either the goobj2 fork, or in the
upstream Go toolchain itself.

hashImport also gives a better error if it cannot find a package now,
rather than just an "empty seed" panic.

Finally, the sanity check in isPrivate unearthed the fact that we do not
support garbling test packages at all, since they were invalid paths
which never matched GOPRIVATE. Add an explicit check and TODO about
that.

Fixes #224.
Fixes #228.
5 years ago
..
asm.txt testdata: don't let tests rely on rewriting mod files 5 years ago
basic.txt obfuscate unexported names like exported ones (#227) 5 years ago
cgo.txt testdata: don't let tests rely on rewriting mod files 5 years ago
debugdir.txt testdata: don't let tests rely on rewriting mod files 5 years ago
goprivate.txt obfuscate fewer std packages (#196) 5 years ago
goversion.txt make -coverprofile include toolexec processes (#216) 5 years ago
help.txt include a "garble version" test (#221) 5 years ago
implement.txt testdata: don't let tests rely on rewriting mod files 5 years ago
imports.txt make the handling of import paths more robust 5 years ago
init.txt testdata: add test case for init funcs in many files (#208) 5 years ago
ldflags.txt testdata: don't let tests rely on rewriting mod files 5 years ago
linkname.txt fixed some bugs related to additional linkname corner cases (#210) 5 years ago
literals.txt do not try to obfuscate huge literals (#204) 5 years ago
modinfo.txt testdata: don't let tests rely on rewriting mod files 5 years ago
plugin.txt testdata: don't let tests rely on rewriting mod files 5 years ago
reverse.txt initial support for reversing panic output (#225) 5 years ago
seed.txt testdata: don't let tests rely on rewriting mod files 5 years ago
syntax.txt make the handling of import paths more robust 5 years ago
test.txt testdata: don't let tests rely on rewriting mod files 5 years ago
tiny.txt testdata: don't let tests rely on rewriting mod files 5 years ago