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/mdui/Logo.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\mdui;
6
7
use DOMElement;
8
use SimpleSAML\SAML2\Assert\Assert;
9
use SimpleSAML\SAML2\Exception\ArrayValidationException;
10
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
11
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
12
use SimpleSAML\XML\ArrayizableElementInterface;
13
use SimpleSAML\XML\SchemaValidatableElementInterface;
14
use SimpleSAML\XML\SchemaValidatableElementTrait;
15
use SimpleSAML\XML\TypedTextContentTrait;
16
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
17
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
18
use SimpleSAML\XMLSchema\Type\LanguageValue;
19
use SimpleSAML\XMLSchema\Type\PositiveIntegerValue;
20
21
/**
22
 * Class for handling the Logo metadata extensions for login and discovery user interface
23
 *
24
 * @link: http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-metadata-ui/v1.0/sstc-saml-metadata-ui-v1.0.pdf
25
 * @package simplesamlphp/saml2
26
 */
27
final class Logo extends AbstractMduiElement implements
28
    ArrayizableElementInterface,
29
    SchemaValidatableElementInterface
30
{
31
    use SchemaValidatableElementTrait;
32
    use TypedTextContentTrait;
33
34
35
    public const string TEXTCONTENT_TYPE = SAMLAnyURIValue::class;
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 35 at column 24
Loading history...
36
37
38
    private static string $scheme_regex = '/^(data|http[s]?[:])/i';
39
40
41
    /**
42
     * Initialize a Logo.
43
     *
44
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue $url
45
     * @param \SimpleSAML\XMLSchema\Type\PositiveIntegerValue $height
46
     * @param \SimpleSAML\XMLSchema\Type\PositiveIntegerValue $width
47
     * @param \SimpleSAML\XMLSchema\Type\LanguageValue|null $lang
48
     */
49
    public function __construct(
50
        SAMLAnyURIValue $url,
51
        protected PositiveIntegerValue $height,
52
        protected PositiveIntegerValue $width,
53
        protected ?LanguageValue $lang = null,
54
    ) {
55
        $this->setContent($url);
56
    }
57
58
59
    /**
60
     * Validate the content of the element.
61
     *
62
     * @param string $content  The value to go in the XML textContent
63
     *
64
     * @throws \InvalidArgumentException on failure
65
     */
66
    protected function validateContent(string $content): void
67
    {
68
        Assert::validURI($content, SchemaViolationException::class);
69
        Assert::regex(self::$scheme_regex, $content, ProtocolViolationException::class);
70
    }
71
72
73
    /**
74
     * Collect the value of the lang-property
75
     *
76
     * @return \SimpleSAML\XMLSchema\Type\LanguageValue|null
77
     */
78
    public function getLanguage(): ?LanguageValue
79
    {
80
        return $this->lang;
81
    }
82
83
84
    /**
85
     * Collect the value of the height-property
86
     *
87
     * @return \SimpleSAML\XMLSchema\Type\PositiveIntegerValue
88
     */
89
    public function getHeight(): PositiveIntegerValue
90
    {
91
        return $this->height;
92
    }
93
94
95
    /**
96
     * Collect the value of the width-property
97
     *
98
     * @return \SimpleSAML\XMLSchema\Type\PositiveIntegerValue
99
     */
100
    public function getWidth(): PositiveIntegerValue
101
    {
102
        return $this->width;
103
    }
104
105
106
    /**
107
     * Convert XML into a Logo
108
     *
109
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
110
     *   if the qualified name of the supplied element is wrong
111
     * @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException
112
     *   if the supplied element is missing one of the mandatory attributes
113
     */
114
    public static function fromXML(DOMElement $xml): static
115
    {
116
        Assert::same($xml->localName, 'Logo', InvalidDOMElementException::class);
117
        Assert::same($xml->namespaceURI, Logo::NS, InvalidDOMElementException::class);
118
        Assert::stringNotEmpty($xml->textContent, 'Missing url value for Logo.');
119
120
        $Url = SAMLAnyURIValue::fromString($xml->textContent);
121
        $Width = self::getAttribute($xml, 'width', PositiveIntegerValue::class);
122
        $Height = self::getAttribute($xml, 'height', PositiveIntegerValue::class);
123
        $lang = self::getOptionalAttribute($xml, 'xml:lang', LanguageValue::class, null);
124
125
        return new static($Url, $Height, $Width, $lang);
126
    }
127
128
129
    /**
130
     * Convert this Logo to XML.
131
     */
132
    public function toXML(?DOMElement $parent = null): DOMElement
133
    {
134
        $e = $this->instantiateParentElement($parent);
135
        $e->textContent = $this->getContent()->getValue();
136
        $e->setAttribute('height', $this->getHeight()->getValue());
137
        $e->setAttribute('width', $this->getWidth()->getValue());
138
139
        if ($this->getLanguage() !== null) {
140
            $e->setAttribute('xml:lang', $this->getLanguage()->getValue());
141
        }
142
143
        return $e;
144
    }
145
146
147
    /**
148
     * Create a class from an array
149
     *
150
     * @param array{
151
     *   'url': string,
152
     *   'height'?: int,
153
     *   'width'?: int,
154
     *   'lang'?: string,
155
     * } $data
156
     */
157
    public static function fromArray(array $data): static
158
    {
159
        $data = self::processArrayContents($data);
160
161
        return new static(
162
            SAMLAnyURIValue::fromString($data['url']),
163
            PositiveIntegerValue::fromInteger($data['height']),
164
            PositiveIntegerValue::fromInteger($data['width']),
165
            $data['lang'] !== null ? LanguageValue::fromString($data['lang']) : null,
166
        );
167
    }
168
169
170
    /**
171
     * Validates an array representation of this object and returns the same array with
172
     * rationalized keys (casing) and parsed sub-elements.
173
     *
174
     * @param array{
175
     *   'url': string,
176
     *   'height'?: int,
177
     *   'width'?: int,
178
     *   'lang'?: string,
179
     * } $data
180
     * @return array{
181
     *   'url': string,
182
     *   'height'?: int,
183
     *   'width'?: int,
184
     *   'lang'?: string,
185
     * }
186
     */
187
    private static function processArrayContents(array $data): array
188
    {
189
        $data = array_change_key_case($data, CASE_LOWER);
190
191
        // Make sure the array keys are known for this kind of object
192
        Assert::allOneOf(
193
            array_keys($data),
194
            [
195
                'url',
196
                'height',
197
                'width',
198
                'lang',
199
            ],
200
            ArrayValidationException::class,
201
        );
202
203
        Assert::keyExists($data, 'url', ArrayValidationException::class);
204
        Assert::keyExists($data, 'height', ArrayValidationException::class);
205
        Assert::keyExists($data, 'width', ArrayValidationException::class);
206
207
        Assert::integer($data['height'], ArrayValidationException::class);
208
        Assert::integer($data['width'], ArrayValidationException::class);
209
210
        $retval = [
211
            'url' => $data['url'],
212
            'height' => $data['height'],
213
            'width' => $data['width'],
214
        ];
215
216
        if (array_key_exists('lang', $data)) {
217
            Assert::string($data['lang'], ArrayValidationException::class);
218
            $retval['lang'] = $data['lang'];
219
        }
220
221
        return $retval;
222
    }
223
224
225
    /**
226
     * Create an array from this class
227
     *
228
     * @return array{
229
     *   'url': string,
230
     *   'height'?: int,
231
     *   'width'?: int,
232
     *   'lang'?: string,
233
     * }
234
     */
235
    public function toArray(): array
236
    {
237
        $lang = $this->getLanguage()?->getValue();
238
239
        return [
240
            'url' => $this->getContent()->getValue(),
241
            'width' => $this->getWidth()->toInteger(),
242
            'height' => $this->getHeight()->toInteger(),
243
        ] + (isset($lang) ? ['lang' => $lang] : []);
244
    }
245
}
246