Open CaledoniaProject opened 5 years ago
I have removed the relevant code, but still got issues
2019/03/09 04:14:58 Obfuscating strings...
2019/03/09 04:14:58 Obfuscating symbols...
Renamed 1 occurrence in 1 file in 1 package.
Renamed 2 occurrences in 2 files in 2 packages.
Renamed 2 occurrences in 2 files in 2 packages.
Renamed 2 occurrences in 2 files in 1 package.
Renamed 1 occurrence in 1 file in 1 package.
Renamed 1 occurrence in 1 file in 1 package.
Renamed 1 occurrence in 1 file in 1 package.
Renamed 1 occurrence in 1 file in 1 package.
build cache is required, but could not be located: GOCACHE is not defined and neither $XDG_CACHE_HOME nor $HOME are defined
Failed to compile: exit status 1
Try the latest master
branch, which sets GOCACHE.
New errors:
Failed to obfuscate symbols: top-level renames: /tmp/026921609/src/xxxxx/doc.go:10:1: expected declaration, found available
Source code:
// Package pty provides functions for working with Unix terminals.
package pty
import (
"errors"
"os"
)
// ErrUnsupported is returned if a function is not
// available on the current platform.
var ErrUnsupported = errors.New("unsupported")
Interesting. I'm guessing some other stage of the obfuscation pipeline corrupted the doc.go
file somehow. To find out, try adding the -outdir
flag so you can keep the obfuscated GOPATH
after the obfuscation fails. Then you can look at the exact doc.go
file that gorename
is complaining about.
I've deleted all previous comments and merged the bug report into one:
Unable to process multiple //
comments
// ErrUnsupported is returned if a function is not
// available on the current platform.
var ErrUnsupported = errors.New("unsupported")
became
9 // ErrUnsupported is returned if a function is not
10 available on the current platform.
11 m.
12 var ErrUnsupported = errors.New((func() string {
13 mask := []byte("\x2e\xe5\xd4\xcd\x26\x50\xa8\x1c\xce\xe3\x55")
14 maskedStr := []byte("\x5b\x8b\xa7\xb8\x56\x20\xc7\x6e\xba\x86\x31")
Unable to process /**/
style comments:
/* ErrUnsupported is returned if a function is not
available on the current platform. */
became
/* ErrUnsupported is returned if a function is not
available on the current platform.
/
Did not process comments after package
keyword.
package unix // import "golang.org/x/sys/unix"
This will throw an error if package name is unexpected:
src/XXX/args.go:4:2: code in directory /XXXX/src/XXX/XXX/jidgeindacgiemcpihnp/unix expects import "golang.org/x/sys/unix"
I've patched removeDoNotEdit and append only comments that contains the keyword // +build
, it finally worked.
By the way, removeDoNotEdit had a bug for a brief while (a few hours) before I fixed it. Is the comment problem still happening on the latest master branch? The latest master should also respect build tags (added yesterday)
Yes, it is the master branch. The last commit is 18 hours ago.
Problem 3 is an interesting one, as it seems to reveal deeper problems with some Go build tools. For example, my IDE complains about the comment example you provided, and it simply relies on existing Go source code analysis tools. I think we should create a separate issue for problem 3.
To check the other two problems, I created a directory in my GOPATH with the package name github.com/unixpickle/testme
and made a main.go file:
package main
import (
"errors"
"fmt"
)
// ErrUnsupported is returned if a function is not
// available on the current platform.
var ErrUnsupported = errors.New("unsupported")
// Foo is a cool structure
// with a doc comment.
type Foo struct {
}
/* Ignored checks something
that it shouldn't? */
func (f *Foo) Ignored() {
}
func main() {
fmt.Println("hi")
}
Gobfuscate correctly obfuscates it with this output:
package main
import (
"errors"
"fmt"
)
// Mkcdnleioandomamdfam is returned if a function is not
// available on the current platform.
var Mkcdnleioandomamdfam = errors.New((func() string {
mask := []byte("\x21\x0f\xc7\xbb\x81\x86\x39\xac\x48\xa4\xc6")
maskedStr := []byte("\x54\x61\xb4\xce\xf1\xf6\x56\xde\x3c\xc1\xa2")
res := make([]byte, 11)
for i, m := range mask {
res[i] = m ^ maskedStr[i]
}
return string(res)
}()))
// Ogfkflibbhjhjmmgjajd is a cool structure
// with a doc comment.
type Ogfkflibbhjhjmmgjajd struct {
}
/* Ignored checks something
that it shouldn't? */
func (f *Ogfkflibbhjhjmmgjajd) Cdlckjmaedannakkmjko() {
}
func main() {
fmt.Println((func() string {
mask := []byte("\xaf\xa2")
maskedStr := []byte("\xc7\xcb")
res := make([]byte, 2)
for i, m := range mask {
res[i] = m ^ maskedStr[i]
}
return string(res)
}()))
}
On commit a1091026f8b56f40d54e218c597993c3486dacd7, I see problems 1 and 2 as you described. But not on master.
I got the following error with gobfuscate:
How can I debug this?