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/saml/Attribute.php (2 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\saml;
6
7
use DOMElement;
8
use SimpleSAML\SAML2\Assert\Assert;
9
use SimpleSAML\SAML2\Constants as C;
10
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
11
use SimpleSAML\SAML2\Type\SAMLStringValue;
12
use SimpleSAML\SAML2\XML\EncryptableElementTrait;
13
use SimpleSAML\XML\ExtendableAttributesTrait;
14
use SimpleSAML\XML\SchemaValidatableElementInterface;
15
use SimpleSAML\XML\SchemaValidatableElementTrait;
16
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
17
use SimpleSAML\XMLSchema\XML\Constants\NS;
18
use SimpleSAML\XMLSecurity\Backend\EncryptionBackend;
19
use SimpleSAML\XMLSecurity\XML\EncryptableElementInterface;
20
21
use function strval;
22
23
/**
24
 * Class representing SAML 2 Attribute.
25
 *
26
 * @package simplesamlphp/saml2
27
 */
28
class Attribute extends AbstractSamlElement implements
29
    EncryptableElementInterface,
30
    SchemaValidatableElementInterface
31
{
32
    use EncryptableElementTrait;
0 ignored issues
show
The trait SimpleSAML\SAML2\XML\EncryptableElementTrait requires the property $ownerDocument which is not provided by SimpleSAML\SAML2\XML\saml\Attribute.
Loading history...
33
    use ExtendableAttributesTrait;
34
    use SchemaValidatableElementTrait;
35
36
37
    /** The namespace-attribute for the xs:anyAttribute element */
38
    public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;
39
40
41
    /**
42
     * Initialize an Attribute.
43
     *
44
     * @param \SimpleSAML\SAML2\Type\SAMLStringValue $name
45
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $nameFormat
46
     * @param \SimpleSAML\SAML2\Type\SAMLStringValue|null $friendlyName
47
     * @param \SimpleSAML\SAML2\XML\saml\AttributeValue[] $attributeValue
48
     * @param list<\SimpleSAML\XML\Attribute> $namespacedAttribute
0 ignored issues
show
The type SimpleSAML\SAML2\XML\saml\list 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...
49
     */
50
    public function __construct(
51
        protected SAMLStringValue $name,
52
        protected ?SAMLAnyURIValue $nameFormat = null,
53
        protected ?SAMLStringValue $friendlyName = null,
54
        protected array $attributeValue = [],
55
        array $namespacedAttribute = [],
56
    ) {
57
        Assert::maxCount($attributeValue, C::UNBOUNDED_LIMIT);
58
        Assert::allIsInstanceOf($attributeValue, AttributeValue::class, 'Invalid AttributeValue.');
59
60
        switch (strval($nameFormat)) {
61
            case C::NAMEFORMAT_URI:
62
                Assert::validURI(
63
                    strval($name),
64
                    sprintf("Attribute name `%s` does not match its declared format `%s`", $name, $nameFormat),
65
                );
66
                break;
67
            case C::NAMEFORMAT_BASIC:
68
                Assert::validNCName(
69
                    strval($name),
70
                    sprintf("Attribute name `%s` does not match its declared format `%s`", $name, $nameFormat),
71
                );
72
                break;
73
        }
74
75
        $this->setAttributesNS($namespacedAttribute);
76
    }
77
78
79
    /**
80
     * Collect the value of the Name-property
81
     *
82
     * @return \SimpleSAML\SAML2\Type\SAMLStringValue
83
     */
84
    public function getName(): SAMLStringValue
85
    {
86
        return $this->name;
87
    }
88
89
90
    /**
91
     * Collect the value of the NameFormat-property
92
     *
93
     * @return \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null
94
     */
95
    public function getNameFormat(): ?SAMLAnyURIValue
96
    {
97
        return $this->nameFormat;
98
    }
99
100
101
    /**
102
     * Collect the value of the FriendlyName-property
103
     *
104
     * @return \SimpleSAML\SAML2\Type\SAMLStringValue|null
105
     */
106
    public function getFriendlyName(): ?SAMLStringValue
107
    {
108
        return $this->friendlyName;
109
    }
110
111
112
    /**
113
     * Collect the value of the attributeValues-property
114
     *
115
     * @return \SimpleSAML\SAML2\XML\saml\AttributeValue[]
116
     */
117
    public function getAttributeValues(): array
118
    {
119
        return $this->attributeValue;
120
    }
121
122
123
    public function getEncryptionBackend(): ?EncryptionBackend
124
    {
125
        // return the encryption backend you want to use,
126
        // or null if you are fine with the default
127
        return null;
128
    }
129
130
131
    /**
132
     * Convert XML into a Attribute
133
     *
134
     * @param \DOMElement $xml The XML element we should load
135
     * @return static
136
     *
137
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
138
     *   if the qualified name of the supplied element is wrong
139
     * @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException
140
     *   if the supplied element is missing one of the mandatory attributes
141
     */
142
    public static function fromXML(DOMElement $xml): static
143
    {
144
        Assert::same($xml->localName, 'Attribute', InvalidDOMElementException::class);
145
        Assert::same($xml->namespaceURI, Attribute::NS, InvalidDOMElementException::class);
146
147
        return new static(
148
            self::getAttribute($xml, 'Name', SAMLStringValue::class),
149
            self::getOptionalAttribute($xml, 'NameFormat', SAMLAnyURIValue::class, null),
150
            self::getOptionalAttribute($xml, 'FriendlyName', SAMLStringValue::class, null),
151
            AttributeValue::getChildrenOfClass($xml),
152
            self::getAttributesNSFromXML($xml),
153
        );
154
    }
155
156
157
    /**
158
     * Convert this Attribute to XML.
159
     *
160
     * @param \DOMElement|null $parent The element we should append this Attribute to.
161
     * @return \DOMElement
162
     */
163
    public function toXML(?DOMElement $parent = null): DOMElement
164
    {
165
        $e = $this->instantiateParentElement($parent);
166
        $e->setAttribute('Name', strval($this->getName()));
167
168
        if ($this->getNameFormat() !== null) {
169
            $e->setAttribute('NameFormat', strval($this->getNameFormat()));
170
        }
171
172
        if ($this->getFriendlyName() !== null) {
173
            $e->setAttribute('FriendlyName', strval($this->getFriendlyName()));
174
        }
175
176
        foreach ($this->getAttributesNS() as $attr) {
177
            $attr->toXML($e);
178
        }
179
180
        foreach ($this->getAttributeValues() as $av) {
181
            $av->toXML($e);
182
        }
183
184
        return $e;
185
    }
186
}
187