-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
types used for reflection in importers cause breakage #788
Comments
Your code can't produce your expected output. Are you sure that 4 and 5 are expected? Are you sure Have you tried without literals? |
Example to replicate the errorThe previous example its bad, I create a new code (not pseucode, this really works) to replicate the error. package main
import (
"context"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
)
var (
ctx = context.Background()
cli *client.Client
)
const (
helloWorld = "helloWorld"
)
func main() {
cli, _ = client.NewClientWithOpts(client.FromEnv)
removeHelloWorldContainer()
upOfficialHelloWorldImage()
println("success!")
}
func removeHelloWorldContainer() {
containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{All: true})
if err != nil {
println("Failed to list containers:", err)
panic("")
}
for _, c := range containers {
println("print before c.Names[0]")
if c.Names[0] == "/"+helloWorld {
println("print after c.Names[0]")
err := cli.ContainerRemove(context.Background(), c.ID, types.ContainerRemoveOptions{
Force: true,
})
if err != nil {
println(err.Error())
panic("")
}
}
}
}
func upOfficialHelloWorldImage() {
helloWorldContainer, err := cli.ContainerCreate(ctx, &container.Config{
Image: "hello-world",
}, nil, nil,
nil, helloWorld)
if err != nil {
println(err)
panic("")
}
// Start PostgresSQL container
if err := cli.ContainerStart(ctx, helloWorldContainer.ID, types.ContainerStartOptions{}); err != nil {
println(err)
panic("")
}
} Executed commandsThis its my makefile. I use a compiled from master branch. (because the last version can't handle protopuf)
very-very-obfuscate:
garble -literals -tiny -seed=random build -o ./very-very-obfuscate
obfuscate:
garble build -o ./obfuscate
go-build:
go build -o ./go-build LOGSvery-very-obfuscate (logs)
obfuscate (logs)
go-build (logs)
|
As it looks, the regular compilation works fine, but any compilation done by garble fails to execute the code properly. Could it be that something needs further refinement in the protobuf patch in master branch? |
I don't think I fully understand how the service works in depth to be able to generate a PR, but I'd be happy to help with anything I can. |
@mvdan hello, I already added info to the issue. |
Try add to your code: I think name obfuscation breaks docker response deserialisation |
To fix this we could either: |
I think a) would be the optimal solution. Couldn't we run a preemptive |
Option B would make the obfuscator "give up" on many Go types out there, and it's still not guaranteed to be a full fix. So I don't think it's a good idea. We have discussed option A before, I think. Perhaps it was on Slack, because I can't find it. I also worry about discussing it here, because we could get somewhat deep in the detail in the comments here. My thoughts are that it can work, but it's very expensive. Suppose we have the main packages M1 and M2, which both import the library package P. Right now, if we do
|
Also: option B would never work with a command like #369, because it would be impossible to know how downstreams or importers would use the exposed types with reflection. I think that's another reason to not go down that route. |
Retitling the issue. To reiterate, this is a known limitation, and this is why the README suggests using I'm happy to leave the issue open for discussion, but see my last two comments - I don't think this has a good or easy solution that will "just work" for most users. |
@ezequielaguilera1993 This is probably fixed now, can you test again with current master Feel free to reopen if not fixed. |
What version of Garble and Go are you using?
What environment are you running Garble on?
(work computer)
(work computer)
go env
OutputWhat did you do?
garble -literals -tiny -seed=random build
I made a code that lists the containers within Docker to remove them, but the obfuscated code doesn't work (the non-obfuscated one does).
What did you expect to see?
Finish the code and print this
tryToRemoveContainers: 1
tryToRemoveContainers: 2
tryToRemoveContainers: 2.6
tryToRemoveContainers: 3
tryToRemoveContainers: 4
tryToRemoveContainers: 5
What did you see instead?
tryToRemoveContainers: 1
tryToRemoveContainers: 2
tryToRemoveContainers: 2.6
break in this line
The text was updated successfully, but these errors were encountered: