url_allowlist only works against DATABASE_URL
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
調査の方向性
まず Safeguard の url_allowlist の処理と cleaners がどのように呼び出されるかを追跡し、次に database_cleaner-active_record の ActiveRecord 接続と比較します。database.yml または DATABASE_URL から実際に使用されている接続を safeguard が確認し、ENV['DATABASE_URL'] のみに依存しないようになれば完了です。これには、その変数が未設定の場合も含まれます。
索引モデルが issue の本文から書いたものです。
説明
I debated filing this against database_cleaner-active_record, but after digging in a bit I think it would need a more comprehensive fix.
I have a Rails app running in a Docker stack, where under test, the database is configured the old-fashioned way in database.yml rather than with ENV['DATABASE_URL'] -- or rather, both are supported, but if DATABASE_URL isn't set, it falls back to a hard-coded value.
test:
url: <%= ENV['DATABASE_URL'] ||'postgres://root:root@db/framework-test?pool=5' %>
I wanted a safeguard that would work both with the Docker stack in CI, or for a developer setting up a test database locally or on some other database server, so I assumed I had to set url_allowlist. My first attempt was this lambda:
DatabaseCleaner.url_allowlist = [
->(url) { URI.parse(url).path.end_with?('framework-test') }
]
This blows up, though, because the URL that gets passed here is ENV['DATABASE_URL'], and URI.parse(nil) fails.
My next concern was that DatabaseCleaner would truncate the database at ENV['DATABASE_URL'] (if it exists) rather than the one ActiveRecord is actually using in tests. Thankfully database_cleaner-active_record is smarter than that, and it's using the ActiveRecord connection.
But it seems like if that's how it actually works, Safeguard should somehow hook into that, rather than relying on ENV['DATABASE_URL']. Maybe instead of running once before all cleaners, it should be run per-cleaner, and the cleaner implementations should be responsible for providing the URL they're actually using?
- 主要言語
- Ruby
- スター
- 3k
- フォーク
- 485
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
DatabaseCleaner/database_cleaner のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 67/100
-
Cleaning of dev DBオープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
Cannot truncate a table referenced in a foreign key constraint (ActiveRecord::StatementInvalid)オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
DatabaseCleaner/database_cleaner#717 · コメント 5 件 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
DatabaseCleaner/database_cleaner#716 · コメント 2 件 ·
DatabaseCleaner/database_cleaner の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
yegor256/rubocop-elegant#92 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
ecosyste-ms/awesome#812 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
forem/forem#23933 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
rails/mission_control-jobs#347 ·
-
PROJECT: ILR/DRS
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
thewca/worldcubeassociation.org#15914 ·
メンテナーはふだん 1 日以内に返信