ホストしている Phoenix を Sentry で監視する中でみつけた、クライアントエラーとなった(不正アクセスへの)処理を以下にまとめます。
Plug.Static.InvalidPathError
Sentry の MESSAGE
(Plug.Static.InvalidPathError invalid path for static asset)
どのパスへのリクエストで発生したかが分からないメッセージですが、 https://github.com/elixir-plug/plug/pull/1098/files で改良されるようです。
起きる要因
パスに無効な文字列を含むリクエスト等で発生します。
再現方法
GET http://localhost:4000/assets/:
※assets は Plug.Static で公開しているディレクトリ
レスポンスステータス: 400
Phoenix.NotAcceptableError
Sentry の MESSAGE
(Phoenix.NotAcceptableError no supported media type in accept header.
Expected one of ["html"] but got the following formats:
*
To accept custom formats, register them under the :mime library
in your config/config.exs file:
config :mime, :types, %{
"application/xml" => ["xml"]
}
And then run `mix deps.clean --build mime` to force it to be recompiled.
)
起きる要因
サポートしない Accept ヘッダー でのリクエストにより発生します。今回のケースは Accept ヘッダーの 値が *
再現方法
サポートしない Accept ヘッダーを付与して
GET http://localhost:4000
レスポンスステータス: 406