Issues (99)

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)

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;
0 ignored issues
show
The trait SimpleSAML\XML\TypedTextContentTrait requires some properties which are not provided by SimpleSAML\SAML2\XML\mdui\Logo: $localName, $namespaceURI
Loading history...
33
34
35
    /** @var string */
36
    public const TEXTCONTENT_TYPE = SAMLAnyURIValue::class;
37
38
39
    /** @var string */
40
    private static string $scheme_regex = '/^(data|http[s]?[:])/i';
41
42
43
    /**
44
     * Initialize a Logo.
45
     *
46
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue $url
47
     * @param \SimpleSAML\XMLSchema\Type\PositiveIntegerValue $height
48
     * @param \SimpleSAML\XMLSchema\Type\PositiveIntegerValue $width
49
     * @param \SimpleSAML\XMLSchema\Type\LanguageValue|null $lang
50
     */
51
    public function __construct(
52
        SAMLAnyURIValue $url,
53
        protected PositiveIntegerValue $height,
54
        protected PositiveIntegerValue $width,
55
        protected ?LanguageValue $lang = null,
56
    ) {
57
        $this->setContent($url);
58
    }
59
60
61
    /**
62
     * Validate the content of the element.
63
     *
64
     * @param string $content  The value to go in the XML textContent
65
     * @throws \InvalidArgumentException on failure
66
     * @return void
67
     */
68
    protected function validateContent(string $content): void
69
    {
70
        Assert::validURI($content, SchemaViolationException::class);
71
        Assert::regex(self::$scheme_regex, $content, ProtocolViolationException::class);
72
    }
73
74
75
    /**
76
     * Collect the value of the lang-property
77
     *
78
     * @return \SimpleSAML\XMLSchema\Type\LanguageValue|null
79
     */
80
    public function getLanguage(): ?LanguageValue
81
    {
82
        return $this->lang;
83
    }
84
85
86
    /**
87
     * Collect the value of the height-property
88
     *
89
     * @return \SimpleSAML\XMLSchema\Type\PositiveIntegerValue
90
     */
91
    public function getHeight(): PositiveIntegerValue
92
    {
93
        return $this->height;
94
    }
95
96
97
    /**
98
     * Collect the value of the width-property
99
     *
100
     * @return \SimpleSAML\XMLSchema\Type\PositiveIntegerValue
101
     */
102
    public function getWidth(): PositiveIntegerValue
103
    {
104
        return $this->width;
105
    }
106
107
108
    /**
109
     * Convert XML into a Logo
110
     *
111
     * @param \DOMElement $xml The XML element we should load
112
     * @return static
113
     *
114
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
115
     *   if the qualified name of the supplied element is wrong
116
     * @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException
117
     *   if the supplied element is missing one of the mandatory attributes
118
     */
119
    public static function fromXML(DOMElement $xml): static
120
    {
121
        Assert::same($xml->localName, 'Logo', InvalidDOMElementException::class);
122
        Assert::same($xml->namespaceURI, Logo::NS, InvalidDOMElementException::class);
123
        Assert::stringNotEmpty($xml->textContent, 'Missing url value for Logo.');
124
125
        $Url = SAMLAnyURIValue::fromString($xml->textContent);
126
        $Width = self::getAttribute($xml, 'width', PositiveIntegerValue::class);
127
        $Height = self::getAttribute($xml, 'height', PositiveIntegerValue::class);
128
        $lang = self::getOptionalAttribute($xml, 'xml:lang', LanguageValue::class, null);
129
130
        return new static($Url, $Height, $Width, $lang);
131
    }
132
133
134
    /**
135
     * Convert this Logo to XML.
136
     *
137
     * @param \DOMElement|null $parent The element we should append this Logo to.
138
     * @return \DOMElement
139
     */
140
    public function toXML(?DOMElement $parent = null): DOMElement
141
    {
142
        $e = $this->instantiateParentElement($parent);
143
        $e->textContent = $this->getContent()->getValue();
144
        $e->setAttribute('height', $this->getHeight()->getValue());
145
        $e->setAttribute('width', $this->getWidth()->getValue());
146
147
        if ($this->getLanguage() !== null) {
148
            $e->setAttribute('xml:lang', $this->getLanguage()->getValue());
149
        }
150
151
        return $e;
152
    }
153
154
155
    /**
156
     * Create a class from an array
157
     *
158
     * @param array $data
159
     * @return static
160
     */
161
    public static function fromArray(array $data): static
162
    {
163
        $data = self::processArrayContents($data);
164
165
        return new static(
166
            SAMLAnyURIValue::fromString($data['url']),
167
            PositiveIntegerValue::fromInteger($data['height']),
168
            PositiveIntegerValue::fromInteger($data['width']),
169
            $data['lang'] !== null ? LanguageValue::fromString($data['lang']) : null,
170
        );
171
    }
172
173
174
    /**
175
     * Validates an array representation of this object and returns the same array with
176
     * rationalized keys (casing) and parsed sub-elements.
177
     *
178
     * @param array $data
179
     * @return array $data
180
     */
181
    private static function processArrayContents(array $data): array
182
    {
183
        $data = array_change_key_case($data, CASE_LOWER);
184
185
        // Make sure the array keys are known for this kind of object
186
        Assert::allOneOf(
187
            array_keys($data),
188
            [
189
                'url',
190
                'height',
191
                'width',
192
                'lang',
193
            ],
194
            ArrayValidationException::class,
195
        );
196
197
        Assert::keyExists($data, 'url', ArrayValidationException::class);
198
        Assert::keyExists($data, 'height', ArrayValidationException::class);
199
        Assert::keyExists($data, 'width', ArrayValidationException::class);
200
201
        Assert::integer($data['height'], ArrayValidationException::class);
202
        Assert::integer($data['width'], ArrayValidationException::class);
203
204
        $retval = [
205
            'url' => $data['url'],
206
            'height' => $data['height'],
207
            'width' => $data['width'],
208
        ];
209
210
        if (array_key_exists('lang', $data)) {
211
            Assert::string($data['lang'], ArrayValidationException::class);
212
            $retval['lang'] = $data['lang'];
213
        }
214
215
        return $retval;
216
    }
217
218
219
    /**
220
     * Create an array from this class
221
     *
222
     * @return array
223
     */
224
    public function toArray(): array
225
    {
226
        $lang = $this->getLanguage()?->getValue();
227
228
        return [
229
            'url' => $this->getContent()->getValue(),
230
            'width' => $this->getWidth()->toInteger(),
231
            'height' => $this->getHeight()->toInteger(),
232
        ] + (isset($lang) ? ['lang' => $lang] : []);
233
    }
234
}
235