Issues (33)

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/DocumentProvider.php (3 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
3
namespace Sausin\Signere;
4
5
use UnexpectedValueException;
6
7
class DocumentProvider extends BaseClass
8
{
9
    /** The URI of the action */
10
    const URI = 'https://api.signere.no/api/DocumentProvider';
11
12
    /**
13
     * Retrieves a document provider account.
14
     *
15
     * @param  string $providerId
16
     * @return object
17
     */
18 1
    public function getProviderAccount(string $providerId)
19
    {
20
        // make the URL for this request
21 1
        $url = sprintf('%s/%s', $this->getBaseUrl(), $providerId);
22
23
        // get the headers for this request
24 1
        $headers = $this->headers->make('GET', $url);
25
26
        // get the response
27 1
        $response = $this->client->get($url, [
28 1
            'headers' => $headers,
29
        ]);
30
31
        // return the response
32 1
        return $response;
33
    }
34
35
    /**
36
     * Gets the expires date for your BankID certificate. If you don't
37
     * have your own BankID certificate it will return Bad request.
38
     *
39
     * @return object
40
     */
41 1
    public function getCertExpiry()
42
    {
43
        // make the URL for this request
44 1
        $url = sprintf('%s/CertificateExpires', $this->getBaseUrl());
45
46
        // get the headers for this request
47 1
        $headers = $this->headers->make('GET', $url);
48
49
        // get the response
50 1
        $response = $this->client->get($url, [
51 1
            'headers' => $headers,
52
        ]);
53
54
        // return the response
55 1
        return $response;
56
    }
57
58
    /**
59
     * Get the usage when using prepaid or demo account.
60
     *
61
     * @param  string       $providerId
62
     * @param  bool|bool $demo
63
     * @return object
64
     */
65 2 View Code Duplication
    public function getUsage(string $providerId, bool $demo = false)
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...
66
    {
67
        // make the URL for this request
68 2
        $url = sprintf(
69 2
            '%s/quota/%s?ProviderId=%s',
70 2
            $this->getBaseUrl(),
71 2
            $demo ? 'demo' : 'prepaid',
72 2
            $providerId
73
        );
74
75
        // get the headers for this request
76 2
        $headers = $this->headers->make('GET', $url);
77
78
        // get the response
79 2
        $response = $this->client->get($url, [
80 2
            'headers' => $headers,
81
        ]);
82
83
        // return the response
84 2
        return $response;
85
    }
86
87
    /**
88
     * Creates a new document provider.
89
     *
90
     * @param  array  $body
91
     * @return object
92
     */
93 1
    public function create(array $body)
94
    {
95
        // keys that are mandatory for this request
96
        $needKeys = [
97 1
            'BillingAddress1',
98
            'BillingCity',
99
            'BillingPostalCode',
100
            'CompanyEmail',
101
            'CompanyPhone',
102
            'DealerId',
103
            'LegalContactEmail',
104
            'LegalContactName',
105
            'LegalContactPhone',
106
            'MvaNumber',
107
            'Name',
108
        ];
109
110
        // if the body doesn't have needed fields, throw an exception
111 1
        $this->validateHasKeys($body, $needKeys);
112
113 1 View Code Duplication
        if (isset($body['BillingPlan'])) {
0 ignored issues
show
This code seems to be duplicated across 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...
114 1
            $expected = ['Small', 'Medium', 'Large'];
115 1
            if (! in_array($body['BillingPlan'], $expected)) {
116 1
                throw new UnexpectedValueException('BillingPlan should be one of '.implode(', ', $expected));
117
            }
118
        }
119
120
        // make the URL for this request
121 1
        $url = $this->getBaseUrl();
122
123
        // get the response
124 1
        $response = $this->client->post($url, [
125 1
            'json' => $body,
126
        ]);
127
128
        // return the response
129 1
        return $response;
130
    }
131
132
    /**
133
     * Updates a new document provider.
134
     *
135
     * @param  array  $body
136
     * @return object
137
     */
138 1
    public function update(array $body)
139
    {
140
        // keys that are mandatory for this request
141 1
        $needKeys = ['Mobile', 'ProviderId'];
142
143
        // if the body doesn't have needed fields, throw an exception
144 1
        $this->validateHasKeys($body, $needKeys);
145
146 1 View Code Duplication
        if (isset($body['BillingPlan'])) {
0 ignored issues
show
This code seems to be duplicated across 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...
147
            $expected = ['Small', 'Medium', 'Large'];
148
            if (! in_array($body['BillingPlan'], $expected)) {
149
                throw new UnexpectedValueException('BillingPlan should be one of '.implode(', ', $expected));
150
            }
151
        }
152
153
        // make the URL for this request
154 1
        $url = $this->getBaseUrl();
155
156
        // get the headers for this request
157 1
        $headers = $this->headers->make('PUT', $url, $body, true);
158
159
        // get the response
160 1
        $response = $this->client->put($url, [
161 1
            'headers' => $headers,
162 1
            'json' => $body,
163
        ]);
164
165
        // return the response
166 1
        return $response;
167
    }
168
}
169