simplesamlphp /
saml2
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 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
|
|||
| 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 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths