From cc3f70342abbe11d78c7566608de4e45ef7621f9 Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Fri, 12 Jul 2024 07:45:53 +0200 Subject: [PATCH] Update serializers and remove PHPStan errors This commit refines the Symfony Serializer in the ExtensionDescriptor class and upgrades several packages in the composer.json file. It also cleans up the phpstan-baseline.neon file by removing noise from a slew of PHPStan errors, which indicates an improvement in the code quality and robustness. This makes the PHPStan static analysis tool more effective and useful for future developments. --- composer.json | 7 +- phpstan-baseline.neon | 355 +----------------- .../Controller/AssertionRequestController.php | 4 +- .../AssertionResponseController.php | 4 +- .../ExtensionDescriptorDenormalizer.php | 21 +- .../Statement/ExtensionDescriptor.php | 2 + 6 files changed, 21 insertions(+), 372 deletions(-) diff --git a/composer.json b/composer.json index 1fa440e39..bf3efb6e1 100644 --- a/composer.json +++ b/composer.json @@ -99,8 +99,10 @@ "phpstan/extension-installer": "^1.3", "phpstan/phpstan": "^1.8", "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-phpunit": "^1.1", + "phpstan/phpstan-doctrine": "^1.4", + "phpstan/phpstan-phpunit": "^1.4", "phpstan/phpstan-strict-rules": "^1.4", + "phpstan/phpstan-symfony": "^1.4", "phpunit/phpunit": "^10.1|^11.0", "psr/http-client": "^1.0", "psr/http-factory": "^1.1", @@ -108,7 +110,8 @@ "qossmic/deptrac": "^2.0", "rector/rector": "^1.0", "roave/security-advisories": "dev-latest", - "staabm/phpstan-todo-by": "^0.1.25", + "staabm/phpstan-todo-by": "^0.1.27", + "struggle-for-php/sfp-phpstan-psr-log": "^0.21.0", "symfony/asset": "^6.4|^7.0", "symfony/asset-mapper": "^6.4|^7.0", "symfony/browser-kit": "^6.4|^7.0", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 67a407d83..c6b8c17bd 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,10 +1,5 @@ parameters: ignoreErrors: - - - message: "#^Cannot access offset 'FrameworkBundle' on array\\|bool\\|float\\|int\\|string\\|UnitEnum\\.$#" - count: 1 - path: src/stimulus/src/DependencyInjection/WebauthnStimulusExtension.php - - message: "#^Method Webauthn\\\\Bundle\\\\CredentialOptionsBuilder\\\\PublicKeyCredentialCreationOptionsBuilder\\:\\:getFromRequest\\(\\) invoked with 3 parameters, 2 required\\.$#" count: 1 @@ -15,21 +10,6 @@ parameters: count: 1 path: src/symfony/src/CredentialOptionsBuilder/ProfileBasedRequestOptionsBuilder.php - - - message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:integerNode\\(\\)\\.$#" - count: 1 - path: src/symfony/src/DependencyInjection/Configuration.php - - - - message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:scalarNode\\(\\)\\.$#" - count: 4 - path: src/symfony/src/DependencyInjection/Configuration.php - - - - message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:scalarNode\\(\\)\\.$#" - count: 1 - path: src/symfony/src/DependencyInjection/Factory/Security/WebauthnFactory.php - - message: "#^Cannot access offset 'enabled' on mixed\\.$#" count: 2 @@ -375,16 +355,6 @@ parameters: count: 1 path: src/symfony/src/Security/Authentication/Token/WebauthnToken.php - - - message: "#^Method Webauthn\\\\Bundle\\\\Security\\\\Authorization\\\\Voter\\\\IsUserPresentVoter\\:\\:vote\\(\\) has parameter \\$attributes with no value type specified in iterable type array\\.$#" - count: 1 - path: src/symfony/src/Security/Authorization/Voter/IsUserPresentVoter.php - - - - message: "#^Method Webauthn\\\\Bundle\\\\Security\\\\Authorization\\\\Voter\\\\IsUserVerifiedVoter\\:\\:vote\\(\\) has parameter \\$attributes with no value type specified in iterable type array\\.$#" - count: 1 - path: src/symfony/src/Security/Authorization/Voter/IsUserVerifiedVoter.php - - message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpFoundation\\\\Request\\:\\:getContentType\\(\\)\\.$#" count: 1 @@ -1040,16 +1010,6 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/AttestationObjectDenormalizer.php - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AttestationObjectDenormalizer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AttestationObjectDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AttestationObjectDenormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AttestationObjectDenormalizer.php - - message: "#^Parameter \\#1 \\$data of class Webauthn\\\\StringStream constructor expects string, mixed given\\.$#" count: 1 @@ -1060,31 +1020,11 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/AttestationObjectDenormalizer.php - - - message: "#^Parameter \\#2 \\$attStmt of static method Webauthn\\\\AttestationStatement\\\\AttestationObject\\:\\:create\\(\\) expects Webauthn\\\\AttestationStatement\\\\AttestationStatement, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AttestationObjectDenormalizer.php - - - - message: "#^Parameter \\#3 \\$authData of static method Webauthn\\\\AttestationStatement\\\\AttestationObject\\:\\:create\\(\\) expects Webauthn\\\\AuthenticatorData, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AttestationObjectDenormalizer.php - - message: "#^Cannot access offset 'fmt' on mixed\\.$#" count: 1 path: src/webauthn/src/Denormalizer/AttestationStatementDenormalizer.php - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AttestationStatementDenormalizer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AttestationStatementDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AttestationStatementDenormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AttestationStatementDenormalizer.php - - message: "#^Parameter \\#1 \\$attestation of method Webauthn\\\\AttestationStatement\\\\AttestationStatementSupport\\:\\:load\\(\\) expects array\\, mixed given\\.$#" count: 1 @@ -1095,51 +1035,11 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/AttestationStatementDenormalizer.php - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AttestedCredentialDataNormalizer\\:\\:normalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AttestedCredentialDataNormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AttestedCredentialDataNormalizer\\:\\:supportsNormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AttestedCredentialDataNormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AuthenticationExtensionNormalizer\\:\\:normalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticationExtensionNormalizer.php - - message: "#^Method Webauthn\\\\Denormalizer\\\\AuthenticationExtensionNormalizer\\:\\:normalize\\(\\) should return array but returns mixed\\.$#" count: 1 path: src/webauthn/src/Denormalizer/AuthenticationExtensionNormalizer.php - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AuthenticationExtensionNormalizer\\:\\:supportsNormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticationExtensionNormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AuthenticationExtensionsDenormalizer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticationExtensionsDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AuthenticationExtensionsDenormalizer\\:\\:normalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticationExtensionsDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AuthenticationExtensionsDenormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticationExtensionsDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AuthenticationExtensionsDenormalizer\\:\\:supportsNormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticationExtensionsDenormalizer.php - - message: "#^Cannot access offset 'attestationObject' on mixed\\.$#" count: 1 @@ -1165,21 +1065,6 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/AuthenticatorAssertionResponseDenormalizer.php - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AuthenticatorAssertionResponseDenormalizer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticatorAssertionResponseDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AuthenticatorAssertionResponseDenormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticatorAssertionResponseDenormalizer.php - - - - message: "#^Parameter \\#1 \\$clientDataJSON of static method Webauthn\\\\AuthenticatorAssertionResponse\\:\\:create\\(\\) expects Webauthn\\\\CollectedClientData, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticatorAssertionResponseDenormalizer.php - - message: "#^Parameter \\#1 \\$data of static method Webauthn\\\\Util\\\\Base64\\:\\:decode\\(\\) expects string, mixed given\\.$#" count: 3 @@ -1190,21 +1075,11 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/AuthenticatorAssertionResponseDenormalizer.php - - - message: "#^Parameter \\#2 \\$authenticatorData of static method Webauthn\\\\AuthenticatorAssertionResponse\\:\\:create\\(\\) expects Webauthn\\\\AuthenticatorData, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticatorAssertionResponseDenormalizer.php - - message: "#^Parameter \\#3 \\$signature of static method Webauthn\\\\AuthenticatorAssertionResponse\\:\\:create\\(\\) expects string, mixed given\\.$#" count: 1 path: src/webauthn/src/Denormalizer/AuthenticatorAssertionResponseDenormalizer.php - - - message: "#^Parameter \\#5 \\$attestationObject of static method Webauthn\\\\AuthenticatorAssertionResponse\\:\\:create\\(\\) expects Webauthn\\\\AttestationStatement\\\\AttestationObject\\|null, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticatorAssertionResponseDenormalizer.php - - message: "#^Cannot access offset 'attestationObject' on mixed\\.$#" count: 2 @@ -1220,21 +1095,6 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/AuthenticatorAttestationResponseDenormalizer.php - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AuthenticatorAttestationResponseDenormalizer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticatorAttestationResponseDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AuthenticatorAttestationResponseDenormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticatorAttestationResponseDenormalizer.php - - - - message: "#^Parameter \\#1 \\$clientDataJSON of static method Webauthn\\\\AuthenticatorAttestationResponse\\:\\:create\\(\\) expects Webauthn\\\\CollectedClientData, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticatorAttestationResponseDenormalizer.php - - message: "#^Parameter \\#1 \\$data of static method Webauthn\\\\Util\\\\Base64\\:\\:decode\\(\\) expects string, mixed given\\.$#" count: 1 @@ -1245,11 +1105,6 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/AuthenticatorAttestationResponseDenormalizer.php - - - message: "#^Parameter \\#2 \\$attestationObject of static method Webauthn\\\\AuthenticatorAttestationResponse\\:\\:create\\(\\) expects Webauthn\\\\AttestationStatement\\\\AttestationObject, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticatorAttestationResponseDenormalizer.php - - message: "#^Parameter \\#3 \\$transports of static method Webauthn\\\\AuthenticatorAttestationResponse\\:\\:create\\(\\) expects array\\, mixed given\\.$#" count: 1 @@ -1260,16 +1115,6 @@ parameters: count: 2 path: src/webauthn/src/Denormalizer/AuthenticatorDataDenormalizer.php - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AuthenticatorDataDenormalizer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticatorDataDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AuthenticatorDataDenormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticatorDataDenormalizer.php - - message: "#^Parameter \\#1 \\$data of method Webauthn\\\\Denormalizer\\\\AuthenticatorDataDenormalizer\\:\\:fixIncorrectEdDSAKey\\(\\) expects string, mixed given\\.$#" count: 1 @@ -1290,36 +1135,11 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/AuthenticatorDataDenormalizer.php - - - message: "#^Parameter \\#6 \\$extensions of static method Webauthn\\\\AuthenticatorData\\:\\:create\\(\\) expects Webauthn\\\\AuthenticationExtensions\\\\AuthenticationExtensions\\|null, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticatorDataDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AuthenticatorResponseDenormalizer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticatorResponseDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\AuthenticatorResponseDenormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/AuthenticatorResponseDenormalizer.php - - message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, mixed given\\.$#" count: 2 path: src/webauthn/src/Denormalizer/AuthenticatorResponseDenormalizer.php - - - message: "#^Method Webauthn\\\\Denormalizer\\\\CollectedClientDataDenormalizer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/CollectedClientDataDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\CollectedClientDataDenormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/CollectedClientDataDenormalizer.php - - message: "#^Parameter \\#1 \\$json of function json_decode expects string, mixed given\\.$#" count: 1 @@ -1336,45 +1156,25 @@ parameters: path: src/webauthn/src/Denormalizer/CollectedClientDataDenormalizer.php - - message: "#^Method Webauthn\\\\Denormalizer\\\\ExtensionDescriptorDenormalizer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" + message: "#^Only iterables can be unpacked, mixed given in argument \\#1\\.$#" count: 1 path: src/webauthn/src/Denormalizer/ExtensionDescriptorDenormalizer.php - - message: "#^Method Webauthn\\\\Denormalizer\\\\ExtensionDescriptorDenormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" + message: "#^Parameter \\#1 \\$id of static method Webauthn\\\\MetadataService\\\\Statement\\\\ExtensionDescriptor\\:\\:create\\(\\) expects string, mixed given\\.$#" count: 1 path: src/webauthn/src/Denormalizer/ExtensionDescriptorDenormalizer.php - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialDenormalizer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialDenormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialDenormalizer.php - - message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, mixed given\\.$#" count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialDenormalizer.php + path: src/webauthn/src/Denormalizer/ExtensionDescriptorDenormalizer.php - - message: "#^Parameter \\#3 \\$response of static method Webauthn\\\\PublicKeyCredential\\:\\:create\\(\\) expects Webauthn\\\\AuthenticatorResponse, mixed given\\.$#" + message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, mixed given\\.$#" count: 1 path: src/webauthn/src/Denormalizer/PublicKeyCredentialDenormalizer.php - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialDescriptorNormalizer\\:\\:normalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialDescriptorNormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialDescriptorNormalizer\\:\\:supportsNormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialDescriptorNormalizer.php - - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" count: 1 @@ -1455,26 +1255,6 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialOptionsDenormalizer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialOptionsDenormalizer\\:\\:normalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialOptionsDenormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialOptionsDenormalizer\\:\\:supportsNormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - message: "#^Parameter \\#1 \\$challenge of static method Webauthn\\\\PublicKeyCredentialRequestOptions\\:\\:create\\(\\) expects string, mixed given\\.$#" count: 1 @@ -1485,11 +1265,6 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - - message: "#^Parameter \\#1 \\$rp of static method Webauthn\\\\PublicKeyCredentialCreationOptions\\:\\:create\\(\\) expects Webauthn\\\\PublicKeyCredentialRpEntity, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, mixed given\\.$#" count: 2 @@ -1500,36 +1275,16 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - - message: "#^Parameter \\#2 \\$user of static method Webauthn\\\\PublicKeyCredentialCreationOptions\\:\\:create\\(\\) expects Webauthn\\\\PublicKeyCredentialUserEntity, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - - - message: "#^Parameter \\#3 \\$allowCredentials of static method Webauthn\\\\PublicKeyCredentialRequestOptions\\:\\:create\\(\\) expects array\\, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - message: "#^Parameter \\#3 \\$challenge of static method Webauthn\\\\PublicKeyCredentialCreationOptions\\:\\:create\\(\\) expects string, mixed given\\.$#" count: 1 path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - - message: "#^Parameter \\#4 \\$pubKeyCredParams of static method Webauthn\\\\PublicKeyCredentialCreationOptions\\:\\:create\\(\\) expects array\\, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - message: "#^Parameter \\#4 \\$userVerification of static method Webauthn\\\\PublicKeyCredentialRequestOptions\\:\\:create\\(\\) expects string\\|null, mixed given\\.$#" count: 1 path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - - message: "#^Parameter \\#5 \\$authenticatorSelection of static method Webauthn\\\\PublicKeyCredentialCreationOptions\\:\\:create\\(\\) expects Webauthn\\\\AuthenticatorSelectionCriteria\\|null, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - message: "#^Parameter \\#5 \\$timeout of static method Webauthn\\\\PublicKeyCredentialRequestOptions\\:\\:create\\(\\) expects int\\<1, max\\>\\|null, mixed given\\.$#" count: 1 @@ -1540,36 +1295,11 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - - message: "#^Parameter \\#6 \\$extensions of static method Webauthn\\\\PublicKeyCredentialRequestOptions\\:\\:create\\(\\) expects array\\\\|Webauthn\\\\AuthenticationExtensions\\\\AuthenticationExtensions\\|null, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - - - message: "#^Parameter \\#7 \\$excludeCredentials of static method Webauthn\\\\PublicKeyCredentialCreationOptions\\:\\:create\\(\\) expects array\\, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - message: "#^Parameter \\#8 \\$timeout of static method Webauthn\\\\PublicKeyCredentialCreationOptions\\:\\:create\\(\\) expects int\\<1, max\\>\\|null, mixed given\\.$#" count: 1 path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - - message: "#^Parameter \\#9 \\$extensions of static method Webauthn\\\\PublicKeyCredentialCreationOptions\\:\\:create\\(\\) expects Webauthn\\\\AuthenticationExtensions\\\\AuthenticationExtensions\\|null, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialParametersDenormalizer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialParametersDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialParametersDenormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialParametersDenormalizer.php - - message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, mixed given\\.$#" count: 1 @@ -1640,26 +1370,6 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/PublicKeyCredentialSourceDenormalizer.php - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialSourceDenormalizer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialSourceDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialSourceDenormalizer\\:\\:normalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialSourceDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialSourceDenormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialSourceDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialSourceDenormalizer\\:\\:supportsNormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialSourceDenormalizer.php - - message: "#^Parameter \\#1 \\$data of static method Webauthn\\\\Util\\\\Base64\\:\\:decode\\(\\) expects string, mixed given\\.$#" count: 1 @@ -1715,11 +1425,6 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/PublicKeyCredentialSourceDenormalizer.php - - - message: "#^Parameter \\#5 \\$trustPath of static method Webauthn\\\\PublicKeyCredentialSource\\:\\:create\\(\\) expects Webauthn\\\\TrustPath\\\\TrustPath, mixed given\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialSourceDenormalizer.php - - message: "#^Parameter \\#7 \\$credentialPublicKey of static method Webauthn\\\\PublicKeyCredentialSource\\:\\:create\\(\\) expects string, mixed given\\.$#" count: 1 @@ -1735,26 +1440,6 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/PublicKeyCredentialSourceDenormalizer.php - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialUserEntityDenormalizer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialUserEntityDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialUserEntityDenormalizer\\:\\:normalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialUserEntityDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialUserEntityDenormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialUserEntityDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\PublicKeyCredentialUserEntityDenormalizer\\:\\:supportsNormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/PublicKeyCredentialUserEntityDenormalizer.php - - message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, mixed given\\.$#" count: 1 @@ -1765,43 +1450,13 @@ parameters: count: 1 path: src/webauthn/src/Denormalizer/TrustPathDenormalizer.php - - - message: "#^Method Webauthn\\\\Denormalizer\\\\TrustPathDenormalizer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/TrustPathDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\TrustPathDenormalizer\\:\\:normalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/TrustPathDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\TrustPathDenormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/TrustPathDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\TrustPathDenormalizer\\:\\:supportsNormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/TrustPathDenormalizer.php - - message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, mixed given\\.$#" count: 1 path: src/webauthn/src/Denormalizer/TrustPathDenormalizer.php - - message: "#^Method Webauthn\\\\Denormalizer\\\\VerificationMethodANDCombinationsDenormalizer\\:\\:normalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\VerificationMethodANDCombinationsDenormalizer\\:\\:normalize\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: src/webauthn/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php - - - - message: "#^Method Webauthn\\\\Denormalizer\\\\VerificationMethodANDCombinationsDenormalizer\\:\\:supportsNormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" + message: "#^Method Webauthn\\\\Denormalizer\\\\VerificationMethodANDCombinationsDenormalizer\\:\\:normalize\\(\\) should return array\\ but returns array\\\\|bool\\|float\\|int\\|string\\|null\\>\\.$#" count: 1 path: src/webauthn/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php diff --git a/src/symfony/src/Controller/AssertionRequestController.php b/src/symfony/src/Controller/AssertionRequestController.php index f0caa98aa..a1ff4e956 100644 --- a/src/symfony/src/Controller/AssertionRequestController.php +++ b/src/symfony/src/Controller/AssertionRequestController.php @@ -37,7 +37,9 @@ public function __invoke(Request $request): Response return $response; } catch (Throwable $throwable) { - $this->logger->error($throwable->getMessage()); + $this->logger->error('An error occurred during the assertion ceremony', [ + 'exception' => $throwable, + ]); if ($this->failureHandler instanceof AuthenticationFailureHandlerInterface) { return $this->failureHandler->onAuthenticationFailure( $request, diff --git a/src/symfony/src/Controller/AssertionResponseController.php b/src/symfony/src/Controller/AssertionResponseController.php index b160a1b44..ae3c6eb61 100644 --- a/src/symfony/src/Controller/AssertionResponseController.php +++ b/src/symfony/src/Controller/AssertionResponseController.php @@ -73,7 +73,9 @@ public function __invoke(Request $request): Response ); return $this->successHandler->onSuccess($request); } catch (Throwable $throwable) { - $this->logger->error($throwable->getMessage()); + $this->logger->error('An error occurred during the assertion ceremony', [ + 'exception' => $throwable, + ]); if ($this->failureHandler instanceof AuthenticationFailureHandlerInterface) { return $this->failureHandler->onAuthenticationFailure( $request, diff --git a/src/webauthn/src/Denormalizer/ExtensionDescriptorDenormalizer.php b/src/webauthn/src/Denormalizer/ExtensionDescriptorDenormalizer.php index 2f87c570b..8585432ab 100644 --- a/src/webauthn/src/Denormalizer/ExtensionDescriptorDenormalizer.php +++ b/src/webauthn/src/Denormalizer/ExtensionDescriptorDenormalizer.php @@ -4,39 +4,24 @@ namespace Webauthn\Denormalizer; -use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; -use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Webauthn\MetadataService\Statement\ExtensionDescriptor; use function array_key_exists; -use function assert; -use function is_array; -final class ExtensionDescriptorDenormalizer implements DenormalizerInterface, DenormalizerAwareInterface +final class ExtensionDescriptorDenormalizer implements DenormalizerInterface { - use DenormalizerAwareTrait; - - private const ALREADY_CALLED = 'EXTENSION_DESCRIPTOR_PREPROCESS_ALREADY_CALLED'; - public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed { - assert(is_array($data), 'Data should be an array'); if (array_key_exists('fail_if_unknown', $data)) { $data['failIfUnknown'] = $data['fail_if_unknown']; unset($data['fail_if_unknown']); } - $context[self::ALREADY_CALLED] = true; - - return $this->denormalizer->denormalize($data, $type, $format, $context); + return ExtensionDescriptor::create(...$data); } public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool { - if ($context[self::ALREADY_CALLED] ?? false) { - return false; - } - return $type === ExtensionDescriptor::class; } @@ -46,7 +31,7 @@ public function supportsDenormalization(mixed $data, string $type, string $forma public function getSupportedTypes(?string $format): array { return [ - ExtensionDescriptor::class => false, + ExtensionDescriptor::class => true, ]; } } diff --git a/src/webauthn/src/MetadataService/Statement/ExtensionDescriptor.php b/src/webauthn/src/MetadataService/Statement/ExtensionDescriptor.php index 75eeaef46..5eec30433 100644 --- a/src/webauthn/src/MetadataService/Statement/ExtensionDescriptor.php +++ b/src/webauthn/src/MetadataService/Statement/ExtensionDescriptor.php @@ -4,6 +4,7 @@ namespace Webauthn\MetadataService\Statement; +use Symfony\Component\Serializer\Attribute\SerializedName; use Webauthn\Exception\MetadataStatementLoadingException; readonly class ExtensionDescriptor @@ -12,6 +13,7 @@ public function __construct( public string $id, public ?int $tag, public ?string $data, + #[SerializedName('fail_if_unknown')] public bool $failIfUnknown ) { if ($tag !== null) {