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/saml/AuthnStatement.php (1 issue)

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\Type\SAMLDateTimeValue;
0 ignored issues
show
The type SimpleSAML\SAML2\Type\SAMLDateTimeValue 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...
10
use SimpleSAML\SAML2\Type\SAMLStringValue;
11
use SimpleSAML\XML\SchemaValidatableElementInterface;
12
use SimpleSAML\XML\SchemaValidatableElementTrait;
13
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
14
use SimpleSAML\XMLSchema\Exception\MissingElementException;
15
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
16
17
use function array_pop;
18
19
/**
20
 * Class representing a SAML2 AuthnStatement
21
 *
22
 * @package simplesamlphp/saml2
23
 */
24
final class AuthnStatement extends AbstractStatementType implements SchemaValidatableElementInterface
25
{
26
    use SchemaValidatableElementTrait;
27
28
29
    /**
30
     * Initialize an AuthnStatement.
31
     *
32
     * @param \SimpleSAML\SAML2\XML\saml\AuthnContext $authnContext
33
     * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue $authnInstant
34
     * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $sessionNotOnOrAfter
35
     * @param \SimpleSAML\SAML2\Type\SAMLStringValue|null $sessionIndex
36
     * @param \SimpleSAML\SAML2\XML\saml\SubjectLocality|null $subjectLocality
37
     */
38
    public function __construct(
39
        protected AuthnContext $authnContext,
40
        protected SAMLDateTimeValue $authnInstant,
41
        protected ?SAMLDateTimeValue $sessionNotOnOrAfter = null,
42
        protected ?SAMLStringValue $sessionIndex = null,
43
        protected ?SubjectLocality $subjectLocality = null,
44
    ) {
45
        Assert::nullOrNotWhitespaceOnly($sessionIndex);
46
    }
47
48
49
    /**
50
     * Collect the value of the authnContext-property
51
     *
52
     * @return \SimpleSAML\SAML2\XML\saml\AuthnContext
53
     */
54
    public function getAuthnContext(): AuthnContext
55
    {
56
        return $this->authnContext;
57
    }
58
59
60
    /**
61
     * Collect the value of the AuthnInstant-property
62
     *
63
     * @return \SimpleSAML\SAML2\Type\SAMLDateTimeValue
64
     */
65
    public function getAuthnInstant(): SAMLDateTimeValue
66
    {
67
        return $this->authnInstant;
68
    }
69
70
71
    /**
72
     * Collect the value of the sessionNotOnOrAfter-property
73
     *
74
     * @return \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null
75
     */
76
    public function getSessionNotOnOrAfter(): ?SAMLDateTimeValue
77
    {
78
        return $this->sessionNotOnOrAfter;
79
    }
80
81
82
    /**
83
     * Collect the value of the sessionIndex-property
84
     *
85
     * @return \SimpleSAML\SAML2\Type\SAMLStringValue|null
86
     */
87
    public function getSessionIndex(): ?SAMLStringValue
88
    {
89
        return $this->sessionIndex;
90
    }
91
92
93
    /**
94
     * Collect the value of the subjectLocality-property
95
     *
96
     * @return \SimpleSAML\SAML2\XML\saml\SubjectLocality|null
97
     */
98
    public function getSubjectLocality(): ?SubjectLocality
99
    {
100
        return $this->subjectLocality;
101
    }
102
103
104
    /**
105
     * Convert XML into an AuthnStatement
106
     *
107
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
108
     *   if the qualified name of the supplied element is wrong
109
     * @throws \SimpleSAML\XMLSchema\Exception\MissingElementException
110
     *   if one of the mandatory child-elements is missing
111
     * @throws \Exception if the authentication instant is not a valid timestamp.
112
     */
113
    public static function fromXML(DOMElement $xml): static
114
    {
115
        Assert::same($xml->localName, 'AuthnStatement', InvalidDOMElementException::class);
116
        Assert::same($xml->namespaceURI, AuthnStatement::NS, InvalidDOMElementException::class);
117
118
        $authnContext = AuthnContext::getChildrenOfClass($xml);
119
        Assert::minCount(
120
            $authnContext,
121
            1,
122
            'Missing <saml:AuthnContext> in <saml:AuthnStatement>',
123
            MissingElementException::class,
124
        );
125
        Assert::maxCount(
126
            $authnContext,
127
            1,
128
            'More than one <saml:AuthnContext> in <saml:AuthnStatement>',
129
            TooManyElementsException::class,
130
        );
131
132
        $subjectLocality = SubjectLocality::getChildrenOfClass($xml);
133
134
        return new static(
135
            array_pop($authnContext),
136
            self::getAttribute($xml, 'AuthnInstant', SAMLDateTimeValue::class),
137
            self::getOptionalAttribute($xml, 'SessionNotOnOrAfter', SAMLDateTimeValue::class, null),
138
            self::getOptionalAttribute($xml, 'SessionIndex', SAMLStringValue::class, null),
139
            array_pop($subjectLocality),
140
        );
141
    }
142
143
144
    /**
145
     * Convert this AuthnStatement to XML.
146
     */
147
    public function toXML(?DOMElement $parent = null): DOMElement
148
    {
149
        $e = $this->instantiateParentElement($parent);
150
151
        if ($this->getSubjectLocality() !== null && !$this->getSubjectLocality()->isEmptyElement()) {
152
            $this->getSubjectLocality()->toXML($e);
153
        }
154
155
        $this->getAuthnContext()->toXML($e);
156
157
        $e->setAttribute('AuthnInstant', $this->getAuthnInstant()->getValue());
158
159
        if ($this->getSessionIndex() !== null) {
160
            $e->setAttribute('SessionIndex', $this->getSessionIndex()->getValue());
161
        }
162
163
        if ($this->getSessionNotOnOrAfter() !== null) {
164
            $e->setAttribute('SessionNotOnOrAfter', $this->getSessionNotOnOrAfter()->getValue());
165
        }
166
167
        return $e;
168
    }
169
}
170