Issues (843)

Security Analysis    not enabled

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.

require/libs/geoPHP/lib/adapters/GeoJSON.class.php (1 issue)

Labels
Severity

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
 * GeoJSON class : a geojson reader/writer.
4
 *
5
 * Note that it will always return a GeoJSON geometry. This
6
 * means that if you pass it a feature, it will return the
7
 * geometry of that feature strip everything else.
8
 */
9
class GeoJSON extends GeoAdapter
10
{
11
  /**
12
   * Given an object or a string, return a Geometry
13
   *
14
   * @param mixed $input The GeoJSON string or object
15
   *
16
   * @return object Geometry
17
   */
18
  public function read($input) {
19
    if (is_string($input)) {
20
      $input = json_decode($input);
21
    }
22
    if (!is_object($input)) {
23
      throw new Exception('Invalid JSON');
24
    }
25
    if (!is_string($input->type)) {
26
      throw new Exception('Invalid JSON');
27
    }
28
29
    // Check to see if it's a FeatureCollection
30
    if ($input->type == 'FeatureCollection') {
31
      $geoms = array();
32
      foreach ($input->features as $feature) {
33
        $geoms[] = $this->read($feature);
34
      }
35
      return geoPHP::geometryReduce($geoms);
36
    }
37
38
    // Check to see if it's a Feature
39
    if ($input->type == 'Feature') {
40
      return $this->read($input->geometry);
41
    }
42
43
    // It's a geometry - process it
44
    return $this->objToGeom($input);
45
  }
46
47
  private function objToGeom($obj) {
48
    $type = $obj->type;
49
50
    if ($type == 'GeometryCollection') {
51
      return $this->objToGeometryCollection($obj);
52
    }
53
    $method = 'arrayTo' . $type;
54
    return $this->$method($obj->coordinates);
55
  }
56
57
  private function arrayToPoint($array) {
58
    return new Point($array[0], $array[1]);
59
  }
60
61
  private function arrayToLineString($array) {
62
    $points = array();
63
    foreach ($array as $comp_array) {
64
      $points[] = $this->arrayToPoint($comp_array);
65
    }
66
    return new LineString($points);
67
  }
68
69
  private function arrayToPolygon($array) {
70
    $lines = array();
71
    foreach ($array as $comp_array) {
72
      $lines[] = $this->arrayToLineString($comp_array);
73
    }
74
    return new Polygon($lines);
75
  }
76
77
  private function arrayToMultiPoint($array) {
78
    $points = array();
79
    foreach ($array as $comp_array) {
80
      $points[] = $this->arrayToPoint($comp_array);
81
    }
82
    return new MultiPoint($points);
83
  }
84
85
  private function arrayToMultiLineString($array) {
86
    $lines = array();
87
    foreach ($array as $comp_array) {
88
      $lines[] = $this->arrayToLineString($comp_array);
89
    }
90
    return new MultiLineString($lines);
91
  }
92
93
  private function arrayToMultiPolygon($array) {
94
    $polys = array();
95
    foreach ($array as $comp_array) {
96
      $polys[] = $this->arrayToPolygon($comp_array);
97
    }
98
    return new MultiPolygon($polys);
99
  }
100
101
  private function objToGeometryCollection($obj) {
102
    $geoms = array();
103
    if (empty($obj->geometries)) {
104
      throw new Exception('Invalid GeoJSON: GeometryCollection with no component geometries');
105
    }
106
    foreach ($obj->geometries as $comp_object) {
107
      $geoms[] = $this->objToGeom($comp_object);
108
    }
109
    return new GeometryCollection($geoms);
110
  }
111
112
  /**
113
   * Serializes an object into a geojson string
114
   *
115
   *
116
   * @param Geometry $obj The object to serialize
0 ignored issues
show
There is no parameter named $obj. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
117
   *
118
   * @return string The GeoJSON string
119
   */
120
  public function write(Geometry $geometry, $return_array = FALSE) {
121
    if ($return_array) {
122
      return $this->getArray($geometry);
123
    }
124
    else {
125
      return json_encode($this->getArray($geometry));
126
    }
127
  }
128
129
  public function getArray($geometry) {
130
    if ($geometry->getGeomType() == 'GeometryCollection') {
131
      $component_array = array();
132
      foreach ($geometry->components as $component) {
133
        $component_array[] = array(
134
          'type' => $component->geometryType(),
135
          'coordinates' => $component->asArray(),
136
        );
137
      }
138
      return array(
139
        'type'=> 'GeometryCollection',
140
        'geometries'=> $component_array,
141
      );
142
    }
143
    else return array(
144
      'type'=> $geometry->getGeomType(),
145
      'coordinates'=> $geometry->asArray(),
146
    );
147
  }
148
}
149
150
151