-
-
Notifications
You must be signed in to change notification settings - Fork 262
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
Add support for obfuscating files embedded via //go:embed #194
Comments
I think this should be low priority, because it's fairly easy to have a pre-build step that obfuscates the files to embed before calling |
Hi @mvdan I've just came across this to where I'd need to obfuscate files embeded via go:embed, as per your comment, do you have any examples of how this could work? I guess i'd need to de obfuscate the contents of these files when running the application to.
|
I wrote https://github.com/lu4p/embed-encrypt a while ago, if you want to use it it would need to be updated to work with a current go version. (There is a PR of someone working on it) I still think this should be part of garble as using another pre build step is pretty cumbersome. |
I'm not opposed to merging this into garble if someone else implements it. Hopefully it wouldn't add much maintainer complexity in the long term. Perhaps we could reuse some of the code used for literal obfuscation, with the caveat that source literals tend to be small, and embedded files can easily get large, e.g. images weighing megabytes. |
Draft: https://go.googlesource.com/proposal/+/master/design/draft-embed.md
Proposal: golang/go#41191
User facing api: https://github.com/golang/go/blob/master/src/embed/embed.go
Compiler support commit: golang/go@8bde9b3
The compiler puts the embedded files directly into the objectfile, so we need to rewrite the generated objectfiles, to replace the embedded files with an obfuscated version.
embed.FS
Supporting
embed.FS
(var x embed.FS
) should be relatively straightforward.We would need to rewrite the following functions from
src/embed/embed.go
:func (f *file) Name() string
func (f FS) lookup(name string) *file
func (f *file) Info() (fs.FileInfo, error)
func (f FS) readDir(dir string) []file
func (f *openFile) Read(b []byte) (int, error)
We already do sth. similar in https://github.com/burrowers/garble/blob/master/runtime_strip.go.
Alternatively we could add a wrapper
func WrapFS(fs embed.FS) garble.FS
, which would allow us to not rewritesrc/embed/embed.go
and instead move the responsibility to the user.variables
Variables are more tricky:
We would probably need to inject lambda functions into the Objectfile.
On a source code level those would look similiar to this one:
Alternatively we could export a
func DecodeEmbededString(*string)
function, which could then be called by the user to decode the embedded variable.This is blocked by #124.
The text was updated successfully, but these errors were encountered: