unixpickle / gobfuscate

Obfuscate Go binaries and packages
BSD 2-Clause "Simplified" License
1.45k stars 157 forks source link

json.Number issue #46

Open grv99 opened 3 years ago

grv99 commented 3 years ago

The strings obfuscator currently breaks for json.Number symbols.

Ex. https://github.com/auto-program/vendor/blob/9351d5081b8149a1d03a783dae10cf054146ed16/github.com/gocraft/dbr/types.go#L106

// UnmarshalJSON correctly deserializes a NullInt64 from JSON
func (n *NullInt64) UnmarshalJSON(b []byte) error {
    var s json.Number
    if err := json.Unmarshal(b, &s); err != nil {
        return err
    }
    if s == "" {
        return n.Scan(nil)
    }
    return n.Scan(s)
}
func (n *NullInt64) UnmarshalJSON(b []byte) error {
    var s json.Number
    if err := json.Unmarshal(b, &s); err != nil {
        return err
    }
    if s == (func() string {
mask := []byte("")
maskedStr := []byte("")
res := make([]byte, 0)
        for i, m := range mask {
            res[i] = m ^ maskedStr[i]
        }
        return string(res)
        }()) {
        return n.Scan(nil)
    }
    return n.Scan(s)
}

cannot compare s == ((func() string literal)()) (mismatched types json.Number and string)