From 5078f37aa747a33d61dd23d55972cb9cc5d9f8be Mon Sep 17 00:00:00 2001 From: Paragon Initiative Enterprises Date: Fri, 19 Apr 2024 19:53:57 -0400 Subject: [PATCH 1/4] Update sodium_compat dependency --- .github/workflows/ci.yml | 4 ++-- composer.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d04ea35..9323f14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,11 +13,11 @@ jobs: strategy: matrix: operating-system: ['ubuntu-latest'] - php-versions: ['8.1'] + php-versions: ['8.1', '8.2', '8.3', '8.4'] phpunit-versions: ['latest'] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/composer.json b/composer.json index 69fea3c..c8068e1 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "paragonie/constant_time_encoding": ">= 2.6", "paragonie/corner": "^2", "paragonie/easy-ecc": "^1", - "paragonie/sodium_compat": "^1.17" + "paragonie/sodium_compat": "^1|^2" }, "require-dev": { "phpunit/phpunit": "^9|^10", From b764964b47405f620657510289202adf92076e64 Mon Sep 17 00:00:00 2001 From: Paragon Initiative Enterprises Date: Fri, 19 Apr 2024 19:56:22 -0400 Subject: [PATCH 2/4] Fix psalm nits, suppress truthy alert --- src/Keys/Version3/SymmetricKey.php | 2 +- src/Keys/Version4/SymmetricKey.php | 2 +- src/Rules/FooterJSON.php | 1 + src/Util.php | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Keys/Version3/SymmetricKey.php b/src/Keys/Version3/SymmetricKey.php index f634ea3..cc55e1f 100644 --- a/src/Keys/Version3/SymmetricKey.php +++ b/src/Keys/Version3/SymmetricKey.php @@ -21,6 +21,6 @@ class SymmetricKey extends BaseSymmetricKey public function __construct( string $keyMaterial ) { - return parent::__construct($keyMaterial, new Version3()); + parent::__construct($keyMaterial, new Version3()); } } diff --git a/src/Keys/Version4/SymmetricKey.php b/src/Keys/Version4/SymmetricKey.php index 04e1b3f..f1847d6 100644 --- a/src/Keys/Version4/SymmetricKey.php +++ b/src/Keys/Version4/SymmetricKey.php @@ -19,6 +19,6 @@ class SymmetricKey extends BaseSymmetricKey public function __construct( string $keyMaterial ) { - return parent::__construct($keyMaterial, new Version4()); + parent::__construct($keyMaterial, new Version4()); } } diff --git a/src/Rules/FooterJSON.php b/src/Rules/FooterJSON.php index d0c4e3c..4ec57f1 100644 --- a/src/Rules/FooterJSON.php +++ b/src/Rules/FooterJSON.php @@ -100,6 +100,7 @@ public function isValid(JsonToken $token): bool /** @var array|bool|null $decoded */ $decoded = json_decode($json, true, $this->maxDepth); + /** @psalm-suppress RiskyTruthyFalsyComparison */ if (!$decoded) { $this->rejectReason = json_last_error_msg(); } diff --git a/src/Util.php b/src/Util.php index 2f26b6b..4c58cea 100644 --- a/src/Util.php +++ b/src/Util.php @@ -55,12 +55,14 @@ public static function calculateJsonDepth(string $json): int $previous = ''; $depth = 1; + /** @psalm-suppress RiskyTruthyFalsyComparison */ while (!empty($stripped) && $stripped !== $previous) { $previous = $stripped; // Remove pairs of tokens $stripped = str_replace(['[]', '{}'], [], $stripped); ++$depth; } + /** @psalm-suppress RiskyTruthyFalsyComparison */ if (!empty($stripped)) { throw new EncodingException( 'Invalid JSON string provided', From dc246ba3ba07eac469f4bec2699a2eb64a7800d6 Mon Sep 17 00:00:00 2001 From: Paragon Initiative Enterprises Date: Fri, 19 Apr 2024 19:59:28 -0400 Subject: [PATCH 3/4] Fix phpunit --- composer.json | 2 +- tests/ExceptionHelpfulTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c8068e1..06ce517 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "paragonie/sodium_compat": "^1|^2" }, "require-dev": { - "phpunit/phpunit": "^9|^10", + "phpunit/phpunit": "^9", "vimeo/psalm": "^4|^5" }, "scripts": { diff --git a/tests/ExceptionHelpfulTest.php b/tests/ExceptionHelpfulTest.php index d3a72e7..b521b8d 100644 --- a/tests/ExceptionHelpfulTest.php +++ b/tests/ExceptionHelpfulTest.php @@ -19,7 +19,7 @@ private function generateException(int $code): void throw new PasetoException('Test', $code); } - public function codeProvider(): array + public static function codeProvider(): array { return [ [ExceptionCode::BAD_VERSION], From d51fb9c3fc9b1a8a7ef1780058176d371ab9d13c Mon Sep 17 00:00:00 2001 From: Paragon Initiative Enterprises Date: Fri, 19 Apr 2024 20:00:30 -0400 Subject: [PATCH 4/4] Skip PHP 8.4 for now --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9323f14..5cd5e5b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: operating-system: ['ubuntu-latest'] - php-versions: ['8.1', '8.2', '8.3', '8.4'] + php-versions: ['8.1', '8.2', '8.3'] phpunit-versions: ['latest'] steps: - name: Checkout