Strip all filename and position info when -tiny is passed (#128)
Co-authored-by: pagran <pagran@protonmail.com> Co-authored-by: lu4p <lu4p@pm.me>pull/133/head
parent
1b50a898bd
commit
d679944408
@ -1,43 +1,32 @@
|
||||
env GOPRIVATE=test/main
|
||||
|
||||
env TINY_PATTERN='^\/\/line :1$'
|
||||
env DEFAULT_PATTERN='^\/\/line \w\.go:[1-9][0-9]*$'
|
||||
env DEFAULT_STACK_PATTERN='^\t\w\.go:[1-9][0-9]*(\s\+0x[0-9a-f]+)?'
|
||||
env TINY_STACK_PATTERN='^\t\?\?:[0-9][0-9]*(\s\+0x[0-9a-f]+)?$'
|
||||
|
||||
# Tiny mode
|
||||
garble -tiny -debugdir=.obf-src build
|
||||
|
||||
grep $TINY_PATTERN .obf-src/main/main.go
|
||||
! grep $DEFAULT_PATTERN .obf-src/main/main.go
|
||||
|
||||
! exec ./main$exe
|
||||
! stderr 'main\.go'
|
||||
! stderr $DEFAULT_STACK_PATTERN
|
||||
stderr $TINY_STACK_PATTERN
|
||||
garble -tiny build
|
||||
exec ./main$exe
|
||||
stderr '\? 0'
|
||||
|
||||
[short] stop # no need to verify this with -short
|
||||
|
||||
# Default mode
|
||||
|
||||
garble -debugdir=.obf-src build
|
||||
|
||||
# Check for file name leak protection
|
||||
grep $TINY_PATTERN .obf-src/main/main.go
|
||||
grep '^\/\/line :1$' .obf-src/main/main.go
|
||||
|
||||
# Check for default line obfuscation
|
||||
grep $DEFAULT_PATTERN .obf-src/main/main.go
|
||||
grep '^\/\/line \w\.go:[1-9][0-9]*$' .obf-src/main/main.go
|
||||
exec ./main$exe
|
||||
|
||||
! exec ./main$exe
|
||||
! stderr 'main\.go'
|
||||
! stderr $TINY_STACK_PATTERN
|
||||
stderr $DEFAULT_STACK_PATTERN
|
||||
stderr '\w\.go [1-9]'
|
||||
|
||||
-- go.mod --
|
||||
module test/main
|
||||
-- main.go --
|
||||
package main
|
||||
|
||||
import "runtime"
|
||||
|
||||
func main() {
|
||||
panic("Test")
|
||||
}
|
||||
_, file, line, _ := runtime.Caller(0)
|
||||
println(file, line)
|
||||
}
|
Loading…
Reference in New Issue