disable signature & privileged

This commit is contained in:
Meo597
2026-10-15 12:22:56 +08:00
parent 65449d4f03
commit 03ee3f872f
5 changed files with 50 additions and 38 deletions
+3
View File
@@ -1,5 +1,7 @@
package lua
// TODO: Re-enable these tests and their helper when Compile supports privileged signature authorization again.
/*
import (
"bytes"
"crypto/ed25519"
@@ -80,3 +82,4 @@ func TestSignPrivilegedScriptRejectsInvalidSeed(t *testing.T) {
}
}
}
*/
+5 -3
View File
@@ -37,9 +37,11 @@ func Compile(script string) (*Program, error) {
return nil, errors.New("currently unavailable")
code, err = base64.Decode(script)
} else if name, err = platform.ResolveLuaFile(script); err == nil {
if code, err = os.ReadFile(name); err == nil {
privileged, err = verifyPrivilegedSignature(code)
}
code, err = os.ReadFile(name)
// TODO: Restore privileged signature authorization and re-enable the related tests and CLI entries.
// if err == nil {
// privileged, err = verifyPrivilegedSignature(code)
// }
}
if err != nil {
return nil, err
+24 -19
View File
@@ -3,10 +3,6 @@ package lua
import (
"bytes"
"context"
"crypto/ed25519"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"errors"
"fmt"
"net"
@@ -14,9 +10,7 @@ import (
"path/filepath"
"runtime"
"strings"
"sync"
"testing"
"time"
"weak"
xerrors "github.com/xtls/xray-core/common/errors"
@@ -234,6 +228,21 @@ func compileTestProgram(t *testing.T, code string) *Program {
return program
}
func writeTestScript(t *testing.T, code string) string {
t.Helper()
path := filepath.Join(t.TempDir(), "script.lua")
if err := os.WriteFile(path, []byte(code), 0o600); err != nil {
t.Fatal(err)
}
path, err := filepath.EvalSymlinks(path)
if err != nil {
t.Fatal(err)
}
return path
}
// TODO: Re-enable these tests and helpers when Compile supports privileged signature authorization again.
/*
const privilegedSignatureHeader = "-- @xray:privileged-signature="
// RFC 8032 test-vector key. The fixture signature was independently computed
@@ -266,19 +275,6 @@ func setTestPrivilegedPublicKey(t *testing.T, key string) {
}
}
func writeTestScript(t *testing.T, code string) string {
t.Helper()
path := filepath.Join(t.TempDir(), "script.lua")
if err := os.WriteFile(path, []byte(code), 0o600); err != nil {
t.Fatal(err)
}
path, err := filepath.EvalSymlinks(path)
if err != nil {
t.Fatal(err)
}
return path
}
func testSignature(t *testing.T, body string) string {
t.Helper()
seed, err := hex.DecodeString(privilegedTestSeed)
@@ -486,6 +482,8 @@ func TestProgramSignedBodyTampering(t *testing.T) {
}
}
*/
// TODO: Re-enable this test when Compile supports inline scripts again.
/*
func TestProgramInlineSignaturesCannotAuthorize(t *testing.T) {
@@ -516,6 +514,8 @@ func TestProgramInlineSignaturesCannotAuthorize(t *testing.T) {
}
*/
// TODO: Re-enable this test when Compile supports privileged signature authorization again.
/*
func TestProgramSignedDiagnostics(t *testing.T) {
setTestPrivilegedPublicKey(t, privilegedTestPublicKey)
const invalidBody = "\n\nlocal = 1"
@@ -543,6 +543,8 @@ func TestProgramSignedDiagnostics(t *testing.T) {
}
}
*/
func TestProgramSandbox(t *testing.T) {
dir := t.TempDir()
if err := os.WriteFile(filepath.Join(dir, "escape.lua"), []byte(`disk_loaded = true; return "escaped"`), 0o600); err != nil {
@@ -1047,6 +1049,8 @@ func TestProgramSandboxClosesFailedInitialization(t *testing.T) {
}
}
// TODO: Re-enable these tests when Compile supports privileged signature authorization again.
/*
func TestProgramPrivilegedLibraries(t *testing.T) {
setTestPrivilegedPublicKey(t, privilegedTestPublicKey)
const body = `assert(require("io") == io and require("os") == os)
@@ -1175,3 +1179,4 @@ func TestProgramPrivilegesAreCompileTimeSnapshot(t *testing.T) {
})
}
}
*/