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

Simple obfuscation for large literals #720

Merged
merged 2 commits into from
Apr 30, 2023
Merged

Conversation

DominicBreuker
Copy link
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
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.

testdata/script/literals.txtar Outdated Show resolved Hide resolved
testdata/script/literals.txtar Show resolved Hide resolved
main_test.go Outdated Show resolved Hide resolved
@DominicBreuker
Copy link
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
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.

None yet

2 participants