Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stan error #517

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/infection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow

name: "Integrate"

on:
push:
branches:
- "*.x"

jobs:
mutation_testing:
name: "5️⃣ Mutation Testing"
needs:
- "byte_level"
- "syntax_errors"
runs-on: "ubuntu-latest"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.1"
extensions: "json, mbstring, openssl, sqlite3, curl, uuid"

- name: "Checkout code"
uses: "actions/checkout@v4"

- name: "Fetch Git base reference"
run: "git fetch --depth=1 origin ${GITHUB_BASE_REF}"

- name: "Install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"
composer-options: "--optimize-autoloader"

- name: "Execute Infection"
run: "make ci-mu"
28 changes: 0 additions & 28 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,34 +145,6 @@ jobs:
- name: "Check coding style"
run: "make ci-cs"

mutation_testing:
name: "5️⃣ Mutation Testing"
needs:
- "byte_level"
- "syntax_errors"
runs-on: "ubuntu-latest"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.1"
extensions: "json, mbstring, openssl, sqlite3, curl, uuid"

- name: "Checkout code"
uses: "actions/checkout@v4"

- name: "Fetch Git base reference"
run: "git fetch --depth=1 origin ${GITHUB_BASE_REF}"

- name: "Install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"
composer-options: "--optimize-autoloader"

- name: "Execute Infection"
run: "make ci-mu"

rector_checkstyle:
name: "6️⃣ Rector Checkstyle"
needs:
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1870,11 +1870,6 @@ parameters:
count: 1
path: src/Library/KeyManagement/KeyConverter/KeyConverter.php

-
message: "#^Parameter \\#3 \\$subject of function preg_replace expects array\\|string, string\\|null given\\.$#"
count: 1
path: src/Library/KeyManagement/KeyConverter/KeyConverter.php

-
message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\RSAKey\\:\\:__construct\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
26 changes: 13 additions & 13 deletions src/Library/Encryption/Algorithm/KeyEncryption/AbstractECDH.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ protected function calculateAgreementKey(JWK $private_key, JWK $public_key): str
throw new InvalidArgumentException('Invalid key parameter "crv"');
}
switch ($crv) {
case 'P-256' :
case 'P-384' :
case 'P-521' :
case 'P-256':
case 'P-384':
case 'P-521':
$curve = $this->getCurve($crv);
if (function_exists('openssl_pkey_derive')) {
try {
Expand Down Expand Up @@ -115,7 +115,7 @@ protected function calculateAgreementKey(JWK $private_key, JWK $public_key): str

return $this->convertDecToBin(EcDH::computeSharedKey($curve, $pub_key, $priv_key));

case 'X25519' :
case 'X25519':
$this->checkSodiumExtensionIsAvailable();
$x = $public_key->get('x');
if (! is_string($x)) {
Expand All @@ -130,7 +130,7 @@ protected function calculateAgreementKey(JWK $private_key, JWK $public_key): str

return sodium_crypto_scalarmult($sKey, $recipientPublickey);

default :
default:
throw new InvalidArgumentException(sprintf('The curve "%s" is not supported', $crv));
}
}
Expand Down Expand Up @@ -212,19 +212,19 @@ private function checkKey(JWK $key, bool $is_private): void
throw new InvalidArgumentException('Invalid key parameter "crv"');
}
switch ($crv) {
case 'P-256' :
case 'P-384' :
case 'P-521' :
case 'P-256':
case 'P-384':
case 'P-521':
if (! $key->has('y')) {
throw new InvalidArgumentException('The key parameter "y" is missing.');
}

break;

case 'X25519' :
case 'X25519':
break;

default :
default:
throw new InvalidArgumentException(sprintf('The curve "%s" is not supported', $crv));
}
if ($is_private === true && ! $key->has('d')) {
Expand Down Expand Up @@ -279,14 +279,14 @@ private function createOKPKey(string $curve): JWK
$this->checkSodiumExtensionIsAvailable();

switch ($curve) {
case 'X25519' :
case 'X25519':
$keyPair = sodium_crypto_box_keypair();
$d = sodium_crypto_box_secretkey($keyPair);
$x = sodium_crypto_box_publickey($keyPair);

break;

case 'Ed25519' :
case 'Ed25519':
$keyPair = sodium_crypto_sign_keypair();
$secret = sodium_crypto_sign_secretkey($keyPair);
$secretLength = mb_strlen($secret, '8bit');
Expand All @@ -295,7 +295,7 @@ private function createOKPKey(string $curve): JWK

break;

default :
default:
throw new InvalidArgumentException(sprintf('Unsupported "%s" curve', $curve));
}

Expand Down
10 changes: 5 additions & 5 deletions src/Library/Encryption/JWEBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,11 @@ private function determineCEK(array &$additionalHeader): string
}

switch ($this->keyManagementMode) {
case KeyEncryption::MODE_ENCRYPT :
case KeyEncryption::MODE_WRAP :
case KeyEncryption::MODE_ENCRYPT:
case KeyEncryption::MODE_WRAP:
return $this->createCEK($this->contentEncryptionAlgorithm->getCEKSize());

case KeyEncryption::MODE_AGREEMENT :
case KeyEncryption::MODE_AGREEMENT:
if (count($this->recipients) !== 1) {
throw new LogicException(
'Unable to encrypt for multiple recipients using key agreement algorithms.'
Expand All @@ -465,7 +465,7 @@ private function determineCEK(array &$additionalHeader): string
$additionalHeader
);

case KeyEncryption::MODE_DIRECT :
case KeyEncryption::MODE_DIRECT:
if (count($this->recipients) !== 1) {
throw new LogicException(
'Unable to encrypt for multiple recipients using key agreement algorithms.'
Expand All @@ -483,7 +483,7 @@ private function determineCEK(array &$additionalHeader): string

return Base64UrlSafe::decodeNoPadding($k);

default :
default:
throw new InvalidArgumentException(sprintf(
'Unsupported key management mode "%s".',
$this->keyManagementMode
Expand Down
5 changes: 4 additions & 1 deletion tests/Component/Signature/RFC7520/NestingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public function signatureVerification(): void

static::assertTrue($jwsVerifier->verifyWithKey($loaded_compact_json, $signature_key, 0));
static::assertSame($signature_header, $loaded_compact_json->getSignature(0)->getProtectedHeader());
static::assertSame($payload, json_decode((string) $loaded_compact_json->getPayload(), true, 512, JSON_THROW_ON_ERROR));
static::assertSame(
$payload,
json_decode((string) $loaded_compact_json->getPayload(), true, 512, JSON_THROW_ON_ERROR)
);
}
}
Loading