Issues (538)

Security Analysis    no request data  

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.

src/XML/samlp/NameIDPolicy.php (4 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\samlp;
6
7
use DOMElement;
8
use SimpleSAML\SAML2\Assert\Assert;
9
use SimpleSAML\SAML2\Exception\ArrayValidationException;
10
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
11
use SimpleSAML\SAML2\Type\SAMLStringValue;
12
use SimpleSAML\XML\ArrayizableElementInterface;
13
use SimpleSAML\XML\SchemaValidatableElementInterface;
14
use SimpleSAML\XML\SchemaValidatableElementTrait;
15
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
16
use SimpleSAML\XMLSchema\Type\BooleanValue;
0 ignored issues
show
The type SimpleSAML\XMLSchema\Type\BooleanValue 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...
17
18
use function array_change_key_case;
19
use function array_filter;
20
use function array_key_exists;
21
use function array_keys;
22
use function var_export;
23
24
/**
25
 * Class for handling SAML2 NameIDPolicy.
26
 *
27
 * @package simplesamlphp/saml2
28
 */
29
final class NameIDPolicy extends AbstractSamlpElement implements
0 ignored issues
show
The type SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement 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...
30
    ArrayizableElementInterface,
31
    SchemaValidatableElementInterface
32
{
33
    use SchemaValidatableElementTrait;
34
35
36
    /**
37
     * Initialize a NameIDPolicy.
38
     *
39
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $Format
40
     * @param \SimpleSAML\SAML2\Type\SAMLStringValue|null $SPNameQualifier
41
     * @param \SimpleSAML\XMLSchema\Type\BooleanValue|null $AllowCreate
42
     */
43
    public function __construct(
44
        protected ?SAMLAnyURIValue $Format = null,
45
        protected ?SAMLStringValue $SPNameQualifier = null,
46
        protected ?BooleanValue $AllowCreate = null,
47
    ) {
48
    }
49
50
51
    /**
52
     * @return \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null
53
     */
54
    public function getFormat(): ?SAMLAnyURIValue
55
    {
56
        return $this->Format;
57
    }
58
59
60
    /**
61
     * @return \SimpleSAML\SAML2\Type\SAMLStringValue|null
62
     */
63
    public function getSPNameQualifier(): ?SAMLStringValue
64
    {
65
        return $this->SPNameQualifier;
66
    }
67
68
69
    /**
70
     * @return \SimpleSAML\XMLSchema\Type\BooleanValue|null
71
     */
72
    public function getAllowCreate(): ?BooleanValue
73
    {
74
        return $this->AllowCreate;
75
    }
76
77
78
    /**
79
     * Test if an object, at the state it's in, would produce an empty XML-element
80
     */
81
    public function isEmptyElement(): bool
82
    {
83
        return empty($this->getFormat())
84
            && empty($this->getSPNameQualifier())
85
            && empty($this->getAllowCreate());
86
    }
87
88
89
    /**
90
     * Convert XML into a NameIDPolicy
91
     *
92
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
93
     *   if the qualified name of the supplied element is wrong
94
     */
95
    public static function fromXML(DOMElement $xml): static
96
    {
97
        Assert::same($xml->localName, 'NameIDPolicy', InvalidDOMElementException::class);
98
        Assert::same($xml->namespaceURI, NameIDPolicy::NS, InvalidDOMElementException::class);
99
100
        $Format = self::getOptionalAttribute($xml, 'Format', SAMLAnyURIValue::class, null);
101
        $SPNameQualifier = self::getOptionalAttribute($xml, 'SPNameQualifier', SAMLStringValue::class, null);
102
        $AllowCreate = self::getOptionalAttribute($xml, 'AllowCreate', BooleanValue::class, null);
103
104
        return new static(
105
            $Format,
106
            $SPNameQualifier,
107
            $AllowCreate,
108
        );
109
    }
110
111
112
    /**
113
     * Convert this NameIDPolicy to XML.
114
     */
115
    public function toXML(?DOMElement $parent = null): DOMElement
116
    {
117
        $e = $this->instantiateParentElement($parent);
118
119
        if ($this->getFormat() !== null) {
120
            $e->setAttribute('Format', $this->getFormat()->getValue());
121
        }
122
123
        if ($this->getSPNameQualifier() !== null) {
124
            $e->setAttribute('SPNameQualifier', $this->getSPNameQualifier()->getValue());
125
        }
126
127
        if ($this->getAllowCreate() !== null) {
128
            $e->setAttribute('AllowCreate', var_export($this->getAllowCreate()->toBoolean(), true));
129
        }
130
131
        return $e;
132
    }
133
134
135
    /**
136
     * Create a class from an array
137
     *
138
     * @param array{
139
     *   'Format'?: string,
140
     *   'SPNameQualifier'?: string,
141
     *   'AllowCreate'?: string,
142
     * } $data
143
     */
144
    public static function fromArray(array $data): static
145
    {
146
        $data = self::processArrayContents($data);
147
148
        return new static(
149
            $data['Format'] !== null ? SAMLAnyURIValue::fromString($data['Format']) : null,
150
            $data['SPNameQualifier'] !== null ? SAMLStringValue::fromString($data['SPNameQualifier']) : null,
151
            $data['AllowCreate'] !== null ? BooleanValue::fromBoolean($data['AllowCreate']) : null,
152
        );
153
    }
154
155
156
    /**
157
     * Validates an array representation of this object and returns the same array with
158
     * rationalized keys (casing) and parsed sub-elements.
159
     *
160
     * @param array{
161
     *   'Format'?: string,
162
     *   'SPNameQualifier'?: string,
163
     *   'AllowCreate'?: string,
164
     * } $data
165
     * @return array{
0 ignored issues
show
Documentation Bug introduced by
The doc comment array{ at position 2 could not be parsed: the token is null at position 2.
Loading history...
166
     *   'Format'?: string,
167
     *   'SPNameQualifier'?: string,
168
     *   'AllowCreate'?: string,
169
     * }
170
     */
171
    private static function processArrayContents(array $data): array
172
    {
173
        $data = array_change_key_case($data, CASE_LOWER);
174
175
        // Make sure the array keys are known for this kind of object
176
        Assert::allOneOf(
177
            array_keys($data),
178
            [
179
                'format',
180
                'spnamequalifier',
181
                'allowcreate',
182
            ],
183
            ArrayValidationException::class,
184
        );
185
186
        Assert::string($data['format'], ArrayValidationException::class);
187
188
        $retval = ['Format' => $data['format']];
189
190
        if (array_key_exists('spnamequalifier', $data)) {
191
            Assert::string($data['spnamequalifier'], ArrayValidationException::class);
192
            $retval['SPNameQualifier'] = $data['spnamequalifier'];
193
        }
194
195
        if (array_key_exists('allowcreate', $data)) {
196
            Assert::boolean($data['allowcreate'], ArrayValidationException::class);
197
            $retval['AllowCreate'] = $data['allowcreate'];
198
        }
199
200
        return $retval;
201
    }
202
203
204
    /**
205
     * Create an array from this class
206
     *
207
     * @return array{
0 ignored issues
show
Documentation Bug introduced by
The doc comment array{ at position 2 could not be parsed: the token is null at position 2.
Loading history...
208
     *   'Format'?: string,
209
     *   'SPNameQualifier'?: string,
210
     *   'AllowCreate'?: string,
211
     * }
212
     */
213
    public function toArray(): array
214
    {
215
        $data = [
216
            'Format' => $this->getFormat()?->getValue(),
217
            'SPNameQualifier' => $this->getSPNameQualifier()?->getValue(),
218
            'AllowCreate' => $this->getAllowCreate()?->toBoolean(),
219
        ];
220
221
        return array_filter($data);
222
    }
223
}
224