GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

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/GeoTimeZone/Calculator.php (4 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
namespace GeoTimeZone;
4
5
use DateTime;
6
use DateTimeZone;
7
use ErrorException;
8
use GeoTimeZone\Quadrant\Tree;
9
10
class Calculator
11
{
12
    protected $quadrantTree;
13
    
14
    /**
15
     * TimeZone constructor.
16
     * @param $dataDirectory
17
     * @throws ErrorException
18
     */
19 25
    public function __construct($dataDirectory = null)
20
    {
21 25
        if (isset($dataDirectory) && is_dir($dataDirectory)) {
22 25
            $this->quadrantTree = new Tree($dataDirectory);
23 25
            $this->quadrantTree->initializeDataTree();
24
        }else{
25
            throw new ErrorException('Invalid data tree directory: ' . $dataDirectory);
26
        }
27 25
    }
28
    
29
    /**
30
     * Adjust the latitude value
31
     * @param $latitude
32
     * @return float|int
33
     * @throws ErrorException
34
     */
35 23
    protected function adjustLatitude($latitude)
36
    {
37 23
        $newLatitude = $latitude;
38 23
        if (null == $latitude || abs($latitude) > Tree::MAX_ABS_LATITUDE) {
39 2
            throw new ErrorException('Invalid latitude: ' . $latitude);
40
        }
41 21
        if (abs($latitude) == Tree::MAX_ABS_LATITUDE) {
42 4
            $newLatitude = ($latitude <=> 0) * Tree::ABS_LATITUDE_LIMIT;
43
        }
44 21
        return $newLatitude;
45
    }
46
    
47
    /**
48
     * Adjust longitude value
49
     * @param $longitude
50
     * @return float|int
51
     * @throws ErrorException
52
     */
53 21
    protected function adjustLongitude($longitude)
54
    {
55 21
        $newLongitude = $longitude;
56 21
        if (null == $longitude || abs($longitude) > Tree::MAX_ABS_LONGITUDE) {
57 2
            throw new ErrorException('Invalid longitude: ' . $longitude);
58
        }
59 19
        if (abs($longitude) == Tree::MAX_ABS_LONGITUDE) {
60 4
            $newLongitude = ($longitude <=> 0) * Tree::ABS_LONGITUDE_LIMIT;
61
        }
62 19
        return $newLongitude;
63
    }
64
    
65
    /**
66
     * Get timezone name from a particular location (latitude, longitude)
67
     * @param $latitude
68
     * @param $longitude
69
     * @return string
70
     * @throws ErrorException
71
     */
72 21
    public function getTimeZoneName($latitude, $longitude)
73
    {
74 21
        $timeZone = Tree::NONE_TIMEZONE;
75
        try {
76 21
            $latitude = $this->adjustLatitude($latitude);
77 19
            $longitude = $this->adjustLongitude($longitude);
78 17
            $timeZone = $this->quadrantTree->lookForTimezone($latitude, $longitude);
79 11
        }catch (ErrorException $error){
0 ignored issues
show
The class ErrorException does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
80 11
            throw $error;
81
        }
82 10
        return $timeZone;
83
    }
84
    
85
    /**
86
     * Get the local date belonging to a particular latitude, longitude and timestamp
87
     * @param $latitude
88
     * @param $longitude
89
     * @param $timestamp
90
     * @return DateTime
91
     * @throws ErrorException
92
     */
93 7
    public function getLocalDate($latitude, $longitude, $timestamp)
94
    {
95 7
        $date = new DateTime();
96
        try {
97 7
            $timeZone = $this->getTimeZoneName($latitude, $longitude);
98 6
            $date->setTimestamp($timestamp);
99 6
            if ($timeZone != Tree::NONE_TIMEZONE) {
100 6
                $date->setTimezone(new DateTimeZone($timeZone));
101
            }
102 1
        }catch (ErrorException $error){
0 ignored issues
show
The class ErrorException does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
103 1
            throw $error;
104
        }
105 6
        return $date;
106
    }
107
    
108
    /**
109
     * Get timestamp from latitude, longitude and localTimestamp
110
     * @param $latitude
111
     * @param $longitude
112
     * @param $localTimestamp
113
     * @return mixed
114
     * @throws ErrorException
115
     */
116 3
    public function getCorrectTimestamp($latitude, $longitude, $localTimestamp)
117
    {
118 3
        $timestamp = $localTimestamp;
119
        try {
120 3
            $timeZoneName = $this->getTimeZoneName($latitude, $longitude);
121 2
            if ($timeZoneName != Tree::NONE_TIMEZONE) {
122 2
                $date = new DateTime();
123 2
                $date->setTimestamp($localTimestamp);
124 2
                if ($timeZoneName != null) {
125 2
                    $date->setTimezone(new DateTimeZone($timeZoneName));
126
                }
127 2
                $timestamp = $date->getOffset() != false ? $localTimestamp - $date->getOffset() : $localTimestamp;
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing $date->getOffset() of type integer to the boolean false. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
128
            }
129 1
        }catch(ErrorException $error){
0 ignored issues
show
The class ErrorException does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
130 1
            throw $error;
131
        }
132 2
        return $timestamp;
133
    }
134
}
135
136