-
Notifications
You must be signed in to change notification settings - Fork 187
Unify roadrunner #4262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Unify roadrunner #4262
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
appsec/tests/integration/src/test/www/roadrunner/composer.json
This file was deleted.
Oops, something went wrong.
59 changes: 0 additions & 59 deletions
59
appsec/tests/integration/src/test/www/roadrunner/worker.php
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,12 @@ | ||
| { | ||
| "require": { | ||
| "spiral/roadrunner-http": "^2.1", | ||
| "nyholm/psr7": "^1.5" | ||
| "require": { | ||
| "spiral/roadrunner": "2.12.3", | ||
| "nyholm/psr7": "^1.0" | ||
| }, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "App\\": "src/", | ||
| "Adapters\\": "adapters/" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/Frameworks/Roadrunner/Version_2/src/HomePageHandler.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <?php | ||
|
|
||
| namespace App; | ||
|
|
||
| use Nyholm\Psr7\Response; | ||
| use Psr\Http\Message\ResponseInterface; | ||
| use Psr\Http\Message\ServerRequestInterface; | ||
|
|
||
| class HomePageHandler | ||
| { | ||
| public function handle(ServerRequestInterface $req): ResponseInterface | ||
| { | ||
| $qp = $req->getQueryParams(); | ||
| if (isset($qp['user']) && extension_loaded('ddappsec')) { | ||
| \datadog\appsec\track_user_login_success_event( | ||
| $qp['user'], | ||
| [ | ||
| 'email' => 'jean.example@example.com', | ||
| 'session_id' => '987654321', | ||
| 'role' => 'admin' | ||
| ] | ||
| ); | ||
| } | ||
|
|
||
| $status = 200; | ||
| if (isset($qp['status'])) { | ||
| $status = (int) $qp['status']; | ||
| } | ||
| return new Response( | ||
| $status, | ||
| ['Content-Type' => 'text/plain'], | ||
| "Hello world!" | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?php | ||
|
|
||
| namespace App; | ||
|
|
||
| use Nyholm\Psr7\Response; | ||
| use Psr\Http\Message\ResponseInterface; | ||
| use Psr\Http\Message\ServerRequestInterface; | ||
|
|
||
| class JsonHandler | ||
| { | ||
| public function handle(ServerRequestInterface $req): ResponseInterface | ||
| { | ||
| $qp = $req->getQueryParams(); | ||
| if (isset($qp['block'])) { | ||
| $poison = 'block_this'; | ||
| } else { | ||
| $poison = 'poison'; | ||
| } | ||
| return new Response( | ||
| 200, | ||
| ['Content-Type' => 'application/json'], | ||
| json_encode(['message' => ['Hello world!', 42, true, $poison]]) | ||
| ); | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
tests/Frameworks/Roadrunner/Version_2/src/PhpInfoHandler.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
|
|
||
| namespace App; | ||
|
|
||
| use Nyholm\Psr7\Response; | ||
| use Psr\Http\Message\ResponseInterface; | ||
| use Psr\Http\Message\ServerRequestInterface; | ||
|
|
||
| class PhpInfoHandler | ||
| { | ||
| public function handle(ServerRequestInterface $request): ResponseInterface | ||
| { | ||
| \ob_start(); | ||
| phpinfo(); | ||
| $phpinfo = \ob_get_clean(); | ||
|
|
||
| return new Response( | ||
| 200, | ||
| ['Content-Type' => 'text/html'], | ||
| $phpinfo | ||
| ); | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
tests/Frameworks/Roadrunner/Version_2/src/PostRespondRaspHandler.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <?php | ||
|
|
||
| namespace App; | ||
|
|
||
| use Nyholm\Psr7\Response; | ||
| use Psr\Http\Message\ResponseInterface; | ||
| use Psr\Http\Message\ServerRequestInterface; | ||
|
|
||
| class PostRespondRaspHandler | ||
| { | ||
| public function handle(ServerRequestInterface $req): ResponseInterface | ||
| { | ||
| // Schedule RASP instrumentation to run after respond() returns, which is | ||
| // after ddappsec's request_shutdown has been sent. The evaluations cannot | ||
| // happen at that point, so each must be accounted for under RFC-1012's | ||
| // appsec.rasp.rule.skipped instead. | ||
| // | ||
| // The first call carries no rule variant, the second one does, so the test | ||
| // can check that rule_variant is only tagged when present. | ||
| // The ssrf address is a closed local port: the RASP push happens in a pre-hook, | ||
| // before any I/O, so no reachable host is needed and this fails instantly rather | ||
| // than stalling the worker between requests for the connect timeout. | ||
| $GLOBALS['_rr_post_respond'] = static function () { | ||
| @fopen('../etc/passwd', 'r'); | ||
| @fopen('http://127.0.0.1:1/', 'r'); | ||
| }; | ||
| return new Response(200, ['Content-Type' => 'text/plain'], 'OK'); | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
tests/Frameworks/Roadrunner/Version_2/src/PostRespondTrackUserHandler.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
|
|
||
| namespace App; | ||
|
|
||
| use Nyholm\Psr7\Response; | ||
| use Psr\Http\Message\ResponseInterface; | ||
| use Psr\Http\Message\ServerRequestInterface; | ||
|
|
||
| class PostRespondTrackUserHandler | ||
| { | ||
| public function handle(ServerRequestInterface $req): ResponseInterface | ||
| { | ||
| // Schedule track_user_login_success() to run after respond() returns. | ||
| // worker.php consumes this callback after respond(), which is after | ||
| // ddappsec's request_shutdown has been sent. track_user_login_success | ||
| // is another RequestExec sender, so if it still reaches the helper | ||
| // (socket open, active=true) it sends RequestExec into the outer loop. | ||
| $GLOBALS['_rr_post_respond'] = static function () { | ||
| \datadog\appsec\v2\track_user_login_success('test-user', true); | ||
| }; | ||
| return new Response(200, ['Content-Type' => 'text/plain'], 'OK'); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?php | ||
|
|
||
| namespace App; | ||
|
|
||
| class Router { | ||
| private array $routes = []; | ||
|
|
||
| public function addRoute($path, $handler): void | ||
| { | ||
| $this->routes[$path] = $handler; | ||
| } | ||
|
|
||
| public function getHandler($path) { | ||
| return $this->routes[$path] ?? null; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?php | ||
|
|
||
| namespace App; | ||
|
|
||
| use Nyholm\Psr7\Response; | ||
| use Psr\Http\Message\ResponseInterface; | ||
| use Psr\Http\Message\ServerRequestInterface; | ||
|
|
||
| class XmlHandler | ||
| { | ||
| public function handle(ServerRequestInterface $request): ResponseInterface | ||
| { | ||
| $c = <<<XML | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <note foo="bar"> | ||
| <from>Jean</from> | ||
| poison | ||
| </note> | ||
| XML; | ||
|
|
||
| return new Response( | ||
| 200, | ||
| ['Content-Type' => 'application/xml'], | ||
| $c | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.