Issues (43)

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/Response/Response.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
namespace Loevgaard\AltaPay\Response;
3
4
use Loevgaard\AltaPay\Exception\XmlException;
5
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;
6
7
abstract class Response implements ResponseInterface
8
{
9
    /**
10
     * Holds the response object
11
     *
12
     * @var PsrResponseInterface
13
     */
14
    protected $response;
15
16
    /**
17
     * Holds the entire XML response string, i.e.
18
     *
19
     * <APIResponse version="20110831">
20
     *   <Header>
21
     *     <Date>2011-08-29T23:48:32+02:00</Date>
22
     *     <Path>API/xxx</Path>
23
     *     <ErrorCode>0</ErrorCode>
24
     *     <ErrorMessage/>
25
     *   </Header>
26
     *   <Body>
27
     *     [.....]
28
     *   </Body>
29
     * </APIResponse>
30
     *
31
     * @var string
32
     */
33
    protected $xml;
34
35
    /**
36
     * Holds an XML object based on the Response::$xml string
37
     *
38
     * @var \SimpleXMLElement
39
     */
40
    protected $xmlDoc;
41
42
    /**
43
     * @var string
44
     */
45
    protected $version;
46
47
    /**
48
     * @var \DateTimeImmutable
49
     */
50
    protected $date;
51
52
    /**
53
     * @var string
54
     */
55
    protected $path;
56
57
    /**
58
     * @var int
59
     */
60
    protected $errorCode;
61
62
    /**
63
     * @var string
64
     */
65
    protected $errorMessage;
66
67
    /**
68
     * @param PsrResponseInterface $response
69
     * @throws XmlException
70
     */
71 27 View Code Duplication
    public function __construct(PsrResponseInterface $response)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
72
    {
73 27
        $this->response = $response;
74 27
        $this->xml = (string)$this->response->getBody();
75 27
        $this->xmlDoc = new \SimpleXMLElement($this->xml);
76 27
        $this->version = (string)$this->xmlDoc['version'];
77 27
        $this->date = \DateTimeImmutable::createFromFormat(DATE_RFC3339, (string)$this->xmlDoc->Header->Date);
78 27
        if ($this->date === false) {
79 3
            $exception = new XmlException('The date format is wrong in xml header');
80 3
            $exception->setXmlElement($this->xmlDoc);
81 3
            throw $exception;
82
        }
83 24
        $this->path = (string)$this->xmlDoc->Header->Path;
84 24
        $this->errorCode = (int)$this->xmlDoc->Header->ErrorCode;
85 24
        $this->errorMessage = (string)$this->xmlDoc->Header->ErrorMessage;
86 24
        $this->init();
87 24
    }
88
89
    /**
90
     * @return bool
91
     */
92 12
    public function isSuccessful() : bool
93
    {
94 12
        return $this->errorCode === 0;
95
    }
96
97
    /**
98
     * @return PsrResponseInterface
99
     */
100 12
    public function getResponse() : PsrResponseInterface
101
    {
102 12
        return $this->response;
103
    }
104
105
    /**
106
     * @return string
107
     */
108 3
    public function getXml() : string
109
    {
110 3
        return $this->xml;
111
    }
112
113
    /**
114
     * @return \SimpleXMLElement
115
     */
116 3
    public function getXmlDoc() : \SimpleXMLElement
117
    {
118 3
        return $this->xmlDoc;
119
    }
120
121
    /**
122
     * @return string
123
     */
124 3
    public function getVersion() : string
125
    {
126 3
        return $this->version;
127
    }
128
129
    /**
130
     * @return \DateTimeImmutable
131
     */
132 3
    public function getDate() : \DateTimeImmutable
133
    {
134 3
        return $this->date;
135
    }
136
137
    /**
138
     * @return string
139
     */
140 3
    public function getPath() : string
141
    {
142 3
        return $this->path;
143
    }
144
145
    /**
146
     * @return int
147
     */
148 3
    public function getErrorCode() : int
149
    {
150 3
        return $this->errorCode;
151
    }
152
153
    /**
154
     * @return string
155
     */
156 3
    public function getErrorMessage() : string
157
    {
158 3
        return $this->errorMessage;
159
    }
160
161
    /**
162
     * Is called after the contructor has initialized the properties
163
     * Use this to do any initialization you need
164
     */
165 3
    protected function init()
166
    {
167 3
    }
168
}
169