Skip to content

Simple obfuscation for large literals#720

Merged
mvdan merged 2 commits intoburrowers:masterfrom
DominicBreuker:master
Apr 30, 2023
Merged

Simple obfuscation for large literals#720
mvdan merged 2 commits intoburrowers:masterfrom
DominicBreuker:master

Conversation

@DominicBreuker
Copy link
Copy Markdown
Contributor

Changes literal obfuscation such that literals of any size will be obfuscated, but beyond maxSize we only use the simple obfuscator. This one seems to apply one of the AND, OR or XOR operators byte-wise and should be safe to use.

The test for literals is changed a bit to verify that obfuscation is applied. The code written to the extra_literals.go file by the test helper now creates an init function with Printf statements inside. This way Go does not optimize the literals away when we compile. We also append a unique string to all literals so that we can test that an unobfuscated build contains this string while an obfuscated build does not.

Copy link
Copy Markdown
Member

@mvdan mvdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch! Just some minor stuff.

FYI @lu4p if you have any thoughts.

@DominicBreuker
Copy link
Copy Markdown
Contributor Author

attempt no. 2
test changed such that the -o out is gone. also added some comments to the test helper regarding the compiler optimization.
as for the code in extra_literals.go: agree that plain println would have been better, but I noticed that it might be even better to not print anything at all since failing tests otherwise mess up the terminal. thus I switched to an init function that appends literals to a global variable. like this:

var x = ""

func init() {
    x += "first_string"
    x += "second_string"
    ...
}

Copy link
Copy Markdown
Member

@mvdan mvdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Merging on green.

@mvdan mvdan merged commit b587d8c into burrowers:master Apr 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants