Issues (85)

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