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\mdrpi; |
||
| 6 | |||
| 7 | use DOMElement; |
||
| 8 | use SimpleSAML\SAML2\Assert\Assert; |
||
| 9 | use SimpleSAML\SAML2\Exception\ArrayValidationException; |
||
| 10 | use SimpleSAML\SAML2\Type\SAMLDateTimeValue; |
||
|
0 ignored issues
–
show
|
|||
| 11 | use SimpleSAML\SAML2\Type\SAMLStringValue; |
||
| 12 | use SimpleSAML\XML\ArrayizableElementInterface; |
||
| 13 | use SimpleSAML\XML\SchemaValidatableElementInterface; |
||
| 14 | use SimpleSAML\XML\SchemaValidatableElementTrait; |
||
| 15 | use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Class for handling the mdrpi:Publication element. |
||
| 19 | * |
||
| 20 | * @link: http://docs.oasis-open.org/security/saml/Post2.0/saml-metadata-rpi/v1.0/saml-metadata-rpi-v1.0.pdf |
||
| 21 | * @package simplesamlphp/saml2 |
||
| 22 | */ |
||
| 23 | final class Publication extends AbstractMdrpiElement implements |
||
|
0 ignored issues
–
show
The type
SimpleSAML\SAML2\XML\mdrpi\AbstractMdrpiElement 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 | ArrayizableElementInterface, |
||
| 25 | SchemaValidatableElementInterface |
||
| 26 | { |
||
| 27 | use SchemaValidatableElementTrait; |
||
| 28 | |||
| 29 | |||
| 30 | /** |
||
| 31 | * Create/parse a mdrpi:PublicationInfo element. |
||
| 32 | * |
||
| 33 | * @param \SimpleSAML\SAML2\Type\SAMLStringValue $publisher |
||
| 34 | * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $creationInstant |
||
| 35 | * @param \SimpleSAML\SAML2\Type\SAMLStringValue|null $publicationId |
||
| 36 | */ |
||
| 37 | public function __construct( |
||
| 38 | protected SAMLStringValue $publisher, |
||
| 39 | protected ?SAMLDateTimeValue $creationInstant = null, |
||
| 40 | protected ?SAMLStringValue $publicationId = null, |
||
| 41 | ) { |
||
| 42 | } |
||
| 43 | |||
| 44 | |||
| 45 | /** |
||
| 46 | * Collect the value of the publisher-property |
||
| 47 | * |
||
| 48 | * @return \SimpleSAML\SAML2\Type\SAMLStringValue |
||
| 49 | */ |
||
| 50 | public function getPublisher(): SAMLStringValue |
||
| 51 | { |
||
| 52 | return $this->publisher; |
||
| 53 | } |
||
| 54 | |||
| 55 | |||
| 56 | /** |
||
| 57 | * Collect the value of the creationInstant-property |
||
| 58 | * |
||
| 59 | * @return \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null |
||
| 60 | */ |
||
| 61 | public function getCreationInstant(): ?SAMLDateTimeValue |
||
| 62 | { |
||
| 63 | return $this->creationInstant; |
||
| 64 | } |
||
| 65 | |||
| 66 | |||
| 67 | /** |
||
| 68 | * Collect the value of the publicationId-property |
||
| 69 | * |
||
| 70 | * @return \SimpleSAML\SAML2\Type\SAMLStringValue|null |
||
| 71 | */ |
||
| 72 | public function getPublicationId(): ?SAMLStringValue |
||
| 73 | { |
||
| 74 | return $this->publicationId; |
||
| 75 | } |
||
| 76 | |||
| 77 | |||
| 78 | /** |
||
| 79 | * Convert XML into a Publication |
||
| 80 | * |
||
| 81 | * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
||
| 82 | * if the qualified name of the supplied element is wrong |
||
| 83 | * @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException |
||
| 84 | * if the supplied element is missing one of the mandatory attributes |
||
| 85 | */ |
||
| 86 | public static function fromXML(DOMElement $xml): static |
||
| 87 | { |
||
| 88 | Assert::same($xml->localName, 'Publication', InvalidDOMElementException::class); |
||
| 89 | Assert::same($xml->namespaceURI, Publication::NS, InvalidDOMElementException::class); |
||
| 90 | |||
| 91 | $publisher = self::getAttribute($xml, 'publisher', SAMLStringValue::class); |
||
| 92 | $creationInstant = self::getOptionalAttribute($xml, 'creationInstant', SAMLDateTimeValue::class, null); |
||
| 93 | $publicationId = self::getOptionalAttribute($xml, 'publicationId', SAMLStringValue::class, null); |
||
| 94 | |||
| 95 | return new static($publisher, $creationInstant, $publicationId); |
||
| 96 | } |
||
| 97 | |||
| 98 | |||
| 99 | /** |
||
| 100 | * Convert this element to XML. |
||
| 101 | */ |
||
| 102 | public function toXML(?DOMElement $parent = null): DOMElement |
||
| 103 | { |
||
| 104 | $e = $this->instantiateParentElement($parent); |
||
| 105 | $e->setAttribute('publisher', $this->getPublisher()->getValue()); |
||
| 106 | |||
| 107 | if ($this->getCreationInstant() !== null) { |
||
| 108 | $e->setAttribute('creationInstant', $this->getCreationInstant()->getValue()); |
||
| 109 | } |
||
| 110 | |||
| 111 | if ($this->getPublicationId() !== null) { |
||
| 112 | $e->setAttribute('publicationId', $this->getPublicationId()->getValue()); |
||
| 113 | } |
||
| 114 | |||
| 115 | return $e; |
||
| 116 | } |
||
| 117 | |||
| 118 | |||
| 119 | /** |
||
| 120 | * Create a class from an array |
||
| 121 | * |
||
| 122 | * @param array{ |
||
| 123 | * 'publisher': string, |
||
| 124 | * 'creationInstant'?: string, |
||
| 125 | * 'publicationId'?: string, |
||
| 126 | * } $data |
||
| 127 | */ |
||
| 128 | public static function fromArray(array $data): static |
||
| 129 | { |
||
| 130 | $data = self::processArrayContents($data); |
||
| 131 | |||
| 132 | return new static( |
||
| 133 | SAMLStringValue::fromString($data['publisher']), |
||
| 134 | $data['creationInstant'] !== null ? SAMLDateTimeValue::fromString($data['creationInstant']) : null, |
||
| 135 | $data['publicationId'] !== null ? SAMLStringValue::fromString($data['publicationId']) : null, |
||
| 136 | ); |
||
| 137 | } |
||
| 138 | |||
| 139 | |||
| 140 | /** |
||
| 141 | * Validates an array representation of this object and returns the same array with |
||
| 142 | * rationalized keys (casing) and parsed sub-elements. |
||
| 143 | * |
||
| 144 | * @param array{ |
||
| 145 | * 'publisher': string, |
||
| 146 | * 'creationInstant'?: string, |
||
| 147 | * 'publicationId'?: string, |
||
| 148 | * } $data |
||
| 149 | * @return array{ |
||
|
0 ignored issues
–
show
|
|||
| 150 | * 'publisher': string, |
||
| 151 | * 'creationInstant'?: string, |
||
| 152 | * 'publicationId'?: string, |
||
| 153 | * } |
||
| 154 | */ |
||
| 155 | private static function processArrayContents(array $data): array |
||
| 156 | { |
||
| 157 | $data = array_change_key_case($data, CASE_LOWER); |
||
| 158 | |||
| 159 | Assert::allOneOf( |
||
| 160 | array_keys($data), |
||
| 161 | ['publisher', 'creationinstant', 'publicationid'], |
||
| 162 | ArrayValidationException::class, |
||
| 163 | ); |
||
| 164 | |||
| 165 | Assert::keyExists($data, 'publisher', ArrayValidationException::class); |
||
| 166 | Assert::string($data['publisher'], ArrayValidationException::class); |
||
| 167 | $retval = ['publisher' => $data['publisher']]; |
||
| 168 | |||
| 169 | if (array_key_exists('creationinstant', $data)) { |
||
| 170 | Assert::string($data['creationinstant'], ArrayValidationException::class); |
||
| 171 | Assert::validSAMLDateTime($data['creationinstant'], ArrayValidationException::class); |
||
| 172 | $retval['creationInstant'] = $data['creationinstant']; |
||
| 173 | } |
||
| 174 | |||
| 175 | if (array_key_exists('publicationid', $data)) { |
||
| 176 | Assert::string($data['publicationid'], ArrayValidationException::class); |
||
| 177 | $retval['publicationId'] = $data['publicationid']; |
||
| 178 | } |
||
| 179 | |||
| 180 | return $retval; |
||
| 181 | } |
||
| 182 | |||
| 183 | |||
| 184 | /** |
||
| 185 | * Create an array from this class |
||
| 186 | * |
||
| 187 | * @return array{ |
||
|
0 ignored issues
–
show
|
|||
| 188 | * 'publisher': string, |
||
| 189 | * 'creationInstant'?: string, |
||
| 190 | * 'publicationId'?: string, |
||
| 191 | * } |
||
| 192 | */ |
||
| 193 | public function toArray(): array |
||
| 194 | { |
||
| 195 | $data = []; |
||
| 196 | $data['publisher'] = $this->getPublisher()->getValue(); |
||
| 197 | |||
| 198 | if ($this->getCreationInstant() !== null) { |
||
| 199 | $data['creationInstant'] = $this->getCreationInstant()->getValue(); |
||
| 200 | } |
||
| 201 | |||
| 202 | if ($this->getPublicationId() !== null) { |
||
| 203 | $data['publicationId'] = $this->getPublicationId()->getValue(); |
||
| 204 | } |
||
| 205 | |||
| 206 | return $data; |
||
| 207 | } |
||
| 208 | } |
||
| 209 |
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