mirror of
https://github.com/php/frankenphp.git
synced 2026-03-24 00:52:11 +01:00
perf: move sandboxed environment to the C side (#2058)
This PR uses `zend_array_dup` to simplify and optimize the environment sandboxing logic. It also guarantees no environment leakage on FrankenPHP restarts.
This commit is contained in:
committed by
GitHub
parent
25ed020036
commit
8f4412cbbf
@@ -61,6 +61,16 @@ func escapeMetricLabel(s string) string {
|
||||
return strings.ReplaceAll(s, "\\", "\\\\")
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
// setup custom environment vars for TestOsEnv
|
||||
if os.Setenv("ENV1", "value1") != nil || os.Setenv("ENV2", "value2") != nil {
|
||||
fmt.Println("Failed to set environment variables for tests")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
func TestPHP(t *testing.T) {
|
||||
var wg sync.WaitGroup
|
||||
tester := caddytest.NewTester(t)
|
||||
@@ -957,9 +967,6 @@ func testSingleIniConfiguration(tester *caddytest.Tester, key string, value stri
|
||||
}
|
||||
|
||||
func TestOsEnv(t *testing.T) {
|
||||
require.NoError(t, os.Setenv("ENV1", "value1"))
|
||||
require.NoError(t, os.Setenv("ENV2", "value2"))
|
||||
|
||||
tester := caddytest.NewTester(t)
|
||||
tester.InitServer(`
|
||||
{
|
||||
|
||||
@@ -5,13 +5,13 @@ package caddy
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
"github.com/caddyserver/caddy/v2"
|
||||
"github.com/caddyserver/caddy/v2/caddyconfig"
|
||||
"github.com/caddyserver/caddy/v2/modules/caddyhttp"
|
||||
"github.com/dunglas/frankenphp"
|
||||
"github.com/dunglas/mercure"
|
||||
mercureCaddy "github.com/dunglas/mercure/caddy"
|
||||
"os"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -67,5 +67,5 @@ func createMercureRoute() (caddyhttp.Route, error) {
|
||||
},
|
||||
}
|
||||
|
||||
return mercureRoute, nil;
|
||||
return mercureRoute, nil
|
||||
}
|
||||
|
||||
@@ -253,8 +253,8 @@ func cmdPHPServer(fs caddycmd.Flags) (int, error) {
|
||||
if mercure {
|
||||
mercureRoute, err := createMercureRoute()
|
||||
if err != nil {
|
||||
return caddy.ExitCodeFailedStartup, err
|
||||
}
|
||||
return caddy.ExitCodeFailedStartup, err
|
||||
}
|
||||
|
||||
subroute.Routes = append(caddyhttp.RouteList{mercureRoute}, subroute.Routes...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user