Issues (5)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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.

tests/src/Controller/DiscoPowerTest.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\Test\Module\discopower\Controller;
6
7
use PHPUnit\Framework\Attributes\CoversClass;
0 ignored issues
show
The type PHPUnit\Framework\Attributes\CoversClass was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use SimpleSAML\Configuration;
9
use SimpleSAML\Error;
10
use SimpleSAML\Module\discopower\Controller;
11
use SimpleSAML\Session;
12
use SimpleSAML\TestUtils\ClearStateTestCase;
13
use Symfony\Component\HttpFoundation\{Request, StreamedResponse};
14
15
/**
16
 * Set of tests for the controllers in the "discopower" module.
17
 */
18
#[CoversClass(Controller\DiscoPower::class)]
19
final class DiscoPowerTest extends ClearStateTestCase
20
{
21
    /** @var \SimpleSAML\Configuration */
22
    private static Configuration $discoconfig;
23
24
25
    /**
26
     * Set up for each test.
27
     */
28
    protected function setUp(): void
29
    {
30
        parent::setUp();
31
32
        $config = Configuration::loadFromArray(
33
            [
34
                'module.enable' => ['discopower' => true],
35
                'trusted.url.domains' => ['example.com'],
36
            ],
37
            '[ARRAY]',
38
            'simplesaml',
39
        );
40
41
        Configuration::setPreLoadedConfig($config, 'config.php');
42
43
        self::$discoconfig = Configuration::loadFromArray(
44
            [
45
                'defaulttab' => 0,
46
                'trusted.url.domains' => ['example.com'],
47
            ],
48
            '[ARRAY]',
49
            'simplesaml',
50
        );
51
    }
52
53
    public function testDiscoPowerNoDiscoParams(): void
54
    {
55
        $request = Request::create(
56
            '/disco.php',
57
            'GET',
58
        );
59
60
        $c = new Controller\DiscoPower();
61
62
        $this->expectException(Error\Error::class);
63
        $this->expectExceptionMessage("DISCOPARAMS");
64
        $c->main($request);
65
    }
66
67
    public function testDiscoPowerHasDiscoParams(): void
68
    {
69
        Configuration::setPreLoadedConfig(self::$discoconfig, 'module_discopower.php');
70
71
        $request = Request::create(
72
            '/disco.php',
73
            'GET',
74
        );
75
        $_GET = [
76
            'entityID' => 'https://example.com/sp',
77
            'return' => 'https://example.com/acs',
78
            'returnIDParam' => 'idpentityid',
79
        ];
80
        $_SERVER['REQUEST_URI'] = '/disco.php';
81
82
        $c = new Controller\DiscoPower();
83
84
        $r = $c->main($request);
85
        $this->assertInstanceOf(StreamedResponse::class, $r);
86
        $this->assertTrue($r->isSuccessful());
87
    }
88
89
    public function testDiscoPowerReturnUrlDisallowed(): void
90
    {
91
        Configuration::setPreLoadedConfig(self::$discoconfig, 'module_discopower.php');
92
93
        $request = Request::create(
94
            '/disco.php',
95
            'GET',
96
        );
97
        $_GET = [
98
            'entityID' => 'https://example.com/sp',
99
            'return' => 'https://attacker.example.org/acs',
100
            'returnIDParam' => 'idpentityid',
101
        ];
102
        $_SERVER['REQUEST_URI'] = '/disco.php';
103
104
        $c = new Controller\DiscoPower();
105
106
        // All exceptions in this stage are flattened into DISCOPARAMS
107
        $this->expectException(Error\Error::class);
108
        $this->expectExceptionMessage("DISCOPARAMS");
109
        $c->main($request);
110
    }
111
112
    public function testTablistJson(): void
113
    {
114
        $session = Session::getSessionFromRequest();
115
        $session->setData('discopower:tabList', 'faventry', 'http://example.org/idp');
116
        $session->setData('discopower:tabList', 'tabs', ['Frankrijk', 'Nederland', 'Duitsland']);
117
        $session->setData('discopower:tabList', 'defaulttab', 'Nederland');
118
119
        $request = Request::create(
120
            '/tablist',
121
            'GET',
122
        );
123
124
        $c = new Controller\DiscoPower();
125
126
        $r = $c->tablist($request);
127
        $this->assertTrue($r->isSuccessful());
128
        $this->assertEquals('application/json', $r->headers->get('Content-Type'));
129
        $this->assertEquals(
130
            '{"faventry":"http:\/\/example.org\/idp","default":"Nederland","tabs":["Frankrijk","Nederland","Duitsland"]}',
131
            $r->getContent(),
132
        );
133
134
        $request = Request::create(
135
            '/tablist',
136
            'GET',
137
            ['callback' => 'aapnoot'],
138
        );
139
140
        $c = new Controller\DiscoPower();
141
142
        $r = $c->tablist($request);
143
        $this->assertTrue($r->isSuccessful());
144
        $this->assertEquals('text/javascript', $r->headers->get('Content-Type'));
145
        $this->assertEquals(
146
            '/**/aapnoot({"faventry":"http:\/\/example.org\/idp","default":"Nederland","tabs":["Frankrijk","Nederland","Duitsland"]});',
147
            $r->getContent(),
148
        );
149
    }
150
151
    public function testTablistJsonNoSession(): void
152
    {
153
        $request = Request::create(
154
            '/tablist',
155
            'GET',
156
        );
157
158
        $c = new Controller\DiscoPower();
159
160
        $this->expectException(Error\Exception::class);
161
        $this->expectExceptionMessage("Could not get tab list from session");
162
        $c->tablist($request);
163
    }
164
165
    public function testTablistJsonUnsafeCallback(): void
166
    {
167
        $session = Session::getSessionFromRequest();
168
        $session->setData('discopower:tabList', 'faventry', 'http://example.org/idp');
169
        $session->setData('discopower:tabList', 'tabs', ['Frankrijk', 'Nederland', 'Duitsland']);
170
        $session->setData('discopower:tabList', 'defaulttab', 'Nederland');
171
172
        $request = Request::create(
173
            '/tablist',
174
            'GET',
175
            ['callback' => 'alert("hallo")'],
176
        );
177
178
        $c = new Controller\DiscoPower();
179
180
        $this->expectException(Error\Exception::class);
181
        $this->expectExceptionMessage("Unsafe JSONP callback");
182
        $c->tablist($request);
183
    }
184
}
185