Issues (15)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/CLI/Command/Geocoder/Reverse.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of the Geotools library.
5
 *
6
 * (c) Antoine Corcy <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace League\Geotools\CLI\Command\Geocoder;
13
14
use Geocoder\Formatter\StringFormatter;
15
use Geocoder\ProviderAggregator;
16
use Http\Discovery\HttpClientDiscovery;
17
use League\Geotools\Batch\Batch;
18
use League\Geotools\Coordinate\Coordinate;
19
use Symfony\Component\Console\Input\InputArgument;
20
use Symfony\Component\Console\Input\InputInterface;
21
use Symfony\Component\Console\Input\InputOption;
22
use Symfony\Component\Console\Output\OutputInterface;
23
24
/**
25
 * Command-line geocoder:reverse class
26
 *
27
 * @author Antoine Corcy <[email protected]>
28
 */
29
class Reverse extends Command
30 2
{
31
    protected function configure()
32
    {
33 2
        $this
34 2
            ->setName('geocoder:reverse')
35 2
            ->setDescription('Reverse geocode street address, IPv4 or IPv6 against a provider with an adapter')
36 2
            ->addArgument('coordinate', InputArgument::REQUIRED, 'The coordinate to reverse')
37 2
            ->addOption('provider', null, InputOption::VALUE_REQUIRED,
38 2
                'If set, the name of the provider to use, Google Maps by default', 'google_maps')
39 2
            ->addOption('cache', null, InputOption::VALUE_REQUIRED,
40 2
                'If set, the name of the cache to use, Redis by default')
41 2
            ->addOption('raw', null, InputOption::VALUE_NONE,
42 2
                'If set, the raw format of the reverse geocoding result')
43 2
            ->addOption('json', null, InputOption::VALUE_NONE,
44 2
                'If set, the json format of the reverse geocoding result')
45 2
            ->addOption('args', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
46 2
                'If set, the provider constructor arguments like api key, locale, region, ssl, toponym and service')
47 2
            ->addOption('format', null, InputOption::VALUE_REQUIRED,
48 2
                'If set, the format of the reverse geocoding result', '%S %n, %z %L')
49 2
            ->setHelp(<<<EOT
50 2
<info>Available providers</info>:  {$this->getProviders()} <comment>(some providers need arguments)</comment>
51 2
<info>Available dumpers</info>:    {$this->getDumpers()}
52 2
53 2
<info>Use the default provider with the socket adapter and format the output</info>:
54
55
    %command.full_name% "48.8631507, 2.388911" <comment>--format="%L, %R, %C" --adapter=socket</comment>
56
57
<info>Use the OpenStreetMaps provider with the default adapter</info>:
58
59
    %command.full_name% "48.8631507, 2.388911" <comment>--provider=openstreetmaps</comment>
60
EOT
61
            );
62
    }
63
64 2
    protected function execute(InputInterface $input, OutputInterface $output)
65
    {
66 1
        $coordinate = new Coordinate($input->getArgument('coordinate'));
67
68 1
        $geocoder = new ProviderAggregator;
69
        $httpClient = HttpClientDiscovery::find();
70
        $provider = $this->getProvider($input->getOption('provider'));
71
72
        if ($input->getOption('args')) {
73
            $args = is_array($input->getOption('args'))
74
                ? implode(',', $input->getOption('args'))
75
                : $input->getOption('args');
76
            $geocoder->registerProvider(new $provider($httpClient, $args));
77
        } else {
78
            $geocoder->registerProvider(new $provider($httpClient));
79
        }
80
81
        $batch = new Batch($geocoder);
82
        if ($input->getOption('cache')) {
83
            $batch->setCache( $this->getCache($input->getOption('cache')));
84
        }
85
86
        $reversed = $batch->reverse($coordinate)->parallel();
87
        $address = $reversed[0]->first();
88
89
        if ($input->getOption('raw')) {
90
            $result = array();
91
            $result[] = sprintf('<label>HttpClient</label>:       <value>%s</value>', get_class($httpClient));
92
            $result[] = sprintf('<label>Provider</label>:      <value>%s</value>', $provider);
93
            $result[] = sprintf('<label>Cache</label>:         <value>%s</value>', isset($cache) ? $cache : 'None');
0 ignored issues
show
The variable $cache seems to never exist, and therefore isset should always return false. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
94
            if ($input->getOption('args')) {
95
                $result[] = sprintf('<label>Arguments</label>:     <value>%s</value>', $args);
96
            }
97
            $result[] = '---';
98
            $coordinates = $address->getCoordinates();
99
            $result[] = sprintf('<label>Latitude</label>:      <value>%s</value>', null !== $coordinates ? $coordinates->getLatitude() : '');
100
            $result[] = sprintf('<label>Longitude</label>:     <value>%s</value>', null !== $coordinates ? $coordinates->getLongitude() : '');
101
            if ($address->getBounds()) {
102
                $bounds = $address->getBounds()->toArray();
103
                $result[] = '<label>Bounds</label>';
104
                $result[] = sprintf(' - <label>South</label>: <value>%s</value>', $bounds['south']);
105
                $result[] = sprintf(' - <label>West</label>:  <value>%s</value>', $bounds['west']);
106
                $result[] = sprintf(' - <label>North</label>: <value>%s</value>', $bounds['north']);
107
                $result[] = sprintf(' - <label>East</label>:  <value>%s</value>', $bounds['east']);
108
            }
109
            $result[] = sprintf('<label>Street Number</label>: <value>%s</value>', $address->getStreetNumber());
110
            $result[] = sprintf('<label>Street Name</label>:   <value>%s</value>', $address->getStreetName());
111
            $result[] = sprintf('<label>Zipcode</label>:       <value>%s</value>', $address->getPostalCode());
112
            $result[] = sprintf('<label>City</label>:          <value>%s</value>', $address->getLocality());
113
            $result[] = sprintf('<label>City District</label>: <value>%s</value>', $address->getSubLocality());
114
            if ( NULL !== $adminLevels = $address->getAdminLevels() ) {
115
                $result[] = '<label>Admin Levels</label>';
116
                foreach ($adminLevels as $adminLevel) {
117
                    $result[] = sprintf(' - <label>%s</label>: <value>%s</value>', $adminLevel->getCode(), $adminLevel->getName());
118
                }
119
            }
120
            $country = $address->getCountry();
121
            $result[] = sprintf('<label>Country</label>:       <value>%s</value>', null !== $country ? $country->getName() : '');
122
            $result[] = sprintf('<label>Country Code</label>:  <value>%s</value>', null !== $country ? $country->getCode() : '');
123
            $result[] = sprintf('<label>Timezone</label>:      <value>%s</value>', $address->getTimezone());
124
        } elseif ($input->getOption('json')) {
125
            $result = sprintf('<value>%s</value>', json_encode($address->toArray()));
126
        } else {
127
            $result = (new StringFormatter)->format($address, $input->getOption('format'));
128
        }
129
130
        $output->writeln($result);
0 ignored issues
show
It seems like $result defined by array() on line 90 can also be of type array<integer,string>; however, Symfony\Component\Consol...putInterface::writeln() does only seem to accept string|object<Symfony\Co...onsole\Output\iterable>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
131
        return 0;
132
    }
133
}
134