burrowers / garble

Obfuscate Go builds
BSD 3-Clause "New" or "Revised" License
3.73k stars 239 forks source link

Draft implementation: new subcommand for computing obfuscation map #850

Open fbbdev opened 2 months ago

fbbdev commented 2 months ago

This PR provides a draft implementation for the proposal described at #849.

The transformer.transformGoFile method contains some code that computes the obfuscated identifier for a given types.Object.

This patch does essentially two things:

  1. it refactors the transformer.transformGoFile method, lifting the code segment mentioned above into an independently callable method named transformer.obfuscateObjectName;
  2. it adds a new subcommand garble map that uses the newly added method transformer.obfuscateObjectName to compute the output described at #849.

The refactoring step is necessary to ensure the garble map command stays in sync with the algorithm used by transformGoFile.

I have not added a test yet because I am not familiar with the scripting language and it is also not entirely clear to me what the best approach would be for testing the new command.

The implementation of the new command resembles vaguely that of the reverse subcommand: