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 (9)

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/LarsignService.php (3 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
namespace HavenShen\Larsign;
3
4
use HavenShen\Larsign\LarsignException;
5
6
/**
7
 * LarsignService
8
 *
9
 * @author    Haven Shen <[email protected]>
10
 * @copyright    Copyright (c) Haven Shen
11
 */
12
final class LarsignService
13
{
14
    private $options;
15
16 2
    public function __construct(array $options = array())
17
    {
18 2
        $this->options = $this->normalizeOptions($options);
19 2
    }
20
21 2
    private function normalizeOptions(array $options = array())
22
    {
23
        $options += array(
24 2
            'headerName' => 'Larsign',
25
            'accessKey' => 'larsignaccesskey',
26
            'secretKey' => 'larsignsecretkey',
27
        );
28
29 2
        return $options;
30
    }
31
32
    /**
33
     * Get header name
34
     *
35
     * @return string
36
     */
37 2
    public function getHeaderName()
38
    {
39 2
        return $this->options['headerName'];
40
    }
41
42
    /**
43
     * Get access key
44
     *
45
     * @return string
46
     */
47
    public function getAccessKey()
48
    {
49
        return $this->options['accessKey'];
50
    }
51
52
    /**
53
     * Signature
54
     *
55
     * @param string $data
56
     * @return string
57
     */
58 2
    public function sign($data)
59
    {
60 2
        $hmac = hash_hmac('sha1', $data, $this->options['secretKey'], true);
61 2
        return $this->options['accessKey'] . ':' . $this->base64_urlSafeEncode($hmac);
62
    }
63
64
    /**
65
     * Signature with data
66
     *
67
     * @param string $data
68
     * @return string
69
     */
70 2
    public function signWithData($data)
71
    {
72 2
        $encodedData = $this->base64_urlSafeEncode($data);
73 2
        return $this->sign($encodedData) . ':' . $encodedData;
74
    }
75
76
    /**
77
     * Signature request
78
     *
79
     * @param string $urlString
80
     * @param string $body
81
     * @param string $contentType
82
     * @param int $deadline
83
     * @return string
84
     */
85 2
    public function signRequest($urlString, $body, $contentType = null, $deadline = 0)
86
    {
87 2
        $url = parse_url($urlString);
88
89 2
        $data = '';
90 2
        if (array_key_exists('path', $url)) {
91 2
            $data = $url['path'];
92
        }
93 2
        if (array_key_exists('query', $url)) {
94
            $data .= '?' . $url['query'];
95
        }
96 2
        $data .= "\n";
97
98 2
        if ($body !== null && $contentType === 'application/x-www-form-urlencoded') {
99
            $data .= $body;
100
        }
101
102 2
        $data .= $deadline;
103
104 2
        return $this->signWithData($data);
105
    }
106
107
    /**
108
     * Split authorization signature
109
     *
110
     * @param string $authorization
111
     * @return list
112
     */
113 2
    public function splitAuthorizationLarsign($authorizationLarsign)
114
    {
115 2
        $authorizationLarsignArr = explode(':', $authorizationLarsign);
116
117 2
        $accessKey = isset($authorizationLarsignArr[0]) ? $authorizationLarsignArr[0] : '';
118 2
        $hmacSha1Str = isset($authorizationLarsignArr[1]) ? $authorizationLarsignArr[1] : '';
119 2
        $encodedStr = isset($authorizationLarsignArr[2]) ? $authorizationLarsignArr[2] : '';
120
121 2
        $url = '';
122 2
        $body = '';
123 2
        $deadline = 0;
124
125 2
        if (! empty($encodedStr)) {
126 2
            $encodedStrArr = preg_split('/[;\r\n]+/s', $this->base64_urlSafeDecode($encodedStr));
127
128 2
            $url = isset($encodedStrArr[0]) ? $encodedStrArr[0] : '';
129 2
            $deadline = isset($encodedStrArr[1]) ? (int)$encodedStrArr[1] : 0;
130
        }
131
132
        return [
133 2
            $accessKey,
134 2
            $hmacSha1Str,
135 2
            $encodedStr,
136 2
            $url,
137 2
            $body,
138 2
            $deadline
139
        ];
140
    }
141
142
    /**
143
     * Check auth signature
144
     *
145
     * @param \Illuminate\Http\Request  $request
146
     * @return bool
147
     */
148 2
    public function check($request)
149
    {
150 2
        $contentType = $request->header('content-type');
151
152 2
        $authorizationLarsign = $request->header($this->options['headerName']);
153
154
        list(
155
            $accessKey,
0 ignored issues
show
The assignment to $accessKey is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
156
            $hmacSha1Str,
0 ignored issues
show
The assignment to $hmacSha1Str is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
157
            $encodedStrArr,
0 ignored issues
show
The assignment to $encodedStrArr is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
158
            $url,
159
            $body,
160
            $deadline
161 2
        ) = $this->splitAuthorizationLarsign($authorizationLarsign);
162
163 2
        if (time() > $deadline) {
164
            return false;
165
        }
166
167 2
        if (! $this->verifyCallback($contentType, $authorizationLarsign, $url, $body, $deadline)) {
168
            return false;
169
        }
170
171 2
        return true;
172
173
    }
174
175
    /**
176
     * Verify callback
177
     *
178
     * @param string $contentType
179
     * @param string $authorizationLarsign
180
     * @param string $url
181
     * @param string $body
182
     * @param int $bodeadlinedy
183
     * @return bool
184
     */
185 2
    public function verifyCallback($contentType, $authorizationLarsign, $url, $body, $deadline)
186
    {
187 2
        $authorizationLarsignRs = $this->options['headerName'] .' '. $this->signRequest($url, $body, $contentType, $deadline);
188
189 2
        return $authorizationLarsign === $authorizationLarsignRs;
190
    }
191
192
    /**
193
     * Urlsafe base64 encode
194
     *
195
     * @param string $data
196
     *
197
     * @return string
198
     */
199 2
    public function base64_urlSafeEncode($data)
200
    {
201 2
        $find = array('+', '/');
202 2
        $replace = array('-', '_');
203 2
        return str_replace($find, $replace, base64_encode($data));
204
    }
205
206
    /**
207
     * Urlsafe base64 decode
208
     *
209
     * @param string $str
210
     *
211
     * @return string
212
     */
213 2
    public function base64_urlSafeDecode($str)
214
    {
215 2
        $find = array('-', '_');
216 2
        $replace = array('+', '/');
217 2
        return base64_decode(str_replace($find, $replace, $str));
218
    }
219
}
220