Issues (194)

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

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 Bpost\BpostApiClient\ApiCaller;
4
5
use Bpost\BpostApiClient\Exception\BpostApiResponseException;
6
use Bpost\BpostApiClient\Exception\BpostApiResponseException\BpostApiBusinessException;
7
use Bpost\BpostApiClient\Exception\BpostApiResponseException\BpostApiSystemException;
8
use Bpost\BpostApiClient\Exception\BpostApiResponseException\BpostCurlException;
9
use Bpost\BpostApiClient\Exception\BpostApiResponseException\BpostInvalidResponseException;
10
use Bpost\BpostApiClient\Exception\BpostApiResponseException\BpostInvalidXmlResponseException;
11
use Bpost\BpostApiClient\Logger;
12
13
/**
14
 * Class ApiCaller
15
 * @package Bpost\BpostApiClient\ApiCaller
16
 * @codeCoverageIgnore That makes a HTTP request with the bpost API
17
 */
18
class ApiCaller
19
{
20
21
    /** @var Logger */
22
    private $logger;
23
24
    /** @var int */
25
    private $responseHttpCode;
26
27
    /** @var string */
28
    private $responseBody;
29
30
    /** @var string */
31
    private $responseContentType;
32
33
    /**
34
     * ApiCaller constructor.
35
     * @param Logger $logger
0 ignored issues
show
Should the type for parameter $logger not be null|Logger?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
36
     */
37
    public function __construct(Logger $logger = null)
38
    {
39
        $this->logger = $logger;
40
    }
41
42
    /**
43
     * @return int
44
     */
45
    public function getResponseHttpCode()
46
    {
47
        return $this->responseHttpCode;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getResponseBody()
54
    {
55
        return $this->responseBody;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getResponseContentType()
62
    {
63
        return $this->responseContentType;
64
    }
65
66
67
    /**
68
     * @param array $options
69
     * @return bool
70
     * @throws BpostApiBusinessException
71
     * @throws BpostApiResponseException
72
     * @throws BpostApiSystemException
73
     * @throws BpostCurlException
74
     * @throws BpostInvalidResponseException
75
     * @throws BpostInvalidXmlResponseException
76
     */
77
    public function doCall(array $options)
78
    {
79
        $curl = curl_init();
80
81
        // set options
82
        curl_setopt_array($curl, $options);
83
84
        $this->logger->debug('curl request', $options);
85
86
        // execute
87
        $this->responseBody = curl_exec($curl);
88
        $errorNumber = curl_errno($curl);
89
        $errorMessage = curl_error($curl);
90
91
        $headers = curl_getinfo($curl);
92
93
        $this->logger->debug('curl response', array(
94
            'status' => $errorNumber . ' (' . $errorMessage . ')',
95
            'headers' => $headers,
96
            'response' => $this->responseBody
97
        ));
98
99
        // error?
100
        if ($errorNumber != '') {
101
            throw new BpostCurlException($errorMessage, $errorNumber);
102
        }
103
104
        if (isset($headers['http_code'])) {
105
            $this->responseHttpCode = $headers['http_code'];
106
        }
107
108
        if (isset($headers['Content-Type'])) {
109
            $this->responseContentType = $headers['Content-Type'];
110
        }
111
112
        return true;
113
    }
114
115
    /**
116
     * If the httpCode is 200, return 200
117
     * If the httpCode is 203, return 200
118
     * If the httpCode is 404 ,return 404
119
     * ...
120
     *
121
     * @return int
122
     */
123
    public function getHttpCodeType()
124
    {
125
        return 100 * (int)($this->responseHttpCode / 100);
126
    }
127
}
128