Follow up: Obfuscate more byte slice literals

pull/371/head
lu4p 3 years ago committed by Daniel Martí
parent ec0bdc4012
commit 3ab59000f3

@ -106,16 +106,16 @@ func Obfuscate(file *ast.File, info *types.Info, fset *token.FileSet, ignoreObj
}
var value byte
if lit.Kind == token.CHAR {
val, _, _, err := strconv.UnquoteChar(lit.Value, '\'')
val, err := strconv.Unquote(lit.Value)
if err != nil {
return true
panic(fmt.Sprintf("cannot unquote character: %v", err))
}
value = byte(val)
value = byte(val[0])
} else {
val, err := strconv.ParseUint(lit.Value, 0, 8)
if err != nil {
return true
panic(fmt.Sprintf("cannot parse integer: %v", err))
}
value = byte(val)

@ -225,9 +225,12 @@ func constantTest() {
const impType = imported.ImportedType(3)
}
// TODO: this only tests, that we don't break byte slices
// it was verified manually that these actually get obfuscated,
// however we should add regression tests
// TODO: This only tests that we don't break byte slices.
// It was manually verified that they do get obfuscated,
// The original bytes don't seem to show up in the binary,
// meaning that we can't test for them via binsubstr.
// We should figure out a way to test for the byte sequences.
// For now, we manually tested these when they got added.
func byteTest() {
a := []byte{12, 13}
for _, elm := range a {

Loading…
Cancel
Save