-
Notifications
You must be signed in to change notification settings - Fork 0
fix(cli): narrow parse_subnet_option/1 spec to the value it returns #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -236,7 +236,24 @@ defmodule Tdig.CLI do | |
| |> Map.put(:options, [ecs_option]) | ||
| end | ||
|
|
||
| @spec parse_subnet_option(String.t()) :: {atom(), map()} | ||
| @typedoc """ | ||
| An EDNS Client Subnet option, shaped as `Tenbin.DNS` expects in `:options`. | ||
|
|
||
| `family` is 1 for IPv4 and 2 for IPv6 (RFC 7871). `source_prefix` is the | ||
| prefix length given on the command line, capped at the family's width; | ||
| `scope_prefix` is always 0 in a query, and only a response carries a | ||
| meaningful value. | ||
| """ | ||
| @type edns_client_subnet :: | ||
| {:edns_client_subnet, | ||
| %{ | ||
| family: 1 | 2, | ||
| client_subnet: :inet.ip_address(), | ||
| source_prefix: integer(), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ [LOW]
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 「実装が本当に任意の integer を返し得るのであれば現状で問題ありません」という条件のほうが成立していました。実測です。
したがって ただし指摘の背後にある「負の prefix は本来受け付けるべきでない」という点は妥当で、これは spec ではなく入力検証の欠落です。値域外を弾くのかクランプするのかは挙動の変更を伴うため、本 PR(Dialyzer の解消)とは分けて #86 に起票しました。 |
||
| scope_prefix: 0 | ||
| }} | ||
|
|
||
| @spec parse_subnet_option(String.t()) :: edns_client_subnet() | ||
| def parse_subnet_option(subnet) do | ||
| case String.split(subnet, "/") do | ||
| [addr_str, prefix_str] -> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨ [POSITIVE]
tdigから/tdigへの修正は、lib/tdig/ディレクトリ配下の新規ファイルが暗黙に無視される問題を的確に解消しており、コメントで理由も明記されている点が非常に良いです。