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\Constants as C; |
||
|
0 ignored issues
–
show
|
|||
| 10 | use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooHighException; |
||
|
0 ignored issues
–
show
The type
SimpleSAML\SAML2\Excepti...VersionTooHighException 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\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...
|
|||
| 12 | use SimpleSAML\SAML2\Type\SAMLAnyURIValue; |
||
| 13 | 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...
|
|||
| 14 | use SimpleSAML\SAML2\Type\SAMLStringValue; |
||
| 15 | use SimpleSAML\SAML2\XML\saml\Action; |
||
|
0 ignored issues
–
show
The type
SimpleSAML\SAML2\XML\saml\Action 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...
|
|||
| 16 | use SimpleSAML\SAML2\XML\saml\Evidence; |
||
| 17 | use SimpleSAML\SAML2\XML\saml\Issuer; |
||
| 18 | use SimpleSAML\SAML2\XML\saml\Subject; |
||
| 19 | use SimpleSAML\XML\SchemaValidatableElementInterface; |
||
| 20 | use SimpleSAML\XML\SchemaValidatableElementTrait; |
||
| 21 | use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; |
||
| 22 | use SimpleSAML\XMLSchema\Exception\MissingElementException; |
||
| 23 | use SimpleSAML\XMLSchema\Exception\SchemaViolationException; |
||
| 24 | use SimpleSAML\XMLSchema\Exception\TooManyElementsException; |
||
| 25 | 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...
|
|||
| 26 | use SimpleSAML\XMLSecurity\XML\ds\Signature; |
||
| 27 | |||
| 28 | use function version_compare; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Class representing a SAML2 AuthzDecisionQuery |
||
| 32 | * |
||
| 33 | * @package simplesamlphp/saml2 |
||
| 34 | */ |
||
| 35 | final class AuthzDecisionQuery extends AbstractSubjectQuery implements SchemaValidatableElementInterface |
||
| 36 | { |
||
| 37 | use SchemaValidatableElementTrait; |
||
| 38 | |||
| 39 | |||
| 40 | /** |
||
| 41 | * Constructor for SAML 2 AuthzDecisionQuery. |
||
| 42 | * |
||
| 43 | * @param \SimpleSAML\XMLSchema\Type\IDValue $id |
||
| 44 | * @param \SimpleSAML\SAML2\XML\saml\Subject $subject |
||
| 45 | * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue $resource |
||
| 46 | * @param \SimpleSAML\SAML2\XML\saml\Action[] $action |
||
| 47 | * @param \SimpleSAML\SAML2\XML\saml\Evidence $evidence |
||
| 48 | * @param \SimpleSAML\SAML2\XML\saml\Issuer $issuer |
||
| 49 | * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue $issueInstant |
||
| 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 | public function __construct( |
||
| 55 | IDVaLue $id, |
||
| 56 | Subject $subject, |
||
| 57 | SAMLDateTimeValue $issueInstant, |
||
| 58 | protected SAMLAnyURIValue $resource, |
||
| 59 | protected array $action, |
||
| 60 | protected ?Evidence $evidence = null, |
||
| 61 | ?Issuer $issuer = null, |
||
| 62 | ?SAMLAnyURIValue $destination = null, |
||
| 63 | ?SAMLAnyURIValue $consent = null, |
||
| 64 | ?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...
|
|||
| 65 | ) { |
||
| 66 | Assert::maxCount($action, C::UNBOUNDED_LIMIT); |
||
| 67 | Assert::allIsInstanceOf($action, Action::class, SchemaViolationException::class); |
||
| 68 | |||
| 69 | parent::__construct($id, $subject, $issuer, $issueInstant, $destination, $consent, $extensions); |
||
| 70 | } |
||
| 71 | |||
| 72 | |||
| 73 | /** |
||
| 74 | * Collect the value of the resource-property |
||
| 75 | * |
||
| 76 | * @return \SimpleSAML\SAML2\Type\SAMLAnyURIValue |
||
| 77 | */ |
||
| 78 | public function getResource(): SAMLAnyURIValue |
||
| 79 | { |
||
| 80 | return $this->resource; |
||
| 81 | } |
||
| 82 | |||
| 83 | |||
| 84 | /** |
||
| 85 | * Collect the value of the action-property |
||
| 86 | * |
||
| 87 | * @return \SimpleSAML\SAML2\XML\saml\Action[] |
||
| 88 | */ |
||
| 89 | public function getAction(): array |
||
| 90 | { |
||
| 91 | return $this->action; |
||
| 92 | } |
||
| 93 | |||
| 94 | |||
| 95 | /** |
||
| 96 | * Collect the value of the evidence-property |
||
| 97 | * |
||
| 98 | * @return \SimpleSAML\SAML2\XML\saml\Evidence|null |
||
| 99 | */ |
||
| 100 | public function getEvidence(): ?Evidence |
||
| 101 | { |
||
| 102 | return $this->evidence; |
||
| 103 | } |
||
| 104 | |||
| 105 | |||
| 106 | /** |
||
| 107 | * Convert XML into an AuthzDecisionQuery |
||
| 108 | * |
||
| 109 | * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
||
| 110 | * if the qualified name of the supplied element is wrong |
||
| 111 | * @throws \SimpleSAML\XMLSchema\Exception\MissingElementException |
||
| 112 | * if one of the mandatory child-elements is missing |
||
| 113 | * @throws \Exception if the authentication instant is not a valid timestamp. |
||
| 114 | */ |
||
| 115 | public static function fromXML(DOMElement $xml): static |
||
| 116 | { |
||
| 117 | Assert::same($xml->localName, 'AuthzDecisionQuery', InvalidDOMElementException::class); |
||
| 118 | Assert::same($xml->namespaceURI, AuthzDecisionQuery::NS, InvalidDOMElementException::class); |
||
| 119 | |||
| 120 | $version = self::getAttribute($xml, 'Version', SAMLStringValue::class); |
||
| 121 | Assert::true(version_compare('2.0', $version->getValue(), '<='), RequestVersionTooLowException::class); |
||
| 122 | Assert::true(version_compare('2.0', $version->getValue(), '>='), RequestVersionTooHighException::class); |
||
| 123 | |||
| 124 | $issuer = Issuer::getChildrenOfClass($xml); |
||
| 125 | Assert::countBetween($issuer, 0, 1); |
||
| 126 | |||
| 127 | $extensions = Extensions::getChildrenOfClass($xml); |
||
| 128 | Assert::maxCount( |
||
| 129 | $extensions, |
||
| 130 | 1, |
||
| 131 | 'Only one saml:Extensions element is allowed.', |
||
| 132 | TooManyElementsException::class, |
||
| 133 | ); |
||
| 134 | |||
| 135 | $subject = Subject::getChildrenOfClass($xml); |
||
| 136 | Assert::notEmpty($subject, 'Missing subject in subject query.', MissingElementException::class); |
||
| 137 | Assert::maxCount( |
||
| 138 | $subject, |
||
| 139 | 1, |
||
| 140 | 'More than one <saml:Subject> in AuthzDecisionQuery', |
||
| 141 | TooManyElementsException::class, |
||
| 142 | ); |
||
| 143 | |||
| 144 | $action = Action::getChildrenOfClass($xml); |
||
| 145 | Assert::minCount( |
||
| 146 | $action, |
||
| 147 | 1, |
||
| 148 | 'Missing <saml:Action> in <saml:AuthzDecisionQuery>', |
||
| 149 | MissingElementException::class, |
||
| 150 | ); |
||
| 151 | |||
| 152 | $evidence = Evidence::getChildrenOfClass($xml); |
||
| 153 | Assert::maxCount( |
||
| 154 | $evidence, |
||
| 155 | 1, |
||
| 156 | 'Too many <saml:Evidence> in <saml:AuthzDecisionQuery>', |
||
| 157 | TooManyElementsException::class, |
||
| 158 | ); |
||
| 159 | |||
| 160 | $signature = Signature::getChildrenOfClass($xml); |
||
| 161 | Assert::maxCount($signature, 1, 'Only one ds:Signature element is allowed.', TooManyElementsException::class); |
||
| 162 | |||
| 163 | $request = new static( |
||
| 164 | self::getAttribute($xml, 'ID', IDValue::class), |
||
| 165 | array_pop($subject), |
||
| 166 | self::getAttribute($xml, 'IssueInstant', SAMLDateTimeValue::class), |
||
| 167 | self::getAttribute($xml, 'Resource', SAMLAnyURIValue::class), |
||
| 168 | $action, |
||
| 169 | array_pop($evidence), |
||
| 170 | array_pop($issuer), |
||
| 171 | self::getOptionalAttribute($xml, 'Destination', SAMLAnyURIValue::class, null), |
||
| 172 | self::getOptionalAttribute($xml, 'Consent', SAMLAnyURIValue::class, null), |
||
| 173 | array_pop($extensions), |
||
| 174 | ); |
||
| 175 | |||
| 176 | if (!empty($signature)) { |
||
| 177 | $request->setSignature($signature[0]); |
||
| 178 | $request->setXML($xml); |
||
| 179 | } |
||
| 180 | |||
| 181 | return $request; |
||
| 182 | } |
||
| 183 | |||
| 184 | |||
| 185 | /** |
||
| 186 | * Convert this message to an unsigned XML document. |
||
| 187 | * This method does not sign the resulting XML document. |
||
| 188 | */ |
||
| 189 | protected function toUnsignedXML(?DOMElement $parent = null): DOMElement |
||
| 190 | { |
||
| 191 | $e = parent::toUnsignedXML($parent); |
||
| 192 | $e->setAttribute('Resource', $this->getResource()->getValue()); |
||
| 193 | |||
| 194 | foreach ($this->getAction() as $action) { |
||
| 195 | $action->toXML($e); |
||
| 196 | } |
||
| 197 | |||
| 198 | if ($this->getEvidence() !== null && !$this->getEvidence()->isEmptyElement()) { |
||
| 199 | $this->getEvidence()->toXML($e); |
||
| 200 | } |
||
| 201 | |||
| 202 | return $e; |
||
| 203 | } |
||
| 204 | } |
||
| 205 |
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