Commit Graph

23 Commits

Author SHA1 Message Date
Daniel Martí
81b4c49702 move the "missing -trimpath" test to the slow group (#106)
This shouldn't break often, so it doesn't need to be covered by 'go test
-short'. Moreover, it's still a relatively expensive step, since we end
up reaching package compilation.
2020-08-20 11:51:55 +02:00
Daniel Martí
511779d8ff testdata: set GOPRIVATE in all but two tests (#104)
basic.txt just builds main.go without a module. Similarly, we leave
imports.txt without a GOPRIVATE, to test the 'go list -m' fallback.

For all other tests, explicitly set GOPRIVATE, to avoid two exec calls -
both 'go env GOPRIVATE' as well as 'go list -m'. Each of those calls
takes in the order of 10ms, so saving ~26 exec calls should easily add
to 200-300ms saved from 'go test -short'.
2020-08-20 11:51:55 +02:00
pagran
2735555ab2 Update filename and add line number obfuscation (#94)
Fixes  #2.

Line numbers are now obfuscated, via `//line` comments.
Filenames are now obfuscated via `//line` comments, instead of changing the actual filename.
New flag `-tiny` to reduce the binary size, at the cost of reversibility.
2020-08-14 20:47:15 +02:00
Daniel Martí
3e4f3821ea don't leak build version information via a const either
This requires a bit of extra magic to replace one constant in
runtime/internal/sys, but that was simple enough given that we can reuse
a lot of the code to parse the files and write them to a temporary dir.

We can also drop the -X flags, as runtime.buildVersion is based on the
constant that we replace here.

Fixes #44, again.
2020-06-28 22:01:12 +01:00
Daniel Martí
649cc2f6ba strip Go version information from the binary too
Fixes #44.
2020-06-20 16:24:07 +01:00
Daniel Martí
c7d1fc7c60 strip buildid information from linked binaries
Otherwise, one can use 'go tool buildid' to obtain the main package's
build ID, which can make de-obfuscating the main package much simpler.

Fixes #43.
2020-06-19 18:36:26 +01:00
Daniel Martí
462f60a307 sto pusing -toolexec directly in the tests
Since we introduced $GARBLE_DIR, we stopped recommending the use of
toolexec directly. It's still possible to set up the right flags and env
vars, but that will be a moving target.

In particular, string obfuscation in #16 will require using $GARBLE_DIR
in more scenarios. A work-in-progress patch for string obfuscation
triggered this test script to start failing for the reason above.

While at it, we don't care about what the second build contains, since
we already compare it with the previous build.
2020-06-01 13:49:37 +01:00
Daniel Martí
53272a1eda do less work in 'go test -short'
Only reduces the approximate elapsed time on my laptop from 7.8s to
7.5s, but that's still a win.
2020-04-04 20:48:46 +01:00
Daniel Martí
308e984293 don't use regexes when searching binaries for strings
This is a bit simpler, and saves us a small amount of CPU work in the
tests.
2020-02-23 12:57:39 +01:00
Daniel Martí
30524ea282 shorten 'go test -short' run time
Down from ~11s to ~7s, as we can skip some extra checks.

While at it, avoid duplicate 'go test' builds in test.txt.
2019-12-15 11:45:57 +00:00
Daniel Martí
5556be7402 make the tool work on Windows, enable tests
The tests required a few last tweaks to work on Windows.
2019-12-09 16:47:59 +00:00
Daniel Martí
0058dfc12a make output binaries deterministic
We were leaking temporary file paths, which is no longer the case.
2019-12-09 13:57:03 +00:00
Daniel Martí
ab560ff007 start testing on GitHub Actions
No windows yet, because a few portability issues remain.
2019-12-09 12:44:43 +00:00
Daniel Martí
e08dd99c1e introduce a binary grep command for the tests
The problem with the "grep" built-in command is that it prints the
entire data if there is an error. We don't want megabytes of binary
output for a test.
2019-12-09 12:21:48 +00:00
Daniel Martí
766bb47b82 support std imports 2019-12-08 20:18:52 +00:00
Daniel Martí
764af03e89 introduce 'garble build' shortcut
This way, the user doesn't need to remember to use flags like -a and
-trimpath. Also because we might need more 'go build' flags in the
future.
2019-12-08 18:15:10 +00:00
Daniel Martí
63f58242fb move garble binary setup with $PATH to Setup
This way, it's ready for multiple scripts.
2019-12-08 18:03:52 +00:00
Daniel Martí
8119fa0e62 use readelf in a way that it prints less output 2019-12-08 17:48:40 +00:00
Daniel Martí
f4e356ab13 start hashing identifiers 2019-12-08 17:37:46 +00:00
Daniel Martí
f47c12caba add a bit more docs 2019-12-08 16:24:49 +00:00
Daniel Martí
a670f80fe9 error if the user forgot -trimpath 2019-12-08 13:12:45 +00:00
Daniel Martí
f81b92a0fa start enforcing the link flags -w -s 2019-12-08 13:00:12 +00:00
Daniel Martí
f5f72ef626 initial commit 2019-12-08 11:52:40 +00:00