Issues (31)

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/Fields/GeopointField.php (1 issue)

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
namespace frictionlessdata\tableschema\Fields;
4
5
class GeopointField extends BaseField
6
{
7
    protected function validateCastValue($val)
8
    {
9
        if (in_array($this->format(), ['array', 'object']) && is_string($val)) {
10
            try {
11
                $val = json_decode($val);
12
            } catch (\Exception $e) {
13
                throw $this->getValidationException($e->getMessage(), $val);
14
            }
15
        }
16
        switch ($this->format()) {
17
            case 'default':
18
                if (!is_string($val)) {
19
                    throw $this->getValidationException('value must be a string', $val);
20
                } else {
21
                    $val = explode(',', $val);
22
                    if (count($val) != 2) {
23
                        throw $this->getValidationException('value must be a string with 2 comma-separated elements', $val);
24
                    } else {
25
                        return $this->getNativeGeopoint($val);
26
                    }
27
                }
28
            case 'array':
29
                if (!is_array($val) || array_keys($val) != [0, 1]) {
30
                    throw $this->getValidationException('value must be an array with 2 elements', $val);
31
                } else {
32
                    return $this->getNativeGeopoint($val);
33
                }
34
            case 'object':
35
                $val = json_decode(json_encode($val), true);
36
                if (!is_array($val) || !array_key_exists('lat', $val) || !array_key_exists('lon', $val)) {
37
                    throw $this->getValidationException('object must contain lon and lat attributes', $val);
38
                } else {
39
                    return $this->getNativeGeopoint([$val['lon'], $val['lat']]);
40
                }
41
            default:
42
                throw $this->getValidationException('invalid format', $val);
43
        }
44
    }
45
46
    public static function type()
47
    {
48
        return 'geopoint';
49
    }
50
51
    protected function getNativeGeopoint($arr)
52
    {
53
        list($lon, $lat) = $arr;
54
        $lon = (int) $lon;
55
        $lat = (int) $lat;
56
        if (
57
            $lon > 180 || $lon < -180
58
            || $lat > 90 or $lat < -90
0 ignored issues
show
Comprehensibility Best Practice introduced by
Using logical operators such as or instead of || is generally not recommended.

PHP has two types of connecting operators (logical operators, and boolean operators):

  Logical Operators Boolean Operator
AND - meaning and &&
OR - meaning or ||

The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like &&, or ||.

Let’s take a look at a few examples:

// Logical operators have lower precedence:
$f = false or true;

// is executed like this:
($f = false) or true;


// Boolean operators have higher precedence:
$f = false || true;

// is executed like this:
$f = (false || true);

Logical Operators are used for Control-Flow

One case where you explicitly want to use logical operators is for control-flow such as this:

$x === 5
    or die('$x must be 5.');

// Instead of
if ($x !== 5) {
    die('$x must be 5.');
}

Since die introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined with throw at this point:

// The following is currently a parse error.
$x === 5
    or throw new RuntimeException('$x must be 5.');

These limitations lead to logical operators rarely being of use in current PHP code.

Loading history...
59
        ) {
60
            throw $this->getValidationException('invalid lon,lat values', json_encode($arr));
61
        } else {
62
            return [$lon, $lat];
63
        }
64
    }
65
}
66