Skip to content

CTF ワークスペースの状態モデルと Writeup エクスポートを追加#20

Merged
T3pp31 merged 4 commits into
mainfrom
codex/add-state-model-for-ctf-workspace
May 14, 2026
Merged

CTF ワークスペースの状態モデルと Writeup エクスポートを追加#20
T3pp31 merged 4 commits into
mainfrom
codex/add-state-model-for-ctf-workspace

Conversation

@T3pp31

@T3pp31 T3pp31 commented May 13, 2026

Copy link
Copy Markdown
Owner

Motivation

  • CTF 調査を整理するためにワークスペースで操作履歴・観察・アーティファクト・フラグ候補を扱える状態モデルと UI が必要だった。
  • 調査結果を Markdown の形式で書き出して共有・保存できる導線を追加するために、書き出し処理と Tauri の保存ダイアログ連携を実装した。

Description

  • src/features/ctf/types.tsCtfWorkspace / CtfArtifact / CtfOperation / CtfObservation / FlagCandidate 等の型を追加し、CtfOperation に操作名・入力概要・出力概要・実行時刻・成功/失敗・メモを持たせた。
  • src/features/ctf/history.ts にワークスペース初期化・操作生成・履歴追加・メモ更新などのヘルパー関数を追加した。
  • src/features/ctf/writeup.tsgenerateCtfWriteupMarkdown を追加し、Challenge / Observations / Steps / Interesting Values / Flag Candidates / Final Flag の章を出力する Markdown 生成を実装した。
  • src/pages/CtfPage.tsx を拡張してワークスペースメモ入力、操作メモ入力フォーム、履歴表示、Writeup プレビュー、および保存ダイアログ経由での Markdown 書き出しボタンを追加した(@tauri-apps/plugin-dialogsave を使用)。
  • Tauri 側で src-tauri/src/commands/ctf.rswrite_ctf_writeup コマンドを追加し、src-tauri/capabilities/default.jsondialog:allow-save を追記して保存許可を追加、src-tauri/src/lib.rs の invoke ハンドラにコマンドを登録した。

Testing

  • npm run build を実行してビルドが成功したことを確認した(成功)。
  • npm run lint を実行して ESLint チェックが通ったことを確認した(成功)。
  • cargo fmt --manifest-path src-tauri/Cargo.toml を実行してフォーマットを整えた(成功)。
  • cargo check --manifest-path src-tauri/Cargo.toml を実行したが、ビルド環境に glib-2.0glib-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: c5d54828c1

ℹ️ 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 on lines +45 to +48
listItems(
workspace.operations.map(
(operation) =>
`**${operation.name}** (${operation.status}, ${formatDateTime(operation.executedAt)})\n - Input: ${normalizeLines(operation.inputSummary)}\n - Output: ${normalizeLines(operation.outputSummary)}\n - Notes: ${normalizeLines(operation.notes)}`

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 Sort exported steps chronologically

When a user records multiple operations, appendCtfOperation prepends each new item to workspace.operations, so mapping this array directly exports the writeup's ## Steps in reverse order. For example, adding reconnaissance and then exploitation will produce a writeup that lists exploitation before reconnaissance, which makes the exported solution misleading; sort by executedAt or reverse the array for the writeup while keeping the UI history order if desired.

Useful? React with 👍 / 👎.

T3pp31 commented May 14, 2026

Copy link
Copy Markdown
Owner Author

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

理由:

  • main の最新状態にある CI 関連ファイルを削除する差分が入っています。ローカルで origin/main..origin/pr/20 を確認すると、.github/workflows/ci.ymltests/ciWorkflowConsistency.test.mjstests/readmeConsistency.test.mjs などが削除対象になっていました。まず main を取り込んで、CI と整合性テストを維持してください。
  • src/pages/CtfPage.tsxsrc/features/ctf/types.ts / history.ts / writeup.tsAdd CTF Workspace and Artifact Analyzer (binary analysis, transforms, detectors) #17CTF 定義をページから分離して features/ctf モジュール群へ移動 #19CTFワークスペースを追加 #22 と重複しています。CTF workspace の状態モデルをこの PR で採用するなら、他 PR の CTF API と統合方針を決める必要があります。
  • appendCtfOperationoperations: [operation, ...workspace.operations] で履歴を新しい順に保持していますが、generateCtfWriteupMarkdown はその配列順のまま Steps を出力しています。このままだと writeup の手順が実行順ではなく逆順になり、報告書として読みにくくなります。

対応案:

  1. main に rebase/merge して CI 削除差分を消す。
  2. Writeup 出力時は executedAt 昇順、または履歴保存順と表示順の意図を明示してテストで固定する。
  3. Add CTF Workspace and Artifact Analyzer (binary analysis, transforms, detectors) #17/CTF 定義をページから分離して features/ctf モジュール群へ移動 #19/CTFワークスペースを追加 #22 との CTF 型・ページ実装の重複を整理してください。

@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: 5cd24d35dc

ℹ️ 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".

listItems(
chronologicalOperations.map(
(operation) =>
`**${operation.name}** (${operation.status}, ${formatDateTime(operation.executedAt)})\n - Input: ${normalizeLines(operation.inputSummary)}\n - Output: ${normalizeLines(operation.outputSummary)}\n - Notes: ${normalizeLines(operation.notes)}`

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 multiline step text inside the list

When an operation summary or notes field contains line breaks (the UI uses textareas for these fields), normalizeLines preserves those newlines and this interpolation only indents the first line after Input:, Output:, or Notes:. The continuation lines are emitted at column 0, so exported Markdown breaks out of the nested step list and can turn pasted command output into unrelated paragraphs/headings instead of part of the recorded operation; indent or fence multiline values before inserting them into the list.

Useful? React with 👍 / 👎.

@T3pp31 T3pp31 merged commit d24292b into main May 14, 2026
1 check 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