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\saml\Issuer; |
||
| 15 | use SimpleSAML\XML\SchemaValidatableElementInterface; |
||
| 16 | use SimpleSAML\XML\SchemaValidatableElementTrait; |
||
| 17 | use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; |
||
| 18 | use SimpleSAML\XMLSchema\Exception\MissingElementException; |
||
| 19 | use SimpleSAML\XMLSchema\Exception\TooManyElementsException; |
||
| 20 | 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...
|
|||
| 21 | use SimpleSAML\XMLSecurity\XML\ds\Signature; |
||
| 22 | |||
| 23 | use function array_pop; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * The Artifact is part of the SAML 2.0 IdP code, and it builds an artifact object. |
||
| 27 | * I am using strings, because I find them easier to work with. |
||
| 28 | * I want to use this, to be consistent with the other saml2_requests |
||
| 29 | * |
||
| 30 | * @package simplesamlphp/saml2 |
||
| 31 | */ |
||
| 32 | class ArtifactResolve extends AbstractRequest implements SchemaValidatableElementInterface |
||
| 33 | { |
||
| 34 | use SchemaValidatableElementTrait; |
||
| 35 | |||
| 36 | |||
| 37 | /** |
||
| 38 | * Initialize an ArtifactResolve. |
||
| 39 | * |
||
| 40 | * @param \SimpleSAML\XMLSchema\Type\IDValue $id |
||
| 41 | * @param \SimpleSAML\SAML2\XML\samlp\Artifact $artifact |
||
| 42 | * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue $issueInstant |
||
| 43 | * @param \SimpleSAML\SAML2\XML\saml\Issuer|null $issuer |
||
| 44 | * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $destination |
||
| 45 | * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $consent |
||
| 46 | * @param \SimpleSAML\SAML2\XML\samlp\Extensions $extensions |
||
| 47 | * |
||
| 48 | * @throws \Exception |
||
| 49 | */ |
||
| 50 | final public function __construct( |
||
| 51 | IDValue $id, |
||
| 52 | protected Artifact $artifact, |
||
| 53 | SAMLDateTimeValue $issueInstant, |
||
| 54 | ?Issuer $issuer = null, |
||
| 55 | ?SAMLAnyURIValue $destination = null, |
||
| 56 | ?SAMLAnyURIValue $consent = null, |
||
| 57 | ?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...
|
|||
| 58 | ) { |
||
| 59 | parent::__construct($id, $issuer, $issueInstant, $destination, $consent, $extensions); |
||
| 60 | } |
||
| 61 | |||
| 62 | |||
| 63 | /** |
||
| 64 | * Retrieve the Artifact in this response. |
||
| 65 | */ |
||
| 66 | public function getArtifact(): Artifact |
||
| 67 | { |
||
| 68 | return $this->artifact; |
||
| 69 | } |
||
| 70 | |||
| 71 | |||
| 72 | /** |
||
| 73 | * Create a class from XML |
||
| 74 | * |
||
| 75 | * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
||
| 76 | * if the qualified name of the supplied element is wrong |
||
| 77 | * @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException |
||
| 78 | * if the supplied element is missing one of the mandatory attributes |
||
| 79 | * @throws \SimpleSAML\XMLSchema\Exception\TooManyElementsException |
||
| 80 | * if too many child-elements of a type are specified |
||
| 81 | */ |
||
| 82 | public static function fromXML(DOMElement $xml): static |
||
| 83 | { |
||
| 84 | Assert::same($xml->localName, 'ArtifactResolve', InvalidDOMElementException::class); |
||
| 85 | Assert::same($xml->namespaceURI, ArtifactResolve::NS, InvalidDOMElementException::class); |
||
| 86 | |||
| 87 | $version = self::getAttribute($xml, 'Version', SAMLStringValue::class); |
||
| 88 | Assert::true(version_compare('2.0', $version->getValue(), '<='), RequestVersionTooLowException::class); |
||
| 89 | Assert::true(version_compare('2.0', $version->getValue(), '>='), RequestVersionTooHighException::class); |
||
| 90 | |||
| 91 | $issuer = Issuer::getChildrenOfClass($xml); |
||
| 92 | Assert::maxCount($issuer, 1); |
||
| 93 | |||
| 94 | $extensions = Extensions::getChildrenOfClass($xml); |
||
| 95 | Assert::maxCount( |
||
| 96 | $extensions, |
||
| 97 | 1, |
||
| 98 | 'Only one saml:Extensions element is allowed.', |
||
| 99 | TooManyElementsException::class, |
||
| 100 | ); |
||
| 101 | |||
| 102 | $signature = Signature::getChildrenOfClass($xml); |
||
| 103 | Assert::maxCount($signature, 1, 'Only one ds:Signature element is allowed.', TooManyElementsException::class); |
||
| 104 | |||
| 105 | $artifact = Artifact::getChildrenOfClass($xml); |
||
| 106 | Assert::minCount($artifact, 1, 'At least one samlp:Artifact is required.', MissingElementException::class); |
||
| 107 | Assert::maxCount($artifact, 1, 'Only one samlp:Artifact is allowed.', TooManyElementsException::class); |
||
| 108 | |||
| 109 | $resolve = new static( |
||
| 110 | self::getAttribute($xml, 'ID', IDValue::class), |
||
| 111 | $artifact[0], |
||
| 112 | self::getAttribute($xml, 'IssueInstant', SAMLDateTimeValue::class), |
||
| 113 | array_pop($issuer), |
||
| 114 | self::getOptionalAttribute($xml, 'Destination', SAMLAnyURIValue::class, null), |
||
| 115 | self::getOptionalAttribute($xml, 'Consent', SAMLAnyURIValue::class, null), |
||
| 116 | array_pop($extensions), |
||
| 117 | ); |
||
| 118 | |||
| 119 | if (!empty($signature)) { |
||
| 120 | $resolve->setSignature($signature[0]); |
||
| 121 | $resolve->setXML($xml); |
||
| 122 | } |
||
| 123 | |||
| 124 | return $resolve; |
||
| 125 | } |
||
| 126 | |||
| 127 | |||
| 128 | /** |
||
| 129 | * Convert this message to an unsigned XML document. |
||
| 130 | * This method does not sign the resulting XML document. |
||
| 131 | */ |
||
| 132 | protected function toUnsignedXML(?DOMElement $parent = null): DOMElement |
||
| 133 | { |
||
| 134 | Assert::notEmpty($this->artifact, 'Cannot convert ArtifactResolve to XML without an Artifact set.'); |
||
| 135 | |||
| 136 | $e = parent::toUnsignedXML($parent); |
||
| 137 | $this->getArtifact()->toXML($e); |
||
| 138 | |||
| 139 | return $e; |
||
| 140 | } |
||
| 141 | } |
||
| 142 |
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