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í ea2e0bdf71
obfuscate all variable names, even local ones (#420)
In the added test case, "garble -literals build" would fail:

	--- FAIL: TestScripts/literals (8.29s)
		testscript.go:397:
			> env GOPRIVATE=test/main
			> garble -literals build
			[stderr]
			# test/main
			Usz1FmFm.go:1: cannot call non-function string (type int), declared at Usz1FmFm.go:1
			Usz1FmFm.go:1: string is not a type
			Usz1FmFm.go:1: cannot call non-function append (type int), declared at Usz1FmFm.go:1

That is, for input code such as:

	var append int
	println("foo")
	_ = append

We'd end up with obfuscated code like:

	var append int
	println(func() string {
		// obfuscation...
		x = append(x, ...)
		// obfuscation...
		return string(x)
	})
	_ = append

Which would then break, as the code is shadowing the "append" builtin.
To work around this, always obfuscate variable names, so we end up with:

	var mwu1xuNz int
	println(func() string {
		// obfuscation...
		x = append(x, ...)
		// obfuscation...
		return string(x)
	})
	_ = mwu1xuNz

This change shouldn't make the quality of our obfuscation stronger,
as local variable names do not currently end up in Go binaries.
However, this does make garble more consistent in treating identifiers,
and it completely avoids any issues related to shadowing builtins.

Moreover, this also paves the way for publishing obfuscated source code,
such as #369.

Fixes #417.
3 years ago
..
asm.txt drop support for Go 1.16.x 4 years ago
basic.txt drop support for Go 1.16.x 4 years ago
cgo.txt drop support for Go 1.16.x 4 years ago
crossbuild.txt drop support for Go 1.16.x 4 years ago
debugdir.txt drop support for Go 1.16.x 4 years ago
embed.txt drop support for Go 1.16.x 4 years ago
goprivate.txt Obfuscate more packages of the standard library (#312) 4 years ago
goversion.txt drop support for Go 1.16.x 4 years ago
help.txt always require one argument for "reverse" 4 years ago
implement.txt drop support for Go 1.16.x 4 years ago
imports.txt drop support for Go 1.16.x 4 years ago
init.txt drop support for Go 1.16.x 4 years ago
ldflags.txt drop support for Go 1.16.x 4 years ago
linkname.txt Fix linkname directives with dots in importpath (#407) 4 years ago
literals.txt obfuscate all variable names, even local ones (#420) 3 years ago
modinfo.txt update modinfo.txt test for 1.18's build and VCS info 3 years ago
plugin.txt drop support for Go 1.16.x 4 years ago
position.txt drop support for Go 1.16.x 4 years ago
reflect.txt drop support for Go 1.16.x 4 years ago
reverse.txt testdata: tweak typechecking error for Go 1.18 again 3 years ago
runtime-related.txt Obfuscate more packages of the standard library (#312) 4 years ago
seed.txt drop support for Go 1.16.x 4 years ago
syntax.txt drop support for Go 1.16.x 4 years ago
test.txt drop support for Go 1.16.x 4 years ago
tiny.txt drop support for Go 1.16.x 4 years ago