Skip to content

fix(sd-jwt): tell the decoding bounds apart from invalid JSON #298

fix(sd-jwt): tell the decoding bounds apart from invalid JSON

fix(sd-jwt): tell the decoding bounds apart from invalid JSON #298

Workflow file for this run

name: 📁 PHP CI & Docker Build
on:
push:
branches: ['*.x']
tags: ['*']
pull_request: ~
workflow_dispatch: ~
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
pre_checks:
name: "0️⃣ Pre-checks"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: "Check file permissions"
run: |
NON_EXECUTABLE=$(find . -type f -not -path './.git/*' -not -path './bin/console' -not -path './frankenphp/docker-entrypoint.sh' -not -path './link' -executable)
if [[ -n "$NON_EXECUTABLE" ]]; then
echo "Found non-executable files with executable permission:"
echo "$NON_EXECUTABLE"
exit 1
fi
- name: "Find non-printable ASCII characters"
run: |
if LC_ALL=C.UTF-8 find . -type f -name "*.php" -print0 | xargs -0 grep -PHn "[[:cntrl:]]"; then
echo "Non-printable ASCII characters found"
exit 1
fi
prepare_dependencies:
name: "📦 Prepare Composer Dependencies"
needs: [pre_checks]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
outputs:
cache-key: ${{ steps.cache-key-generator.outputs.key }}
steps:
- uses: actions/checkout@v5
- id: cache-key-generator
run: echo "key=composer-${{ runner.os }}-${{ hashFiles('composer.json', 'src/*/composer.json') }}" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: |
vendor
~/.composer/cache
key: ${{ steps.cache-key-generator.outputs.key }}
restore-keys: |
composer-${{ runner.os }}-
- uses: ramsey/composer-install@v3
with:
dependency-versions: highest
composer-options: --optimize-autoloader
phpstan:
name: "1️⃣ Static Analysis (PHPStan)"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
steps:
- uses: actions/checkout@v5
- uses: actions/cache@v4
with:
path: |
vendor
~/.composer/cache
key: ${{ needs.prepare_dependencies.outputs.cache-key }}
- run: castor phpstan
ecs:
name: "2️⃣ Coding Standards (ECS)"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
steps:
- uses: actions/checkout@v5
- uses: actions/cache@v4
with:
path: |
vendor
~/.composer/cache
key: ${{ needs.prepare_dependencies.outputs.cache-key }}
- run: castor ecs
rector:
name: "3️⃣ Refactoring (Rector)"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
steps:
- uses: actions/checkout@v5
- uses: actions/cache@v4
with:
path: |
vendor
~/.composer/cache
key: ${{ needs.prepare_dependencies.outputs.cache-key }}
- run: castor rector
validate:
name: "4️⃣ Validate composer.json"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
steps:
- uses: actions/checkout@v5
- uses: actions/cache@v4
with:
path: |
vendor
~/.composer/cache
key: ${{ needs.prepare_dependencies.outputs.cache-key }}
- run: |
composer dump-autoload --optimize --strict-psr
composer validate --strict
composer normalize --dry-run --diff || true
lint:
name: "5️⃣ Syntax Check"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
steps:
- uses: actions/checkout@v5
- run: composer exec -- parallel-lint src tests
check_licenses:
name: "6️⃣ License Check"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
steps:
- uses: actions/checkout@v5
- run: castor check-licenses
deptrac:
name: "7️⃣ Architecture Layer Check (Deptrac)"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
steps:
- uses: actions/checkout@v5
- uses: actions/cache@v4
with:
path: |
vendor
~/.composer/cache
key: ${{ needs.prepare_dependencies.outputs.cache-key }}
- run: castor deptrac
tests:
name: "🧪 Unit & Functional Tests (PHP ${{ matrix.php-version }}${{ matrix.lowest-deps && ' - Lowest Deps' || '' }})"
needs:
- prepare_dependencies
- phpstan
- ecs
- rector
- lint
- validate
- check_licenses
- deptrac
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental || false }}
strategy:
fail-fast: false
matrix:
# ml-dsa: whether the ML-DSA algorithms (RFC 9964) must be available on the job's platform, which
# tests/SignatureAlgorithm/MLDSA/MLDSASignatureTest.php asserts. The phpqa images ship OpenSSL 3.5, so the
# gate is the PHP version alone here: closed below 8.4, open from 8.4 on. The OpenSSL side of the gate is
# exercised by the tests_without_ml_dsa job below.
include:
- php-version: '8.2'
lowest-deps: true
ml-dsa: 'no'
- php-version: '8.2'
ml-dsa: 'no'
- php-version: '8.3'
ml-dsa: 'no'
- php-version: '8.4'
ml-dsa: 'yes'
- php-version: '8.5'
experimental: true
ml-dsa: 'yes'
container:
image: ghcr.io/spomky-labs/phpqa:${{ matrix.php-version }}
env:
XDEBUG_MODE: coverage
PHP_VERSION: ${{ matrix.php-version }}
JOSE_ML_DSA_EXPECTED: ${{ matrix.ml-dsa }}
steps:
- uses: actions/checkout@v5
- name: Install dependencies
run: |
if [ "${{ matrix.lowest-deps || 'false' }}" = "true" ]; then
composer update --prefer-lowest --no-interaction --no-progress
else
composer install --no-interaction --no-progress
fi
- name: Run PHPUnit
run: |
composer exec -- phpunit-11 \
--coverage-xml .ci-tools/coverage \
--log-junit=.ci-tools/coverage/junit.xml \
--configuration .ci-tools/phpunit.xml.dist
# The other side of the ML-DSA platform gate: a PHP recent enough (8.4) on an OpenSSL too old (3.0, the one
# Ubuntu 24.04 ships and the PHP of the PPA links against). MLDSA44::isSupported() must be false there, the
# constructor must throw, the bundle must compile and the rest of the suite must be unaffected; MLDSASignatureTest
# asserts the first through JOSE_ML_DSA_EXPECTED. The runner is pinned rather than "latest" so that a newer image
# with OpenSSL 3.5 cannot silently turn this job into a copy of the one above.
tests_without_ml_dsa:
name: "🧪 Unit & Functional Tests (PHP 8.4 - OpenSSL 3.0, no ML-DSA)"
needs:
- prepare_dependencies
- phpstan
- ecs
- rector
- lint
- validate
- check_licenses
- deptrac
runs-on: ubuntu-24.04
env:
JOSE_ML_DSA_EXPECTED: 'no'
steps:
- uses: actions/checkout@v5
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: openssl, sodium, mbstring, gmp, intl
tools: composer, phpunit:11
coverage: none
- name: Show the OpenSSL the PHP binary loaded
run: |
php -r 'echo PHP_VERSION, " built against ", OPENSSL_VERSION_TEXT, PHP_EOL;'
openssl version
- name: Install dependencies
run: composer install --no-interaction --no-progress
- name: Run PHPUnit
run: phpunit --configuration .ci-tools/phpunit.xml.dist
infection:
name: "🧬 Mutation Testing"
needs: [prepare_dependencies, tests]
# Only the lines added or modified are mutated: those of a pull request, against its base branch, and those of a
# push to a maintenance branch, against the commit before it. A new branch has no commit before it and runs none
# of this. The whole source is mutated by "castor infect" without --diff, by hand: it takes far longer.
if: ${{ github.event_name == 'pull_request' || (github.event_name == 'push' && endsWith(github.ref_name, '.x') && github.event.before != '0000000000000000000000000000000000000000') }}
runs-on: ubuntu-latest
timeout-minutes: 45
container:
image: ghcr.io/spomky-labs/phpqa:8.4
env:
XDEBUG_MODE: coverage
steps:
- uses: actions/checkout@v5
with:
# The diff needs the base branch and the merge base with it, which a shallow clone does not have.
fetch-depth: 0
# The checkout is owned by the user of the runner while the steps run as root in the container: git refuses such
# a repository until it is declared safe, and Infection reads the diff with git.
- name: Trust the checkout
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- uses: actions/cache@v4
with:
path: |
vendor
~/.composer/cache
key: ${{ needs.prepare_dependencies.outputs.cache-key }}
- name: Install dependencies
run: composer install --no-interaction --no-progress
- name: Generate coverage reports
run: |
composer exec -- phpunit-11 \
--coverage-xml .ci-tools/coverage \
--log-junit=.ci-tools/coverage/junit.xml \
--configuration .ci-tools/phpunit.xml.dist
- name: Mutations of the pull request
if: ${{ github.event_name == 'pull_request' }}
run: castor infect --diff --base="origin/${{ github.base_ref }}"
- name: Mutations of the push
if: ${{ github.event_name == 'push' }}
run: castor infect --diff --base="${{ github.event.before }}"
exported_files:
name: "📁 Exported Files Check"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Check exported files
run: |
EXPECTED=".gitsplit.yml,CODE_OF_CONDUCT.md,LICENSE,README.md,SECURITY.md,castor.php,composer.json"
CURRENT=$(git archive HEAD | tar --list | grep -v '/$' | grep -Ev '^(assets|bin|config|fixtures|frankenphp|migrations|public|src|templates|translations)/' | sort | paste -sd "," -)
echo "CURRENT = ${CURRENT}"
echo "EXPECTED = ${EXPECTED}"
if [[ "$CURRENT" != "$EXPECTED" ]]; then
echo "❌ Exported files do not match expected list"
exit 1
fi