fix(widgets): shodan 監査の応答解釈エラーを診断可能にし簡易表示で回避できるようにする - #37
Merged
Conversation
yami.ski の監査で「ホスト情報を解釈できませんでした」に当たった。 HTTP 200 かつ本文が文字列でありながら JSON として壊れている状態だが、 旧メッセージは何が返ってきたのかを一切出さないため利用者も作者も 原因を切り分けられなかった。 - 応答の要約 (本文の長さと先頭 60 文字、非文字列ならその型) を表示する。 本文は外部由来なのでサニタイズしてから出す - Shodan の minify=true で取り直す導線を追加。応答が大きすぎて途中で 切れている場合に通ることがある。バナー詳細が落ちるためポートと CVE のみになるので、結果に「簡易表示」と明記する。追加で 1 クレジット 消費するので自動再取得はせず、ボタンで利用者に選ばせる - jsonOf を堅牢化。Json:parse は非文字列を渡すと例外で落ちるため型を 見てから呼び、本文が既にパース済みで返る Vault 実装にも対応する AiScript 1.2.1 の実インタプリタで 11 系統を回帰 (既存 9 + 応答切れ + 本文オブジェクト)。全系統で実行時エラー 0 件、簡易表示ボタン押下後の 復旧とキャッシュ経路のクレジット消費ゼロも確認した。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
misstore | 2643f81 | Aug 09 2026, 10:10 AM |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe Shodan Instance Audit widget now handles parsed and malformed responses, supports minified host retrieval, records minified results, and offers corresponding UI actions. Registry timestamps and widget release metadata were updated. ChangesShodan audit retrieval update
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant AuditView
participant runAudit
participant ShodanHostEndpoint
participant jsonOf
AuditView->>runAudit: request audit
runAudit->>ShodanHostEndpoint: fetch host details with optional minify=true
ShodanHostEndpoint-->>runAudit: response body
runAudit->>jsonOf: parse or validate response body
jsonOf-->>runAudit: parsed audit data or sanitized diagnostic
runAudit-->>AuditView: render result or minified retry action
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#36 の追従修正。
なぜ
実運用インスタンス (yami.ski) の監査で
ホスト情報を解釈できませんでしたに当たった。エラーの発生条件から状態はここまで絞り込める:
Json:parseは非文字列だと例外で落ちるため、穏やかなエラー画面が出た時点で文字列だったと確定する)
/dns/resolveは同じ Vault 接続で成功して IP まで取れているので、認証・接続設定・API キーは正常。大きい方の
/shodan/hostの応答だけが壊れている。Json:parse自体は 5MB の Shodan 形式 JSON でも問題なく処理できることを実測したので、AiScript 側の限界ではない。転送層で応答が途中で切れているのが最有力。
ただし旧コードは何が返ってきたのかを一切表示しないため、利用者も作者も
そこから先を切り分けられなかった。そこが本質的な欠陥だった。
何を直したか
1. 応答の診断表示
何が返ってきたのかを出す。本文は外部由来なのでサニタイズしてから表示する。
切断なのか、HTML が返っているのか、別の何かなのかが一目で分かる。
2. 簡易表示 (minify) での回避
応答が壊れたときだけ「簡易表示で取得 (1 クレジット)」を出す。Shodan の
minify=trueは大きいフィールドを切り詰めて返すので、切断が原因なら通る。バナー詳細が落ちるため稼働サービスと TLS は出ないが、ポートの危険度判定と CVE は残る。
結果には「簡易表示」と明記する。
追加で 1 クレジット消費するので自動再取得はしない。 押すかどうかは利用者が選ぶ
(#36 のクレジット方針を維持)。
3.
jsonOfの堅牢化Json:parseは非文字列を渡すと例外で落ちるため型を見てから呼ぶ。本文が既にパース済みオブジェクトで返る Vault 実装にも対応した。
検証
AiScript 1.2.1 の実インタプリタで 11 系統を回帰(#36 の 9 系統 + 応答切れ +
本文オブジェクト)。全系統で実行時エラー 0 件。
簡易表示ボタン押下後に監査結果へ復帰することと、キャッシュ経路のクレジット消費が
ゼロのままであることも実際にクリックを再現して確認した。
version: 1.0.1 → 1.0.2
残っている不確定要素
真の原因はまだ確定していない。マージ後に実機のエラー画面に出る「応答:」の行を見れば、
切断なのか別要因なのかが判明する。切断で確定すれば恒久対策 (分割取得など) を別途検討する。
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Chores