Issues (21)

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.

src/Rest/Hmac.php (1 issue)

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
 * Jaeger
4
 *
5
 * @copyright	Copyright (c) 2015-2016, mithra62
6
 * @link		http://jaeger-app.com
7
 * @version		1.0
8
 * @filesource 	./Rest/Hmac.php
9
 */
10
 
11
namespace JaegerApp\Rest;
12
13
use PhilipBrown\Signature\Auth;
14
use PhilipBrown\Signature\Token;
15
use PhilipBrown\Signature\Guards\CheckKey;
16
use PhilipBrown\Signature\Guards\CheckVersion;
17
use PhilipBrown\Signature\Guards\CheckTimestamp;
18
use PhilipBrown\Signature\Guards\CheckSignature;
19
use PhilipBrown\Signature\Exceptions\SignatureException;
20
21
/**
22
 * Jaeger - REST Hmac Object
23
 *
24
 * Allows for Hmac authentication 
25
 *
26
 * @package Rest\Authentication
27
 * @author Eric Lamb <[email protected]>
28
 */
29
class Hmac
30
{
31
    /**
32
     * The prefix authentication keys will be named after
33
     * @var string
34
     */
35
    private $prefix = 'm62_auth_';
36
    
37
    /**
38
     * The REQUEST method we're working with
39
     * @var string
40
     */
41
    protected $method = 'get';
42
    
43
    /**
44
     * The route being requested
45
     * @var string
46
     */
47
    protected $route = '';
48
    
49
    /**
50
     * The data to compare
51
     * @var string
52
     */
53
    protected $data = '';
54
    
55
    /**
56
     * Authenticates a request
57
     * @param string $key
58
     * @param string $secret
59
     */
60
    public function auth($key, $secret)
61
    {
62
        //make sure we have the require attributes
63
        $required = array('timestamp');
64
        $data = $this->getData();
65
        foreach($required AS $require) {
66
            if(!isset($data[$this->prefix.$require])) {
67
                return false;
68
            }
69
        }
70
        
71
        //looks good, now let's process it
72
        $auth  = new Auth($this->getMethod(), $this->getRoute(), $this->getData(), [
0 ignored issues
show
$this->getData() is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
73
            new CheckKey,
74
            new CheckVersion,
75
            new CheckTimestamp,
76
            new CheckSignature
77
        ]);
78
        $token = new Token($key, $secret);
79
        
80
        try {
81
            return $auth->attempt($token, $this->prefix);
82
        }
83
        
84
        catch (SignatureException $e) {
85
            return false;
86
        }
87
    }
88
    
89
    /**
90
     * Sets the HTTP method to use
91
     * @param string $method
92
     * @return \JaegerApp\Rest\Hmac
93
     */
94
    public function setMethod($method)
95
    {
96
        $this->method = $method;
97
        return $this;
98
    }
99
    
100
    /**
101
     * Returns the HTTP method
102
     * @return string
103
     */
104
    public function getMethod()
105
    {
106
        return $this->method;
107
    }
108
    
109
    /**
110
     * Sets the route to use
111
     * @param string $route
112
     * @return \JaegerApp\Rest\Hmac
113
     */
114
    public function setRoute($route)
115
    {
116
        $this->route = $route;
117
        return $this;
118
    }
119
    
120
    /**
121
     * Returns the route
122
     * @return string
123
     */
124
    public function getRoute()
125
    {
126
        return $this->route;
127
    }
128
    
129
    /**
130
     * Sets the data payload to use
131
     * @param string $data
132
     * @return \JaegerApp\Rest\Hmac
133
     */
134
    public function setData($data)
135
    {
136
        $this->data = $data;
137
        return $this;
138
    }
139
    
140
    /**
141
     * Returns the data
142
     * @return string
143
     */
144
    public function getData()
145
    {
146
        return $this->data;
147
    }
148
    
149
    public function getPrefix()
150
    {
151
        return $this->prefix;
152
    }
153
}