MagicStack / MagicStack/asyncpg

.pgpass file support handles backslash escapes incorrectly; should de-escape values

オープン
#1,249 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
8.1k
フォーク
468
PR マージ指標
30日以内にマージされた PR はありません

説明

https://www.postgresql.org/docs/current/libpq-pgpass.html isn't fully explicit about how to handle backslash escapes in the `.pgpass` file, however it's reasonably clear from the phrasing that backslashes serve only to escape backslashes and colons and therefore aren't considered part of the value they're used in. E.g., a `.pgpass` row of …

```
*:*:test\:db:test\\:password from pgpass with escapes
```

conveys:

- a database name of `test:db`, not `test\:db`
- a user name of `test\`, not `test\\`

I ran into this problem because I have a password of `4:K1…`, encoded as `4\:K1…`, and it works with `psql` but not `asyncpg`. Once I remove the backslash from `.pgpass`, it starts working with `asyncpg` but failing with `psql`.

I would've provided a failing test and even a code change, but I can't get `python setup.py test` or `pip install -e .[test]` to work in a run-of-the-mill Python 3.12 virtualenv on my run-of-the-mill MacOS.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、`python setup.py test` または `pip install -e .[test]` で報告されている Python 3.12 のテストセットアップの問題を解決し、次に asyncpg の `.pgpass` 処理箇所を特定します。エスケープされたコロンとバックスラッシュのテストカバレッジを追加し、それらの値が `psql` と一貫してエスケープ解除されるようになった時点で、この issue は完了と見なします。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
postgresql, python
領域
databases
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。