Issues (431)

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.

include/classes/bitcoinwrapper.class.php (9 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
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
3
4
/**
5
 * We use a wrapper class around BitcoinClient to add
6
 * some basic caching functionality and some debugging
7
 **/
8
class BitcoinWrapper extends BitcoinClient {
9
  public function __construct($type, $username, $password, $host, $debug_level, $debug_object, $memcache) {
10
    $this->type = $type;
11
    $this->username = $username;
12
    $this->password = $password;
13
    $this->host = $host;
14
    // $this->debug is already used
15
    $this->oDebug = $debug_object;
16
    $this->memcache = $memcache;
17
    $debug_level > 0 ? $debug_level = true : $debug_level = false;
18
    return parent::__construct($this->type, $this->username, $this->password, $this->host, '', $debug_level);
0 ignored issues
show
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
19
  }
20
  /**
21
   * Wrap variouns methods to add caching
22
   **/
23
  // Caching this, used for each can_connect call
24
  public function getinfo() {
25
    $this->oDebug->append("STA " . __METHOD__, 4);
26
    if ($data = $this->memcache->get(__FUNCTION__)) return $data;
27
    try {
28
      return $this->memcache->setCache(__FUNCTION__, parent::getnetworkinfo()+parent::getmininginfo()+parent::getwalletinfo(), 30);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getnetworkinfo() instead of getinfo()). Are you sure this is correct? If so, you might want to change this to $this->getnetworkinfo().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getmininginfo() instead of getinfo()). Are you sure this is correct? If so, you might want to change this to $this->getmininginfo().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getwalletinfo() instead of getinfo()). Are you sure this is correct? If so, you might want to change this to $this->getwalletinfo().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
29
    } catch (Exception $e) {
30
      $this->oDebug->append("DEPRECATED : RPC version < 0.16, fallback to `getinfo` RPC call", 2);
31
      return $this->memcache->setCache(__FUNCTION__, parent::getinfo(), 30);
32
    }
33
  }
34
35
  public function is_testnet() {
36
    $this->oDebug->append("STA " . __METHOD__, 4);
37
    if ($data = $this->memcache->get(__FUNCTION__)) return $data;
38
    if (!(parent::getblockchaininfo()))
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getblockchaininfo() instead of is_testnet()). Are you sure this is correct? If so, you might want to change this to $this->getblockchaininfo().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
39
      return $this->memcache->setCache(__FUNCTION__, parent::is_testnet(), 30);
40
    else
41
      return $this->memcache->setCache(__FUNCTION__, parent::getblockchaininfo()['chain'] == 'test', 30);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getblockchaininfo() instead of is_testnet()). Are you sure this is correct? If so, you might want to change this to $this->getblockchaininfo().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
42
  }
43
44
  public function getmininginfo() {
45
    $this->oDebug->append("STA " . __METHOD__, 4);
46
    if ($data = $this->memcache->get(__FUNCTION__)) return $data;
47
    return $this->memcache->setCache(__FUNCTION__, parent::getmininginfo(), 30);
48
  }
49
50
  public function getblockcount() {
51
    $this->oDebug->append("STA " . __METHOD__, 4);
52
    if ($data = $this->memcache->get(__FUNCTION__)) return $data;
53
    return $this->memcache->setCache(__FUNCTION__, parent::getblockcount(), 30);
54
  }
55
  // Wrapper method to get the real main account balance
56
  public function getrealbalance() {
57
    $this->oDebug->append("STA " . __METHOD__, 4);
58
    $aAccounts = [];
59
60
    try {
61
      $aAccounts = parent::listaccounts();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (listaccounts() instead of getrealbalance()). Are you sure this is correct? If so, you might want to change this to $this->listaccounts().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
62
    } catch (Exception $e) {
63
      if ($e->getCode() == 404)
64
        $aAccounts = array( '*' => parent::getbalance("*") );
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getbalance() instead of getrealbalance()). Are you sure this is correct? If so, you might want to change this to $this->getbalance().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
65
    }
66
67
    // Account checks
68
    if (count($aAccounts) == 1) {
69
      // We only have a single account so getbalance will be fine
70
      return parent::getbalance("*");
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getbalance() instead of getrealbalance()). Are you sure this is correct? If so, you might want to change this to $this->getbalance().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
71
    } else {
72
      return $aAccounts[0];
73
    }
74
  }
75
  public function getdifficulty() {
76
    $this->oDebug->append("STA " . __METHOD__, 4);
77
    if ($data = $this->memcache->get(__FUNCTION__)) return $data;
78
    $data = parent::getdifficulty();
79
    // Check for PoS/PoW coins
80
    if (is_array($data) && array_key_exists('proof-of-work', $data))
81
      $data = $data['proof-of-work'];
82
    return $this->memcache->setCache(__FUNCTION__, $data, 30);
83
  }
84
  public function getestimatedtime($iCurrentPoolHashrate) {
85
    $this->oDebug->append("STA " . __METHOD__, 4);
86
    if ($iCurrentPoolHashrate == 0) return 0;
87
    if ($data = $this->memcache->get(__FUNCTION__)) return $data;
88
    $dDifficulty = $this->getdifficulty();
89
    return $this->memcache->setCache(__FUNCTION__, $dDifficulty * pow(2,32) / $iCurrentPoolHashrate, 30);
90
  }
91
  public function getblockchaindownload() {
92
    $aPeerInfo = $this->getpeerinfo();
93
    $aInfo = $this->getinfo();
94
    $iStartingHeight = 0;
95
    foreach ($aPeerInfo as $aPeerData) {
96
      if ($iStartingHeight < $aPeerData['startingheight']) $iStartingHeight = $aPeerData['startingheight'];
97
    }
98
    if ($iStartingHeight > $aInfo['blocks']) {
99
      return number_format(round($aInfo['blocks'] / $iStartingHeight * 100, 2), 2);
100
    } else {
101
      return false;
102
    }
103
  }
104
  public function getnetworkhashps() {
105
    $this->oDebug->append("STA " . __METHOD__, 4);
106
    if ($data = $this->memcache->get(__FUNCTION__)) return $data;
107
    try {
108
      $dNetworkHashrate = $this->getmininginfo();
109
      if (is_array($dNetworkHashrate)) {
110
        if (array_key_exists('networkhashps', $dNetworkHashrate)) {
111
          $dNetworkHashrate = $dNetworkHashrate['networkhashps'];
112
        } else if (array_key_exists('networkmhps', $dNetworkHashrate)) {
113
          $dNetworkHashrate = $dNetworkHashrate['networkmhps'] * 1000 * 1000;
114
        } else if (array_key_exists('networkghps', $dNetworkHashrate)) {
115
          $dNetworkHashrate = $dNetworkHashrate['networkghps'] * 1000 * 1000 * 1000;
116
        } else if (array_key_exists('hashespersec', $dNetworkHashrate)) {
117
          $dNetworkHashrate = $dNetworkHashrate['hashespersec'];
118
        } else if (array_key_exists('netmhashps', $dNetworkHashrate)) {
119
          $dNetworkHashrate = $dNetworkHashrate['netmhashps'] * 1000 * 1000;
120
        } else {
121
          // Unsupported implementation
122
          $dNetworkHashrate = 0;
123
        }
124
      }
125
    } catch (Exception $e) {
126
      // getmininginfo does not exist, cache for an hour
127
      return $this->memcache->setCache(__FUNCTION__, 0, 3600);
128
    }
129
    return $this->memcache->setCache(__FUNCTION__, $dNetworkHashrate, 30);
130
  }
131
}
132
133
// Load this wrapper
134
$bitcoin = new BitcoinWrapper($config['wallet']['type'], $config['wallet']['username'], $config['wallet']['password'], $config['wallet']['host'], $config['DEBUG'], $debug, $memcache);
135