|
|
|
@ -71,9 +71,17 @@ func extractDebugObfSrc(pkgPath string, pkg *goobj2.Package) error {
|
|
|
|
|
if envGarbleDebugDir == "" {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var archiveMember *goobj2.ArchiveMember
|
|
|
|
|
for _, member := range pkg.ArchiveMembers {
|
|
|
|
|
if member.ArchiveHeader.Name != garbleSrcHeaderName {
|
|
|
|
|
continue
|
|
|
|
|
if member.ArchiveHeader.Name == garbleSrcHeaderName {
|
|
|
|
|
archiveMember = &member
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if archiveMember == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
osPkgPath := filepath.FromSlash(pkgPath)
|
|
|
|
@ -82,12 +90,12 @@ func extractDebugObfSrc(pkgPath string, pkg *goobj2.Package) error {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
archiveSize, err := strconv.Atoi(member.ArchiveHeader.Date)
|
|
|
|
|
archiveSize, err := strconv.Atoi(archiveMember.ArchiveHeader.Date)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
archiveBytes := member.ArchiveHeader.Data[:archiveSize]
|
|
|
|
|
archiveBytes := archiveMember.ArchiveHeader.Data[:archiveSize]
|
|
|
|
|
|
|
|
|
|
archive := bytes.NewBuffer(archiveBytes)
|
|
|
|
|
gzipReader, err := gzip.NewReader(archive)
|
|
|
|
@ -117,10 +125,12 @@ func extractDebugObfSrc(pkgPath string, pkg *goobj2.Package) error {
|
|
|
|
|
debugFile.Close()
|
|
|
|
|
|
|
|
|
|
obfuscationTime := header.ModTime.Local()
|
|
|
|
|
os.Chtimes(debugFilePath, obfuscationTime, obfuscationTime) // Restore obfuscation time
|
|
|
|
|
|
|
|
|
|
// Restore the actual source obfuscation time so as not to mislead the user.
|
|
|
|
|
if err := os.Chtimes(debugFilePath, obfuscationTime, obfuscationTime); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// obfuscateImports does all the necessary work to replace the import paths of
|
|
|
|
|