Skip to content

Fix authentication bypass on /v1/shape via path-normalization mismatch #1653

Fix authentication bypass on /v1/shape via path-normalization mismatch

Fix authentication bypass on /v1/shape via path-normalization mismatch #1653

name: sync-service
on:
push:
branches: ['main']
paths:
- 'packages/electric-telemetry/**'
- 'packages/sync-service/**'
- '.github/workflows/sync_service_tests.yml'
pull_request:
paths:
- 'packages/electric-telemetry/**'
- 'packages/sync-service/**'
- '.github/workflows/sync_service_tests.yml'
permissions:
contents: read
jobs:
build_and_test:
name: 'Build and test sync-service, pg${{ matrix.postgres_version }}'
runs-on: blacksmith-4vcpu-ubuntu-2404
defaults:
run:
working-directory: packages/sync-service
strategy:
fail-fast: false
matrix:
postgres_version: [14, 15, 17, 18]
env:
MIX_ENV: test
MIX_TARGET: application
POSTGRES_VERSION: '${{ matrix.postgres_version }}0000'
CODECOV_FLAGS: elixir,unit-tests,sync-service,postgres-${{ matrix.postgres_version }}0000
CODECOV_TEST_RESULTS_FILES: ./junit/regular-test-junit-report.xml,./junit/telemetry-test-junit-report.xml
services:
postgres:
image: 'ghcr.io/${{ github.repository }}/postgres:${{ matrix.postgres_version }}-alpine-logical'
env:
POSTGRES_PASSWORD: password
options: &postgres_health_check >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 54321:5432
pgbouncer: &pgbouncer_service
image: bitnamilegacy/pgbouncer:latest
env:
PGBOUNCER_AUTH_TYPE: trust
PGBOUNCER_DATABASE: '*'
PGBOUNCER_POOL_MODE: transaction
POSTGRESQL_HOST: postgres
POSTGRESQL_DATABASE: electric
POSTGRESQL_USERNAME: postgres
POSTGRESQL_PASSWORD: password
ports:
- 65432:6432
steps:
- &checkout_source
uses: actions/checkout@v4
- &seed_database
name: Seed the database
run: psql -d postgresql://postgres:password@localhost:54321/postgres?sslmode=disable -f dev/init.sql
- &setup_beam
uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: '.tool-versions'
- &cache_dependencies
name: Cache dependencies
uses: actions/cache@v4
with:
path: packages/sync-service/deps
key: "${{ runner.os }}-${{ hashFiles('.tool-versions') }}-sync-service-deps-${{ env.MIX_ENV }}-${{ hashFiles('packages/sync-service/mix.lock') }}"
restore-keys: |
${{ runner.os }}-${{ hashFiles('.tool-versions') }}-sync-service-deps-${{ env.MIX_ENV }}-${{ hashFiles('packages/sync-service/mix.lock') }}
${{ runner.os }}-${{ hashFiles('.tool-versions') }}-sync-service-deps-${{ env.MIX_ENV }}
${{ runner.os }}-${{ hashFiles('.tool-versions') }}-sync-service-deps
- &cache_compiled_code
name: Cache compiled code
uses: actions/cache@v4
with:
path: |
packages/sync-service/_build/*/lib
!packages/sync-service/_build/*/lib/electric
!packages/sync-service/_build/*/lib/electric_telemetry
key: "${{ runner.os }}-${{ hashFiles('.tool-versions') }}-sync-service-build-${{ env.MIX_ENV }}-${{ hashFiles('packages/sync-service/mix.lock') }}"
restore-keys: |
${{ runner.os }}-${{ hashFiles('.tool-versions') }}-sync-service-build-${{ env.MIX_ENV }}-${{ hashFiles('packages/sync-service/mix.lock') }}
${{ runner.os }}-${{ hashFiles('.tool-versions') }}-sync-service-build-${{ env.MIX_ENV }}
${{ runner.os }}-${{ hashFiles('.tool-versions') }}-sync-service-build
- &install_dependencies
name: Install dependencies
run: mix do deps.get + deps.compile
- &compile_package
name: Compile package
run: mix compile
- name: Run tests
run: mix coveralls.json --include slow --cover --export-coverage test
- name: Upload coverage reports to CodeCov
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: ${{ env.CODECOV_FLAGS }}
files: ./cover/excoveralls.json
- &upload_test_results_to_codecov
name: Upload test results to CodeCov
uses: codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706
if: ${{ !cancelled() }}
env:
DUMMY_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}-dummy
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
flags: ${{ env.CODECOV_FLAGS }}
files: ${{ env.CODECOV_TEST_RESULTS_FILES }}
oracle_property_test:
name: 'Oracle property test, pg17'
runs-on: blacksmith-4vcpu-ubuntu-2404
defaults:
run:
working-directory: packages/sync-service
env:
MIX_ENV: test
MIX_TARGET: application
POSTGRES_VERSION: '170000'
CODECOV_FLAGS: elixir,oracle-tests,sync-service,postgres-170000
CODECOV_TEST_RESULTS_FILES: ./junit/regular-test-junit-report.xml
CHECK_TIMEOUT: 60000
SHAPE_COUNT: 200
MUTATIONS_PER_TXN: 10
TXNS_PER_BATCH: 10
BATCH_COUNT: 50
SKIP_REPATCH_PREWARM: 'true'
services:
postgres:
image: 'ghcr.io/${{ github.repository }}/postgres:17-alpine-logical'
env:
POSTGRES_PASSWORD: password
options: *postgres_health_check
ports:
- 54321:5432
pgbouncer: *pgbouncer_service
steps:
- *checkout_source
- *seed_database
- *setup_beam
- *cache_dependencies
- *cache_compiled_code
- *install_dependencies
- *compile_package
- name: Run oracle property test
run: mix test --only oracle test/integration/oracle_property_test.exs
- *upload_test_results_to_codecov
oracle_property_test_with_restarts:
name: 'Oracle property test with restarts (${{ matrix.restart_type }})'
runs-on: blacksmith-4vcpu-ubuntu-2404
defaults:
run:
working-directory: packages/sync-service
strategy:
fail-fast: false
matrix:
restart_type: [graceful, brutal]
env:
MIX_ENV: test
MIX_TARGET: application
POSTGRES_VERSION: '170000'
CODECOV_FLAGS: elixir,oracle-tests,sync-service,postgres-170000
CODECOV_TEST_RESULTS_FILES: ./junit/regular-test-junit-report.xml
CHECK_TIMEOUT: 60000
SHAPE_COUNT: 200
MUTATIONS_PER_TXN: 10
TXNS_PER_BATCH: 10
BATCH_COUNT: 50
SKIP_REPATCH_PREWARM: 'true'
RESTART_SERVER_EVERY: 3
RESTART_TYPE: ${{ matrix.restart_type }}
TEST_POOL_SIZE: 20
services:
postgres:
image: 'ghcr.io/${{ github.repository }}/postgres:17-alpine-logical'
env:
POSTGRES_PASSWORD: password
options: *postgres_health_check
ports:
- 54321:5432
pgbouncer: *pgbouncer_service
steps:
- *checkout_source
- *seed_database
- *setup_beam
- *cache_dependencies
- *cache_compiled_code
- *install_dependencies
- *compile_package
- name: Run oracle property test with ${{ matrix.restart_type }} server restarts
run: mix test --only oracle test/integration/oracle_property_test.exs
- *upload_test_results_to_codecov
performance_test:
name: 'Performance test, pg17'
runs-on: blacksmith-4vcpu-ubuntu-2404
defaults:
run:
working-directory: packages/sync-service
env:
MIX_ENV: test
MIX_TARGET: application
POSTGRES_VERSION: '170000'
CODECOV_FLAGS: elixir,performance-tests,sync-service,postgres-170000
CODECOV_TEST_RESULTS_FILES: ./junit/regular-test-junit-report.xml
services:
postgres:
image: 'ghcr.io/${{ github.repository }}/postgres:17-alpine-logical'
env:
POSTGRES_PASSWORD: password
options: *postgres_health_check
ports:
- 54321:5432
pgbouncer: *pgbouncer_service
steps:
- *checkout_source
- *seed_database
- *setup_beam
- *cache_dependencies
- *cache_compiled_code
- *install_dependencies
- *compile_package
- name: Run performance test
run: SKIP_REPATCH_PREWARM=true mix test --only performance
- *upload_test_results_to_codecov