python / python/cpython

ipaddress.reverse_pointer returns nonsense if prefixed input is given

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

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

3.10 stdlib type-bug
主要言語
Python
スター
77.2k
フォーク
36k
PR マージ指標
PR 指標を取得中

説明

Bug report

ipaddress.reverse_pointer does not seem to validate its input at all. For example:

$ python3
Python 3.10.4 (main, Apr  2 2022, 09:04:19) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipaddress
>>> ipaddress.ip_network('2001:db8:1:2:3:4:5::/64',False).reverse_pointer
'4.6./.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa'
>>> 

This is very obviously wrong.

In this case of prefixed input, the output should be cut to the appropriate prefix length, yielding
2.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa as output. It is ok to assume /128 as the default, converting 2001:db8:1:2:3:4:5:: to 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa, but input longer than that is an error.

Prefixed address strings are for example important when generating zone names for the server side of IPv6 reverse DNS. Run-of-the-mill network client software is unlikely to use this for addresses shorter than /128, but for the server side it is an important use case.

Greetings
Marc

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

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

はじめの一歩

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

調査の方向性

まず、報告された Python の再現コードを実行し、ipaddress.reverse_pointer のエントリポイントを追跡して、プレフィックス付き入力がどのように処理されるかを理解します。プレフィックス付きの IPv6 入力がプレフィックス長に合わせて切り詰められた逆引きポインター名を生成し、デフォルトのプレフィックスなし入力が /128 として扱われ、/128 より長い入力が拒否されれば完了です。

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

評価

技術スタック
python
領域
networking
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
55/100

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

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