feat: import Sea vHost single-server testing release

This commit is contained in:
canglan committed 2026-10-30 08:39:10 +08:00
commit 248badd33e
441 files changed
+63221

No files matched your search

@@ -0,0 +1,48 @@
package isolation
import (
"os"
"path/filepath"
"testing"
)
func TestPHPMyAdminCopyReadableWithPrivateAgentUmask(t *testing.T) {
app := t.TempDir()
os.Mkdir(filepath.Join(app, "libraries"), 0700)
file := filepath.Join(app, "libraries", "config.default.php")
os.WriteFile(file, []byte("<?php"), 0600)
if e := securePMAReadPermissions(app); e != nil {
t.Fatal(e)
}
i, e := os.Stat(file)
if e != nil || i.Mode().Perm()&0044 != 0044 {
t.Fatal("unprivileged PHP cannot read copied vendor files")
}
i, _ = os.Stat(filepath.Join(app, "libraries"))
if i.Mode().Perm()&0011 != 0011 {
t.Fatal("vendor directories cannot be traversed")
}
}
func TestPHPMyAdminRouteAllowlist(t *testing.T) {
for _, name := range []string{"", "index.php", "url.php", "js/messages.php", "themes/pmahomme/css/theme.css", "js/vendor/jquery/jquery.min.js", "favicon.ico"} {
if !validPMAPath(name) {
t.Fatalf("valid asset denied %s", name)
}
}
for _, name := range []string{"config.inc.php", "sea-signon.php", "setup/index.php", "examples/signon.php", "../config.inc.php", "vendor/autoload.php", "themes/x.php", "/index.php", "js/../../secret"} {
if validPMAPath(name) {
t.Fatalf("unsafe route allowed %s", name)
}
}
}
func TestScheduleVersionCannotTraverseSDKRoot(t *testing.T) {
for _, v := range []string{"..", "../x", "1.2.3;id", "v1.2.3/../../"} {
if validScheduleVersion("node", v) {
t.Fatalf("accepted %s", v)
}
}
if !validScheduleVersion("php", "8.4") || !validScheduleVersion("python", "3.13.9") || !validScheduleVersion("node", "v24.11.0") {
t.Fatal("valid SDK version rejected")
}
}