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\samlp; |
||||
| 6 | |||||
| 7 | use DOMElement; |
||||
| 8 | use SimpleSAML\SAML2\Assert\Assert; |
||||
| 9 | use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooHighException; |
||||
|
0 ignored issues
–
show
|
|||||
| 10 | use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooLowException; |
||||
|
0 ignored issues
–
show
The type
SimpleSAML\SAML2\Excepti...tVersionTooLowException 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 11 | use SimpleSAML\SAML2\Type\SAMLAnyURIValue; |
||||
| 12 | 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 13 | use SimpleSAML\SAML2\Type\SAMLStringValue; |
||||
| 14 | use SimpleSAML\SAML2\XML\IdentifierTrait; |
||||
| 15 | use SimpleSAML\SAML2\XML\saml\EncryptedID; |
||||
| 16 | use SimpleSAML\SAML2\XML\saml\Issuer; |
||||
| 17 | use SimpleSAML\SAML2\XML\saml\NameID; |
||||
| 18 | use SimpleSAML\XML\SchemaValidatableElementInterface; |
||||
| 19 | use SimpleSAML\XML\SchemaValidatableElementTrait; |
||||
| 20 | use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; |
||||
| 21 | use SimpleSAML\XMLSchema\Exception\MissingElementException; |
||||
| 22 | use SimpleSAML\XMLSchema\Exception\TooManyElementsException; |
||||
| 23 | use SimpleSAML\XMLSchema\Type\IDValue; |
||||
|
0 ignored issues
–
show
The type
SimpleSAML\XMLSchema\Type\IDValue 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 24 | use SimpleSAML\XMLSchema\Type\NCNameValue; |
||||
|
0 ignored issues
–
show
The type
SimpleSAML\XMLSchema\Type\NCNameValue 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 25 | use SimpleSAML\XMLSecurity\XML\ds\Signature; |
||||
| 26 | |||||
| 27 | use function array_pop; |
||||
| 28 | use function strval; |
||||
| 29 | |||||
| 30 | /** |
||||
| 31 | * Class for SAML 2 NameIDMappingResponse messages. |
||||
| 32 | * |
||||
| 33 | * @package simplesamlphp/saml2 |
||||
| 34 | */ |
||||
| 35 | class NameIDMappingResponse extends AbstractStatusResponse implements SchemaValidatableElementInterface |
||||
| 36 | { |
||||
| 37 | use IdentifierTrait; |
||||
| 38 | use SchemaValidatableElementTrait; |
||||
| 39 | |||||
| 40 | |||||
| 41 | /** |
||||
| 42 | * Constructor for SAML 2 response messages. |
||||
| 43 | * |
||||
| 44 | * @param \SimpleSAML\SAML2\XML\saml\NameID|\SimpleSAML\SAML2\XML\saml\EncryptedID $identifier |
||||
| 45 | * @param \SimpleSAML\XMLSchema\Type\IDValue $id |
||||
| 46 | * @param \SimpleSAML\SAML2\XML\samlp\Status $status |
||||
| 47 | * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue $issueInstant |
||||
| 48 | * @param \SimpleSAML\SAML2\XML\saml\Issuer|null $issuer |
||||
| 49 | * @param \SimpleSAML\XMLSchema\Type\NCNameValue|null $inResponseTo |
||||
| 50 | * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $destination |
||||
| 51 | * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $consent |
||||
| 52 | * @param \SimpleSAML\SAML2\XML\samlp\Extensions $extensions |
||||
| 53 | */ |
||||
| 54 | final public function __construct( |
||||
| 55 | NameID|EncryptedID $identifier, |
||||
| 56 | IDValue $id, |
||||
| 57 | Status $status, |
||||
| 58 | SAMLDateTimeValue $issueInstant, |
||||
| 59 | ?Issuer $issuer = null, |
||||
| 60 | ?NCNameValue $inResponseTo = null, |
||||
| 61 | ?SAMLAnyURIValue $destination = null, |
||||
| 62 | ?SAMLAnyURIValue $consent = null, |
||||
| 63 | ?Extensions $extensions = null, |
||||
|
0 ignored issues
–
show
The type
SimpleSAML\SAML2\XML\samlp\Extensions 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 64 | ) { |
||||
| 65 | $this->setIdentifier($identifier); |
||||
| 66 | |||||
| 67 | parent::__construct( |
||||
| 68 | $id, |
||||
| 69 | $status, |
||||
| 70 | $issueInstant, |
||||
| 71 | $issuer, |
||||
| 72 | $inResponseTo, |
||||
| 73 | $destination, |
||||
| 74 | $consent, |
||||
| 75 | $extensions, |
||||
| 76 | ); |
||||
| 77 | } |
||||
| 78 | |||||
| 79 | |||||
| 80 | /** |
||||
| 81 | * Convert XML into a NameIDMappingResponse element. |
||||
| 82 | * |
||||
| 83 | * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
||||
| 84 | * if the qualified name of the supplied element is wrong |
||||
| 85 | * @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException |
||||
| 86 | * if the supplied element is missing one of the mandatory attributes |
||||
| 87 | * @throws \SimpleSAML\XMLSchema\Exception\MissingElementException |
||||
| 88 | * if one of the mandatory child-elements is missing |
||||
| 89 | */ |
||||
| 90 | public static function fromXML(DOMElement $xml): static |
||||
| 91 | { |
||||
| 92 | Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
||||
| 93 | Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
||||
| 94 | |||||
| 95 | $version = self::getAttribute($xml, 'Version', SAMLStringValue::class); |
||||
| 96 | Assert::true(version_compare('2.0', strval($version), '<='), RequestVersionTooLowException::class); |
||||
| 97 | Assert::true(version_compare('2.0', strval($version), '>='), RequestVersionTooHighException::class); |
||||
| 98 | |||||
| 99 | $signature = Signature::getChildrenOfClass($xml); |
||||
| 100 | Assert::maxCount($signature, 1, 'Only one ds:Signature element is allowed.', TooManyElementsException::class); |
||||
| 101 | |||||
| 102 | $issuer = Issuer::getChildrenOfClass($xml); |
||||
| 103 | Assert::countBetween($issuer, 0, 1); |
||||
| 104 | |||||
| 105 | $status = Status::getChildrenOfClass($xml); |
||||
| 106 | Assert::minCount($status, 1, MissingElementException::class); |
||||
| 107 | Assert::maxCount($status, 1, TooManyElementsException::class); |
||||
| 108 | |||||
| 109 | $extensions = Extensions::getChildrenOfClass($xml); |
||||
| 110 | Assert::maxCount( |
||||
| 111 | $extensions, |
||||
| 112 | 1, |
||||
| 113 | 'Only one saml:Extensions element is allowed.', |
||||
| 114 | TooManyElementsException::class, |
||||
| 115 | ); |
||||
| 116 | |||||
| 117 | $response = new static( |
||||
| 118 | self::getIdentifierFromXML($xml), |
||||
|
0 ignored issues
–
show
It seems like
self::getIdentifierFromXML($xml) can also be of type null; however, parameter $identifier of SimpleSAML\SAML2\XML\sam...Response::__construct() does only seem to accept SimpleSAML\SAML2\XML\sam...L\SAML2\XML\saml\NameID, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 119 | self::getAttribute($xml, 'ID', IDValue::class), |
||||
| 120 | array_pop($status), |
||||
| 121 | self::getAttribute($xml, 'IssueInstant', SAMLDateTimeValue::class), |
||||
| 122 | empty($issuer) ? null : array_pop($issuer), |
||||
| 123 | self::getOptionalAttribute($xml, 'InResponseTo', NCNameValue::class, null), |
||||
| 124 | self::getOptionalAttribute($xml, 'Destination', SAMLAnyURIValue::class, null), |
||||
| 125 | self::getOptionalAttribute($xml, 'Consent', SAMLAnyURIValue::class, null), |
||||
| 126 | empty($extensions) ? null : array_pop($extensions), |
||||
| 127 | ); |
||||
| 128 | |||||
| 129 | if (!empty($signature)) { |
||||
| 130 | $response->setSignature($signature[0]); |
||||
| 131 | $response->messageContainedSignatureUponConstruction = true; |
||||
| 132 | $response->setXML($xml); |
||||
| 133 | } |
||||
| 134 | |||||
| 135 | return $response; |
||||
| 136 | } |
||||
| 137 | |||||
| 138 | |||||
| 139 | /** |
||||
| 140 | * Convert the response message to an XML element. |
||||
| 141 | */ |
||||
| 142 | protected function toUnsignedXML(?DOMElement $parent = null): DOMElement |
||||
| 143 | { |
||||
| 144 | $e = parent::toUnsignedXML($parent); |
||||
| 145 | |||||
| 146 | $this->getIdentifier()->toXML($e); |
||||
|
0 ignored issues
–
show
The method
toXML() does not exist on SimpleSAML\SAML2\XML\saml\IdentifierInterface. It seems like you code against a sub-type of said class. However, the method does not exist in SimpleSAML\SAML2\XML\saml\BaseIdentifierInterface. Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 147 | |||||
| 148 | return $e; |
||||
| 149 | } |
||||
| 150 | } |
||||
| 151 |
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