Skip to content

Commit 9fd1942

Browse files
author
Greg Bowler
committed
feature: protected global variables
closes #483
1 parent 24be75e commit 9fd1942

File tree

3 files changed

+89
-36
lines changed

3 files changed

+89
-36
lines changed

composer.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@
1414
"ext-json": "*",
1515
"php": ">=8.1",
1616

17-
"phpgt/config": "^1.0",
17+
"phpgt/config": "^v1.0",
1818
"phpgt/dom": "^v4.0",
1919
"phpgt/domtemplate": "^v3.1",
20-
"phpgt/database": "^1.4",
21-
"phpgt/http": "^1.1",
22-
"phpgt/logger": "^1.0",
23-
"phpgt/routing": "^1.0",
24-
"phpgt/servicecontainer": "^1.1",
25-
"phpgt/session": "^1.1",
26-
"phpgt/sync": "^1.2",
20+
"phpgt/database": "^v1.4",
21+
"phpgt/http": "^v1.1",
22+
"phpgt/logger": "^v1.0",
23+
"phpgt/protectedglobal": "^v1.0",
24+
"phpgt/routing": "^v1.0",
25+
"phpgt/servicecontainer": "^v1.1",
26+
"phpgt/session": "^v1.1",
27+
"phpgt/sync": "^v1.2",
2728
"phpgt/ulid": "^v1.0.0",
2829

2930
"psr/http-server-middleware": "^1.0",

composer.lock

Lines changed: 65 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Middleware/RequestHandler.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Gt\Logger\LogHandler\FileHandler;
2020
use Gt\Logger\LogHandler\StdOutHandler;
2121
use Gt\Logger\LogHandler\StreamHandler;
22+
use Gt\ProtectedGlobal\Protection;
2223
use Gt\Routing\BaseRouter;
2324
use Gt\Routing\LogicStream\LogicStreamWrapper;
2425
use Gt\Routing\Path\DynamicPath;
@@ -209,10 +210,23 @@ public function handle(
209210
// $protector->protectAndInject();
210211
}
211212

212-
// TODO: Kill globals.
213213
$input = new Input($_GET, $_POST, $_FILES);
214214
$serviceContainer->set($input);
215215

216+
Protection::removeGlobals($GLOBALS, [
217+
"_GET" => ["xdebug"],
218+
]);
219+
Protection::overrideInternals(
220+
$GLOBALS,
221+
$_ENV,
222+
$_SERVER,
223+
$_GET,
224+
$_POST,
225+
$_FILES,
226+
$_COOKIE,
227+
$_SESSION,
228+
);
229+
216230
$injector = new Injector($serviceContainer);
217231

218232
$logicExecutor = new LogicExecutor(

0 commit comments

Comments
 (0)