@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3/**
4 * Noncritical PHP configuration checks.
5 *
6 * For critical checks, see @{class:PhabricatorPHPPreflightSetupCheck}.
7 */
8final class PhabricatorPHPConfigSetupCheck extends PhabricatorSetupCheck {
9
10 public function getDefaultGroup() {
11 return self::GROUP_PHP;
12 }
13
14 protected function executeChecks() {
15
16 if (empty($_SERVER['REMOTE_ADDR'])) {
17 $doc_href = PhabricatorEnv::getDoclink('Configuring a Preamble Script');
18
19 $summary = pht(
20 'You likely need to fix your preamble script so '.
21 'REMOTE_ADDR is no longer empty.');
22
23 $message = pht(
24 'No REMOTE_ADDR is available, so this server cannot determine the '.
25 'origin address for requests. This will prevent the software from '.
26 'performing important security checks. This most often means you '.
27 'have a mistake in your preamble script. Consult the documentation '.
28 '(%s) and double-check that the script is written correctly.',
29 phutil_tag(
30 'a',
31 array(
32 'href' => $doc_href,
33 'target' => '_blank',
34 ),
35 pht('Configuring a Preamble Script')));
36
37 $this->newIssue('php.remote_addr')
38 ->setName(pht('No REMOTE_ADDR available'))
39 ->setSummary($summary)
40 ->setMessage($message);
41 }
42
43 if (ini_get('mysqli.allow_local_infile')) {
44 $summary = pht(
45 'Disable unsafe option "%s" in PHP configuration.',
46 'mysqli.allow_local_infile');
47
48 $message = pht(
49 'PHP is currently configured to honor requests from any MySQL server '.
50 'it connects to for the content of any local file.'.
51 "\n\n".
52 'This capability supports MySQL "LOAD DATA LOCAL INFILE" queries, but '.
53 'allows a malicious MySQL server read access to the local disk: the '.
54 'server can ask the client to send the content of any local file, '.
55 'and the client will comply.'.
56 "\n\n".
57 'Although it is normally difficult for an attacker to convince '.
58 'this software to connect to a malicious MySQL server, you should '.
59 'disable this option: this capability is unnecessary and inherently '.
60 'dangerous.'.
61 "\n\n".
62 'To disable this option, set: %s',
63 phutil_tag(
64 'tt',
65 array(),
66 pht('%s = 0', 'mysqli.allow_local_infile')));
67
68 $this->newIssue('php.mysqli.allow_local_infile')
69 ->setName(pht('Unsafe PHP "Local Infile" Configuration'))
70 ->setSummary($summary)
71 ->setMessage($message)
72 ->addPHPConfig('mysqli.allow_local_infile');
73 }
74
75 }
76
77}