Issues (7)

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

Labels
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 namespace Packback\Prices;
2
3
use Packback\Prices\PriceDto;
4
use GuzzleHttp\Client as GuzzleClient;
5
6
abstract class PriceClient
7
{
8
    const CONDITION_NEW = 'new';
9
    const CONDITION_GOOD = 'good';
10
    const CONDITION_ACCEPTABLE = 'acceptable';
11
    const CONDITION_POOR = 'poor';
12
13
    const TERM_PERPETUAL = 'perpetual';
14
    const TERM_SEMESTER = 'semester';
15
    const TERM_QUARTER = 'quarter';
16
    const TERM_HALFQUARTER = 'half-quarter';
17
    const TERM_TWOMONTH = 'two-month';
18
    const TERM_ONEMONTH = 'one-month';
19
    const TERM_DAILY = 'daily';
20
21
    public $client;
22
    public $query = [];
23
    public $collection = [];
24
    public $baseUrl = '';
25
26 40
    public function __construct()
27
    {
28 40
        $this->client = new GuzzleClient();
29 40
    }
30
31
    abstract public function getPricesForIsbns($isbns = []);
32
33
    abstract public function addPricesToCollection($response);
34
35 12
    public function addParam($key, $value)
36
    {
37 12
        $this->query[$key] = $value;
38 12
        return $this;
39
    }
40
41 6
    public function send()
42
    {
43 6
        $querystring = http_build_query($this->query);
44
        try {
45 6
            $response = $this->client->get($this->baseUrl.'?'.$querystring);
0 ignored issues
show
The method get does only exist in GuzzleHttp\Client, but not in CROSCON\CommissionJunction\Client.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
46 6
            if ($response->getStatusCode() == '200') {
47 6
                return $this->decodeXml($response->getBody(true));
48
            }
49 2
        } catch (\Exception $e) {
50
            // Return error messaging
51 2
            return $e->getMessage();
52
        }
53
    }
54
55 6
    public function decodeXml($string)
56
    {
57 6
        return json_decode(
58 6
            json_encode(
59 6
                simplexml_load_string(
60
                    $string
61 6
                )
62 4
            ),
63
            true
64 4
        );
65 2
    }
66
67 48
    public function createNewPrice()
68
    {
69 48
        return new PriceDto();
70
    }
71
72 8
    public function addPriceToCollection($price)
73
    {
74 8
        $this->collection[] = $price;
75 8
        return $this;
76
    }
77
78 18
    public function getConditionFromString($string)
79
    {
80 18
        switch (strtolower($string)) {
81 18
            case 'new':
82 18
            case 'rent for 125 days':
83 18
            case 'rent for 90 days':
84 18
            case 'rent for 60 days':
85 18
            case 'rent for 45 days':
86 18
            case 'rent for 30 days':
87 6
                return self::CONDITION_NEW;
88 14
            case 'very good':
89 14
            case 'like new':
90 14
            case 'as new':
91 14
            case 'good':
92 14
            case 'used':
93 14
            case 'collectible':
94 8
                return self::CONDITION_GOOD;
95 6
            case 'near fine':
96 6
            case 'fine':
97 6
            case 'fair':
98 6
            case 'acceptable':
99 2
                return self::CONDITION_ACCEPTABLE;
100 4
            case 'poor':
101 4
                return self::CONDITION_POOR;
102
            default:
103
                throw new \Exception("Unrecognized book condition", 1);
104
        }
105
    }
106
107 12
    public function getTermFromString($string = null)
108
    {
109 12
        switch (strtolower($string)) {
110 12
            case 'used':
111 12
            case 'new':
112 4
                return self::TERM_PERPETUAL;
113 8
            case 'rent for 125 days':
114 8
            case 'semester':
115 2
                return self::TERM_SEMESTER;
116 8
            case 'rent for 90 days':
117 8
            case 'quarter':
118 2
                return self::TERM_QUARTER;
119 8
            case 'rent for 60 days':
120 2
                return self::TERM_TWOMONTH;
121 6
            case 'rent for 45 days':
122 2
                return self::TERM_HALFQUARTER;
123 4
            case 'rent for 30 days':
124 2
                return self::TERM_ONEMONTH;
125 2
            default:
126 2
                return null;
127 2
        }
128
    }
129
}
130