Skip to content

Commit dd43597

Browse files
committed
fix: cast 'alg' to int in AttestationStatement classes to resolve PHPStan errors
1 parent f04bb63 commit dd43597

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

.ci-tools/phpstan-baseline.neon

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,12 @@ parameters:
369369
count: 1
370370
path: ../src/symfony/src/Security/Http/Authenticator/WebauthnAuthenticator.php
371371

372+
-
373+
rawMessage: Cannot cast mixed to int.
374+
identifier: cast.int
375+
count: 1
376+
path: ../src/webauthn/src/AttestationStatement/AndroidKeyAttestationStatementSupport.php
377+
372378
-
373379
rawMessage: Class Webauthn\AttestationStatement\CompoundAttestationStatementSupport has an uninitialized property $attestationStatementSupportManager. Give it default value or assign it in the constructor.
374380
identifier: property.uninitialized
@@ -381,6 +387,18 @@ parameters:
381387
count: 1
382388
path: ../src/webauthn/src/AttestationStatement/CompoundAttestationStatementSupport.php
383389

390+
-
391+
rawMessage: Cannot cast mixed to int.
392+
identifier: cast.int
393+
count: 2
394+
path: ../src/webauthn/src/AttestationStatement/PackedAttestationStatementSupport.php
395+
396+
-
397+
rawMessage: Cannot cast mixed to int.
398+
identifier: cast.int
399+
count: 2
400+
path: ../src/webauthn/src/AttestationStatement/TPMAttestationStatementSupport.php
401+
384402
-
385403
rawMessage: '''
386404
Instanceof references deprecated class Webauthn\PublicKeyCredentialSource:

src/webauthn/src/AttestationStatement/AndroidKeyAttestationStatementSupport.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ public function isValid(
121121
$this->checkCertificate($leaf, $clientDataJSONHash, $authenticatorData);
122122

123123
$signedData = $authenticatorData->authData . $clientDataJSONHash;
124-
/** @var int $alg */
125-
$alg = $attestationStatement->get('alg');
124+
$alg = (int) $attestationStatement->get('alg');
126125
/** @var string $sig */
127126
$sig = $attestationStatement->get('sig');
128127

src/webauthn/src/AttestationStatement/PackedAttestationStatementSupport.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ private function processWithCertificate(
246246
$this->checkCertificate($certificates[0], $authenticatorData);
247247

248248
// Get the COSE algorithm identifier and the corresponding OpenSSL one
249-
/** @var int $coseAlgorithmIdentifier */
250-
$coseAlgorithmIdentifier = $attestationStatement->get('alg');
249+
$coseAlgorithmIdentifier = (int) $attestationStatement->get('alg');
251250
$opensslAlgorithmIdentifier = Algorithms::getOpensslAlgorithmFor($coseAlgorithmIdentifier);
252251

253252
// Verification of the signature
@@ -283,8 +282,7 @@ private function processWithSelfAttestation(
283282
);
284283
$publicKey = $publicKey->normalize();
285284
$publicKey = new Key($publicKey);
286-
/** @var int $alg */
287-
$alg = $attestationStatement->get('alg');
285+
$alg = (int) $attestationStatement->get('alg');
288286
$publicKey->alg() === $alg || throw AttestationStatementVerificationException::create(
289287
'The algorithm of the attestation statement and the key are not identical.'
290288
);

src/webauthn/src/AttestationStatement/TPMAttestationStatementSupport.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ public function isValid(
139139
AuthenticatorData $authenticatorData
140140
): bool {
141141
$attToBeSigned = $authenticatorData->authData . $clientDataJSONHash;
142-
/** @var int $alg */
143-
$alg = $attestationStatement->get('alg');
142+
$alg = (int) $attestationStatement->get('alg');
144143
$attToBeSignedHash = hash(Algorithms::getHashAlgorithmFor($alg), $attToBeSigned, true);
145144
/** @var array{extraData: string} $parsedCertInfo */
146145
$parsedCertInfo = $attestationStatement->get('parsedCertInfo');
@@ -372,8 +371,7 @@ private function processWithCertificate(
372371
$this->checkCertificate($certificates[0], $authenticatorData);
373372

374373
// Get the COSE algorithm identifier and the corresponding OpenSSL one
375-
/** @var int $coseAlgorithmIdentifier */
376-
$coseAlgorithmIdentifier = $attestationStatement->get('alg');
374+
$coseAlgorithmIdentifier = (int) $attestationStatement->get('alg');
377375
$opensslAlgorithmIdentifier = Algorithms::getOpensslAlgorithmFor($coseAlgorithmIdentifier);
378376

379377
/** @var string $certInfo */

0 commit comments

Comments
 (0)