源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
This commit is contained in:
commit
2ed3415fb7
8018 files changed
+1936476
No files matched your search
@@ -0,0 +1,77 @@
|
||||
package agentextension
|
||||
|
||||
import (
|
||||
"debug/elf"
|
||||
"debug/macho"
|
||||
"debug/pe"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func validateNativeExecutablePlatform(path, platform string) error {
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
return validateNativeExecutableFile(file, platform)
|
||||
}
|
||||
|
||||
func validateNativeExecutableFile(file *os.File, platform string) error {
|
||||
osName, architecture, ok := strings.Cut(platform, "-")
|
||||
if !ok || osName == "" || architecture == "" {
|
||||
return errors.New("native executable platform identity is invalid")
|
||||
}
|
||||
switch osName {
|
||||
case "darwin":
|
||||
parsed, err := macho.NewFile(file)
|
||||
if err != nil {
|
||||
return fmt.Errorf("runtime artifact is not a Mach-O executable: %w", err)
|
||||
}
|
||||
defer parsed.Close()
|
||||
want := macho.CpuAmd64
|
||||
if architecture == "arm64" {
|
||||
want = macho.CpuArm64
|
||||
} else if architecture != "amd64" {
|
||||
return fmt.Errorf("unsupported Mach-O architecture %s", architecture)
|
||||
}
|
||||
if parsed.Cpu != want {
|
||||
return fmt.Errorf("Mach-O architecture is %s, want %s", parsed.Cpu, want)
|
||||
}
|
||||
case "linux":
|
||||
parsed, err := elf.NewFile(file)
|
||||
if err != nil {
|
||||
return fmt.Errorf("runtime artifact is not an ELF executable: %w", err)
|
||||
}
|
||||
defer parsed.Close()
|
||||
want := elf.EM_X86_64
|
||||
if architecture == "arm64" {
|
||||
want = elf.EM_AARCH64
|
||||
} else if architecture != "amd64" {
|
||||
return fmt.Errorf("unsupported ELF architecture %s", architecture)
|
||||
}
|
||||
if parsed.Machine != want {
|
||||
return fmt.Errorf("ELF architecture is %s, want %s", parsed.Machine, want)
|
||||
}
|
||||
case "windows":
|
||||
parsed, err := pe.NewFile(file)
|
||||
if err != nil {
|
||||
return fmt.Errorf("runtime artifact is not a PE executable: %w", err)
|
||||
}
|
||||
defer parsed.Close()
|
||||
want := uint16(pe.IMAGE_FILE_MACHINE_AMD64)
|
||||
if architecture == "arm64" {
|
||||
want = pe.IMAGE_FILE_MACHINE_ARM64
|
||||
} else if architecture != "amd64" {
|
||||
return fmt.Errorf("unsupported PE architecture %s", architecture)
|
||||
}
|
||||
if parsed.Machine != want {
|
||||
return fmt.Errorf("PE architecture is %#x, want %#x", parsed.Machine, want)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("native executable verification is unsupported on %s", platform)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user