|
| 1 | +<?php |
| 2 | + |
| 3 | +require_once __DIR__ . "/../vendor/autoload.php"; |
| 4 | + |
| 5 | +require_once __DIR__ . "/../resources/lib/UnityLDAP.php"; |
| 6 | +require_once __DIR__ . "/../resources/lib/UnityUser.php"; |
| 7 | +require_once __DIR__ . "/../resources/lib/UnityGroup.php"; |
| 8 | +require_once __DIR__ . "/../resources/lib/UnityOrg.php"; |
| 9 | +require_once __DIR__ . "/../resources/lib/UnitySQL.php"; |
| 10 | +require_once __DIR__ . "/../resources/lib/UnityMailer.php"; |
| 11 | +require_once __DIR__ . "/../resources/lib/UnitySSO.php"; |
| 12 | +require_once __DIR__ . "/../resources/lib/UnitySite.php"; |
| 13 | +require_once __DIR__ . "/../resources/lib/UnityConfig.php"; |
| 14 | +require_once __DIR__ . "/../resources/lib/UnityWebhook.php"; |
| 15 | +require_once __DIR__ . "/../resources/lib/UnityRedis.php"; |
| 16 | + |
| 17 | +global $HTTP_HEADER_TEST_INPUTS; |
| 18 | +$HTTP_HEADER_TEST_INPUTS = [ |
| 19 | + '', |
| 20 | + 'a', |
| 21 | + 'Hello, World!', |
| 22 | + ' Some text ', |
| 23 | + ' ', |
| 24 | + '12345', |
| 25 | + 'abc123', |
| 26 | + 'Hello@World!', |
| 27 | + str_repeat('a', 8190), // https://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfieldsize |
| 28 | + '<p>This is a paragraph</p>', |
| 29 | + "'; DROP TABLE users; --", |
| 30 | + "<script>alert('XSS');</script>", |
| 31 | + 'こんにちは世界', |
| 32 | + "Hello 👋 World 🌍", |
| 33 | + "Line 1\nLine 2", |
| 34 | + "Column1\tColumn2", |
| 35 | + 'MiXeD cAsE', |
| 36 | + 'https://www.example.com', |
| 37 | + |
| 38 | + '{"key": "value"}', |
| 39 | + 'SGVsbG8sIFdvcmxkIQ==', |
| 40 | + "Hello\x00World", |
| 41 | + mb_convert_encoding("Hello, World!", "UTF-16") |
| 42 | +]; |
| 43 | + |
| 44 | +function switchUser(string $eppn, string $given_name, string $sn, string $mail): void |
| 45 | +{ |
| 46 | + global $CONFIG, $REDIS, $LDAP, $SQL, $MAILER, $WEBHOOK, $SITE, $SSO, $OPERATOR, $USER, $SEND_PIMESG_TO_ADMINS, $LOC_HEADER, $LOC_FOOTER; |
| 47 | + session_write_close(); |
| 48 | + session_id(str_replace(["_", "@", "."], "-", $eppn)); |
| 49 | + // session_start will be called on the first post() |
| 50 | + $_SERVER["REMOTE_USER"] = $eppn; |
| 51 | + $_SERVER["REMOTE_ADDR"] = "127.0.0.1"; |
| 52 | + $_SERVER["eppn"] = $eppn; |
| 53 | + $_SERVER["givenName"] = $given_name; |
| 54 | + $_SERVER["sn"] = $sn; |
| 55 | + include __DIR__ . "/../resources/autoload.php"; |
| 56 | + assert(!is_null($USER)); |
| 57 | +} |
| 58 | + |
| 59 | +function post(string $phpfile, array $post_data): void |
| 60 | +{ |
| 61 | + global $CONFIG, $REDIS, $LDAP, $SQL, $MAILER, $WEBHOOK, $SITE, $SSO, $OPERATOR, $USER, $SEND_PIMESG_TO_ADMINS, $LOC_HEADER, $LOC_FOOTER; |
| 62 | + $_SERVER["REQUEST_METHOD"] = "POST"; |
| 63 | + $_POST = $post_data; |
| 64 | + ob_start(); |
| 65 | + try { |
| 66 | + include $phpfile; |
| 67 | + ob_get_clean(); // discard output |
| 68 | + } catch (Throwable $e) { |
| 69 | + error_log(ob_get_clean()); // don't discard output |
| 70 | + throw $e; |
| 71 | + } finally { |
| 72 | + unset($_POST); |
| 73 | + unset($_SERVER["REQUEST_METHOD"]); |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +function getNormalUser() |
| 78 | +{ |
| 79 | + |
| 80 | +} |
| 81 | + |
| 82 | +function getUserHasNotRequestedAccountDeletionHasGroup() |
| 83 | +{ |
| 84 | + |
| 85 | +} |
| 86 | + |
| 87 | +function getUserHasNotRequestedAccountDeletionHasNoGroups() |
| 88 | +{ |
| 89 | + |
| 90 | +} |
0 commit comments