Issues (30)

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/Service/Subscription/SubscriptionService.php (2 issues)

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
2
3
namespace Speicher210\Fastbill\Api\Service\Subscription;
4
5
use Speicher210\Fastbill\Api\AbstractService;
6
use Speicher210\Fastbill\Api\Model\Feature;
7
use Speicher210\Fastbill\Api\Model\Subscription;
8
9
/**
10
 * Service for subscriptions.
11
 */
12
class SubscriptionService extends AbstractService
13
{
14
    /**
15
     * Get one subscription by using the Fastbill subscription ID.
16
     *
17
     * @param integer $subscriptionId The Fastbill subscription ID.
18
     * @return Subscription|null
19
     */
20 6
    public function getSubscriptionById($subscriptionId)
21
    {
22 6
        $subscriptions = $this
23 6
            ->getSubscriptions(null, null, null, $subscriptionId)
24 6
            ->getResponse()
25 6
            ->getSubscriptions();
26
27 6
        return count($subscriptions) ? reset($subscriptions) : null;
28
    }
29
30
    /**
31
     * Get the subscriptions.
32
     *
33
     * @param integer $customerId The customer ID.
34
     * @param string $externalCustomerId The external customer ID.
35
     * @param string $subscriptionExternalId The external subscription ID.
36
     * @param integer $subscriptionId The subscription ID.
37
     * @return Get\ApiResponse
38
     */
39 12
    public function getSubscriptions(
40
        $customerId = null,
41
        $externalCustomerId = null,
42
        $subscriptionExternalId = null,
43
        $subscriptionId = null
44
    ) {
45 12
        $requestData = new Get\RequestData();
46 12
        $requestData->setCustomerId($customerId);
47 12
        $requestData->setExternalCustomerId($externalCustomerId);
48 12
        $requestData->setSubscriptionExternalId($subscriptionExternalId);
49 12
        $requestData->setSubscriptionId($subscriptionId);
50
51 12
        $request = new Get\Request($requestData);
52
53 12
        return $this->sendRequest($request, Get\ApiResponse::class);
54
    }
55
56
    /**
57
     * Create a subscription.
58
     *
59
     * @param Create\RequestData $requestData The request data.
60
     * @return Create\ApiResponse
61
     */
62 9
    public function createSubscription(Create\RequestData $requestData)
63
    {
64 9
        $request = new Create\Request($requestData);
65
66 9
        return $this->sendRequest($request, Create\ApiResponse::class);
67
    }
68
69
    /**
70
     * Update a subscription.
71
     *
72
     * @param integer $subscriptionId The subscription ID.
73
     * @param \DateTime $nextEvent The next event date and time.
74
     * @param string $subscriptionExternalId The external subscription ID.
75
     * @param string $status The subscription status.
76
     * @param array $xAttributes The subscription x attributes.
77
     * @param Feature[] $features The features.
78
     * @return Update\ApiResponse
79
     */
80 3
    public function updateSubscription(
81
        $subscriptionId,
82
        $nextEvent = null,
83
        $subscriptionExternalId = null,
84
        $status = null,
85
        array $xAttributes = array(),
86
        array $features = array()
87
    ) {
88 3
        $requestData = new Update\RequestData($subscriptionId);
89
90 3
        $requestData->setSubscriptionId($subscriptionId);
91 3
        $requestData->setNextEvent($nextEvent);
92 3
        $requestData->setSubscriptionExternalId($subscriptionExternalId);
93 3
        $requestData->setStatus($status);
94 3
        $requestData->setXAttributes($xAttributes);
95 3
        $requestData->setFeatures($features);
96
97 3
        $request = new Update\Request($requestData);
98
99 3
        return $this->sendRequest($request, Update\ApiResponse::class);
100
    }
101
102
    /**
103
     * Change article of a subscription.
104
     *
105
     * @param ChangeArticle\RequestData $requestData The request data.
106
     * @return ChangeArticle\ApiResponse
107
     */
108 3
    public function changeSubscriptionArticle(ChangeArticle\RequestData $requestData)
109
    {
110 3
        $request = new ChangeArticle\Request($requestData);
111
112 3
        return $this->sendRequest($request, ChangeArticle\ApiResponse::class);
113
    }
114
115
    /**
116
     * Set the addon for a subscription.
117
     *
118
     * @param SetAddon\RequestData $requestData The request data.
119
     * @return SetAddon\ApiResponse
120
     */
121 3
    public function setSubscriptionAddon(SetAddon\RequestData $requestData)
122
    {
123 3
        $request = new SetAddon\Request($requestData);
124
125 3
        return $this->sendRequest($request, SetAddon\ApiResponse::class);
126
    }
127
128
    /**
129
     * Set the usage data of a subscription.
130
     *
131
     * @param SetUsageData\RequestData $requestData The request data.
132
     * @return SetUsageData\ApiResponse
133
     */
134 3
    public function setSubscriptionUsageData(SetUsageData\RequestData $requestData)
135
    {
136 3
        $request = new SetUsageData\Request($requestData);
137
138 3
        return $this->sendRequest($request, SetUsageData\ApiResponse::class);
139
    }
140
141
    /**
142
     * Get the usage data of a subscription.
143
     *
144
     * @param integer $subscriptionId The subscription ID.
145
     * @param \DateTime $subscriptionStart The subscription start.
146
     * @param \DateTime $subscriptionEnd The subscription end.
147
     * @return GetUsageData\ApiResponse
148
     */
149 3
    public function getSubscriptionUsageData(
150
        $subscriptionId,
151
        \DateTime $subscriptionStart = null,
152
        \DateTime $subscriptionEnd = null
153
    ) {
154 3
        $requestData = new GetUsageData\RequestData($subscriptionId);
155
156 3
        $requestData->setSubscriptionId($subscriptionId);
157 3
        $requestData->setSubscriptionStart($subscriptionStart);
0 ignored issues
show
It seems like $subscriptionStart defined by parameter $subscriptionStart on line 151 can be null; however, Speicher210\Fastbill\Api...:setSubscriptionStart() does not accept null, maybe add an additional type check?

It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.

We recommend to add an additional type check (or disallow null for the parameter):

function notNullable(stdClass $x) { }

// Unsafe
function withoutCheck(stdClass $x = null) {
    notNullable($x);
}

// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
    if ($x instanceof stdClass) {
        notNullable($x);
    }
}

// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
    notNullable($x);
}
Loading history...
158 3
        $requestData->setSubscriptionEnd($subscriptionEnd);
0 ignored issues
show
It seems like $subscriptionEnd defined by parameter $subscriptionEnd on line 152 can be null; however, Speicher210\Fastbill\Api...a::setSubscriptionEnd() does not accept null, maybe add an additional type check?

It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.

We recommend to add an additional type check (or disallow null for the parameter):

function notNullable(stdClass $x) { }

// Unsafe
function withoutCheck(stdClass $x = null) {
    notNullable($x);
}

// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
    if ($x instanceof stdClass) {
        notNullable($x);
    }
}

// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
    notNullable($x);
}
Loading history...
159
160 3
        $request = new GetUsageData\Request($requestData);
161
162 3
        return $this->sendRequest($request, GetUsageData\ApiResponse::class);
163
    }
164
165
    /**
166
     * Get the usage data of a subscription.
167
     *
168
     * @param string $usageDataId The usage data ID.
169
     * @return DeleteUsageData\ApiResponse
170
     */
171 3
    public function deleteSubscriptionUsageData($usageDataId)
172
    {
173 3
        $requestData = new DeleteUsageData\RequestData($usageDataId);
174 3
        $request = new DeleteUsageData\Request($requestData);
175
176 3
        return $this->sendRequest($request, DeleteUsageData\ApiResponse::class);
177
    }
178
179
    /**
180
     * Get the upcoming amount.
181
     *
182
     * @param GetUpcomingAmount\RequestData $requestData The request data filter.
183
     * @return GetUpcomingAmount\ApiResponse
184
     */
185 3
    public function getUpcomingAmount(GetUpcomingAmount\RequestData $requestData = null)
186
    {
187 3
        if ($requestData === null) {
188
            $requestData = new GetUpcomingAmount\RequestData();
189
        }
190
191 3
        $request = new GetUpcomingAmount\Request($requestData);
192
193 3
        return $this->sendRequest($request, GetUpcomingAmount\ApiResponse::class);
194
    }
195
196
    /**
197
     * Postpone a subscription shipping.
198
     *
199
     * @param integer $subscriptionId
200
     * @param integer $month The month to postpone.
201
     * @return Postpone\ApiResponse
202
     */
203 3
    public function postponeSubscription($subscriptionId, $month)
204
    {
205 3
        $requestData = new Postpone\RequestData($subscriptionId, $month);
206 3
        $request = new Postpone\Request($requestData);
207
208 3
        return $this->sendRequest($request, Postpone\ApiResponse::class);
209
    }
210
211
    /**
212
     * Renew a subscription.
213
     *
214
     * @param integer $subscriptionId The subscription ID to renew.
215
     * @return Renew\ApiResponse
216
     */
217 3
    public function renewSubscription($subscriptionId)
218
    {
219 3
        $requestData = new Renew\RequestData($subscriptionId);
220 3
        $request = new Renew\Request($requestData);
221
222 3
        return $this->sendRequest($request, Renew\ApiResponse::class);
223
    }
224
225
    /**
226
     * Create a secure link for a subscription.
227
     *
228
     * @param integer $subscriptionId The subscription ID for which to create the secure link.
229
     * @return CreateSecureLink\ApiResponse
230
     */
231 3
    public function createSecureLink($subscriptionId)
232
    {
233 3
        $requestData = new CreateSecureLink\RequestData($subscriptionId);
234 3
        $request = new CreateSecureLink\Request($requestData);
235
236 3
        return $this->sendRequest($request, CreateSecureLink\ApiResponse::class);
237
    }
238
239
    /**
240
     * Cancel a subscription.
241
     *
242
     * @param integer $subscriptionId The subscription ID.
243
     * @param \DateTime $cancellationDate The cancellation date and time.
244
     * @param string $cancellationNote The cancellation note.
245
     * @return Cancel\ApiResponse
246
     */
247 3
    public function cancelSubscription($subscriptionId, \DateTime $cancellationDate = null, $cancellationNote = null)
248
    {
249 3
        $requestData = new Cancel\RequestData($subscriptionId);
250 3
        $requestData->setCancellationDate($cancellationDate);
251 3
        $requestData->setCancellationNote($cancellationNote);
252
253 3
        $request = new Cancel\Request($requestData);
254
255 3
        return $this->sendRequest($request, Cancel\ApiResponse::class);
256
    }
257
258
    /**
259
     * Reactivate a subscription.
260
     *
261
     * @param integer $subscriptionId The subscription ID to reactivate.
262
     * @return Reactivate\ApiResponse
263
     */
264 3
    public function reactivateSubscription($subscriptionId)
265
    {
266 3
        $requestData = new Reactivate\RequestData($subscriptionId);
267 3
        $request = new Reactivate\Request($requestData);
268
269 3
        return $this->sendRequest($request, Reactivate\ApiResponse::class);
270
    }
271
}
272