Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: interface conversion: types.Type is *types.TypeParam, not *types.Struct #899

Open
i11us0ry opened this issue Dec 13, 2024 · 1 comment

Comments

@i11us0ry
Copy link

What version of Garble and Go are you using?

$ garble version
mvdan.cc/garble v0.13.0

$ go version
go1.23.0

What environment are you running Garble on?

arm64 darwin

go env Output
$ go env
GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/user/Library/Caches/go-build'
GOENV='/Users/user/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/user/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/user/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/Users/user/go/pkg/mod/golang.org/[email protected]'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/user/go/pkg/mod/golang.org/[email protected]/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/user/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/user/Desktop/work/tools/garble/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/3s/px98z93j0lz39tykygvb6pr00000gp/T/go-build55363994=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I wrote a tool myself that references the GitHub/projectdiscovery/utls/conn/connpool dependency, and then prepared to use Garble to obfuscate my tool

What did you expect to see?

I hope he can successfully confuse it

What did you see instead?

The following error occurred during the confusion process:

github.com/projectdiscovery/utils/conn/connpool

panic: interface conversion: types.Type is *types.TypeParam, not *types.Struct

I asked chatgpt and with their help, I made the following modifications to 1789 lines of code for the garrle/main.go program. After the modification, I recompiled Garble and confused my tools, and it succeeded. I want to know if this modification has a significant impact

	case *types.Struct:
		if structOrigin, ok := origin.(*types.Struct); ok {
			for i := 0; i < used.NumFields(); i++ {
				field := used.Field(i)
				fieldToStruct[field] = structOrigin

				if field.Embedded() {
					recordType(field.Type(), structOrigin.Field(i).Type(), done, fieldToStruct)
				}
			}
		} else {
			return
		}
	}
@lu4p
Copy link
Member

lu4p commented Dec 13, 2024

Do you mind opening a PR with the change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants