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/ExternalLogin.php (2 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 BadMethodCallException;
6
use UnexpectedValueException;
7
8
class ExternalLogin extends BaseClass
9
{
10
    /** The URI of the action */
11
    const URI = 'https://api.signere.no/api/ExternalLogin';
12
13
    /**
14
     * Return the login information from the login.
15
     *
16
     * @param  string $requestId
17
     * @return object
18
     */
19 1
    public function getLoginInfo(string $requestId)
20
    {
21
        // make the URL for this request
22 1
        $url = sprintf('%s/%s', $this->getBaseUrl(), $requestId);
23
24
        // get the headers for this request
25 1
        $headers = $this->headers->make('GET', $url);
26
27
        // get the response
28 1
        $response = $this->client->get($url, [
29 1
            'headers' => $headers,
30
        ]);
31
32
        // return the response
33 1
        return $response;
34
    }
35
36
    /**
37
     * Creates a app login response which contains
38
     * the launchuri to launch the BankID app.
39
     *
40
     * @param  array  $body
41
     * @return object
42
     */
43 1 View Code Duplication
    public function createAppLaunchUri(array $body)
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...
44
    {
45
        // keys that are mandatory for this request
46 1
        $needKeys = ['ExternalId', 'ReturnUrl'];
47
48
        // if the body doesn't have needed fields, throw an exception
49 1
        $this->validateHasKeys($body, $needKeys);
50
51
        // make the URL for this request
52 1
        $url = sprintf('%s/AppLogin', $this->getBaseUrl());
53
54
        // get the headers for this request
55 1
        $headers = $this->headers->make('POST', $url, $body);
56
57
        // get the response
58 1
        $response = $this->client->post($url, [
59 1
            'headers' => $headers,
60 1
            'json' => $body,
61
        ]);
62
63
        // return the response
64 1
        return $response;
65
    }
66
67
    /**
68
     * Creates a BankID mobile login response.
69
     *
70
     * @param  array  $body
71
     * @return object
72
     */
73 1 View Code Duplication
    public function createMobile(array $body)
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...
74
    {
75
        // keys that are mandatory for this request
76 1
        $needKeys = ['DateOfBirth', 'Mobile'];
77
78
        // if the body doesn't have needed fields, throw an exception
79 1
        $this->validateHasKeys($body, $needKeys);
80
81
        // make the URL for this request
82 1
        $url = sprintf('%s/BankIDMobileLogin/Create', $this->getBaseUrl());
83
84
        // get the headers for this request
85 1
        $headers = $this->headers->make('POST', $url, $body);
86
87
        // get the response
88 1
        $response = $this->client->post($url, [
89 1
            'headers' => $headers,
90 1
            'json' => $body,
91
        ]);
92
93
        // return the response
94 1
        return $response;
95
    }
96
97
    /**
98
     * Starts the BankID mobile session that
99
     * was created by the 'create' method.
100
     *
101
     * @param  array  $body
102
     * @return object
103
     */
104 1
    public function startMobileSession(array $body = [])
105
    {
106
        // let the user know that if he is sending some data
107
        // it should be RequestId. Nothing else goes here.
108 1
        if (! empty($body) && ! isset($body['RequestId'])) {
109 1
            throw new UnexpectedValueException('Input should only have RequestId');
110
        }
111
112
        // make the URL for this request
113 1
        $url = sprintf('%s/BankIDMobileLogin/Start', $this->getBaseUrl());
114
115
        // get the headers for this request
116 1
        $headers = $this->headers->make('POST', $url, $body);
117
118
        // get the response
119 1
        $response = $this->client->post($url, [
120 1
            'headers' => $headers,
121 1
            'json' => $body,
122
        ]);
123
124
        // return the response
125 1
        return $response;
126
    }
127
128
    /**
129
     * Invalidate the login request to prevent
130
     * any replay attacks.
131
     *
132
     * @param  array  $body
133
     * @return object
134
     */
135 1
    public function invalidateLogin(array $body)
136
    {
137
        // let the user know that if he is sending some data
138
        // it should be RequestId. Nothing else goes here.
139 1
        if (! isset($body['RequestId'])) {
140 1
            throw new BadMethodCallException('Input should have RequestId');
141 1
        } elseif (count($body) > 1) {
142
            throw new UnexpectedValueException('Input should only have RequestId');
143
        }
144
145
        // make the URL for this request
146 1
        $url = sprintf('%s/InvalidateLogin', $this->getBaseUrl());
147
148
        // get the headers for this request
149 1
        $headers = $this->headers->make('PUT', $url, $body);
150
151
        // get the response
152 1
        $response = $this->client->put($url, [
153 1
            'headers' => $headers,
154 1
            'json' => $body,
155
        ]);
156
157
        // return the response
158 1
        return $response;
159
    }
160
}
161