fix(security): fix alembic.ini placeholder database URL (#44)#143
Merged
YaronZaki merged 3 commits intoJun 19, 2026
Merged
Conversation
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #44 — the
alembic.inihad a literal placeholder URL (driver://user:pass@localhost/dbname) that posed a security scanner false-positive risk and could silently connect to wrong hosts if the env-var override path failed.Changes
quantara/web_app/alembic.ini: Replacedsqlalchemy.url = driver://user:pass@localhost/dbnamewithsqlalchemy.url = REPLACE_MEsentinel — an invalid URL that guarantees Alembic fails fast if the env-var override path is ever skipped.quantara/web_app/alembic/env.py: Replaced the import ofget_database_url()with a self-contained_build_db_url()that:DB_USER,DB_PASSWORD,DB_HOST,DB_PORT,DB_NAMEfrom environmentRuntimeErrorwith a clear list of missing variables when any required var is absentDB_PORTto5432quantara/web_app/tests/test_alembic_env.py(new): 4 unit tests covering correct URL construction, default port fallback, the sentinel value assertion, and presence of all components in the URL.How CI passes
CI sets
DB_HOST=localhost,DB_USER=postgres,DB_PASSWORD=password,DB_NAME=quantaraas env vars._build_db_url()finds all required vars and constructspostgresql://postgres:password@localhost:5432/quantara. The migration round-trip test andalembic upgrade headstep both work correctly.Test plan
test_alembic_ini_sentinel_value— asserts placeholder is gone andREPLACE_MEis presenttest_get_database_url_constructs_correctly— full URL with all varstest_get_database_url_default_port— port defaults to 5432test_get_database_url_includes_all_components— each component in URLCloses #44
🤖 Generated with Claude Code