Skip to content

BinaryContentにCTF向けメタ情報を追加し読み込み上限を設定する#21

Merged
T3pp31 merged 3 commits into
mainfrom
codex/add-fields-to-binarycontent-for-ctf-analysis
May 14, 2026
Merged

BinaryContentにCTF向けメタ情報を追加し読み込み上限を設定する#21
T3pp31 merged 3 commits into
mainfrom
codex/add-fields-to-binarycontent-for-ctf-analysis

Conversation

@T3pp31

@T3pp31 T3pp31 commented May 13, 2026

Copy link
Copy Markdown
Owner

Motivation

  • バイナリ解析でCTF向けに有用なメタデータ(マジックバイト・ハッシュ・文字列候補・フラグ候補・エントロピー・警告など)を取得して表示できるようにするため。
  • 大きなファイルを無制限に全読み込みする挙動をやめ、表示用に設定可能な先頭バイト数だけを読み込みつつ、ハッシュ等はストリーム処理で全体を評価するため。
  • UI側でHex/DecodedだけでなくSummary/Hashes/Magic Bytes/Strings/Flag Candidates/Warningsを表示し、解析結果を見やすくするため。

Description

  • BinaryContentmagic_bytes / file_type_guess / sha256 / sha1 / md5 / printable_strings / flag_candidates / entropy / warnings を追加し、read_binary_fileAppStatebinary 設定を参照するよう変更した(src-tauri/src/commands/binary.rs)。
  • バイナリ解析用設定を表す BinaryConfig 型を src-tauri/src/config.rs に追加し、既定値を src-tauri/config/default.toml に追加した(max_read_bytes, hex_dump_bytes, decoded_text_max_chars, max_strings, min_string_len, magic_bytes_len, max_flag_candidates)。
  • src-tauri/src/utils/binary.rsread_file を設定引数を受け取る形に書き換え、先頭 N バイトのみを読み込む read_prefix、ハッシュとエントロピーをストリーミングで算出する calculate_hashes_and_entropy、マジックバイト抽出、ファイル種別推定、文字列抽出、フラグ候補抽出、デコード表示制限ロジック等を追加した。
  • フロントエンド型 BinaryContent を更新し、src/pages/BinaryPage.tsx を改良して Summary/Hashes/Magic Bytes/Strings/Flag Candidates/Warnings/Hex Dump/Decoded Text のセクションを表示するようにした。
  • Rust 側ユニットテスト(utils::binary の解析挙動・制限動作)とフロントエンドの tests/tauriInvokeArgs.test.tsx を更新/拡張して、新しい BinaryContent の形状と表示を検証するテストを追加した。
  • ハッシュ処理に openssl を利用するため src-tauri/Cargo.toml に依存を追加した。

Testing

  • cargo fmt --check は成功した。
  • フロントエンドの単体テストは npx vitest run tests/tauriInvokeArgs.test.tsx を実行し全テストが成功(5/5)。
  • ビルドと静的検査は npm run buildtsc + vite build)と npm run linteslint)を実行して成功した。
  • Rust のライブラリ単体テスト(cargo test --offline --lib utils::binary)は追加したテストを含むが、実行環境で glib-2.0.pc 相当のシステム依存が不足しており glib-sys のビルドが失敗するため実行できずブロックされた(環境依存の外部ライブラリが原因)。

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1f25fe9af5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src-tauri/src/config.rs
pub network: NetworkConfig,
pub feature_flags: FeatureFlagsConfig,
pub paths: PathsConfig,
pub binary: BinaryConfig,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve existing configs when adding binary defaults

When a user upgrades with an existing config/default.toml that predates this commit and therefore lacks [binary], this new required field makes toml::from_str in AppConfig::load fail; the app startup path then uses unwrap_or_default, so all of the user's customized scan/network/path settings are silently discarded. Add a serde/default fallback for binary (or merge with defaults) so older config files continue to load with only the new binary settings defaulted.

Useful? React with 👍 / 👎.

T3pp31 commented May 14, 2026

Copy link
Copy Markdown
Owner Author

確認しましたが、この PR は現状マージしません。

理由:

対応案:

  1. main に rebase/merge して CI 削除差分を消す。
  2. Add CTF Workspace and Artifact Analyzer (binary analysis, transforms, detectors) #17BinaryContentにCTF向けメタ情報を追加し読み込み上限を設定する #21 のどちらの Binary analysis 実装を採用するか決め、設定テーブル名とハッシュ依存を一本化する。
  3. 採用側に統合したうえで、Rust 側の unit test と frontend の tauriInvokeArgs 系テストを再実行してください。

@T3pp31 T3pp31 merged commit a542aa7 into main May 14, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant