Skip to content

Fix Multi AI Audit consensus findings (12 issues)#4

Merged
kwrkb merged 4 commits intomainfrom
fix/multi-ai-audit-consensus
Feb 28, 2026
Merged

Fix Multi AI Audit consensus findings (12 issues)#4
kwrkb merged 4 commits intomainfrom
fix/multi-ai-audit-consensus

Conversation

@kwrkb
Copy link
Copy Markdown
Owner

@kwrkb kwrkb commented Feb 28, 2026

Summary

Multi AI Audit (Claude + Gemini + Codex) で検出された Consensus findings 12件を修正。

High

  • run_app.sh: PYTHONPATH 設定 + python3 -m sqliteviewer に変更(相対インポート失敗を修正)
  • build_deb.sh ランチャー: 同様に -m 起動に修正

Medium

  • build_deb.sh: バージョンを pyproject.toml から動的取得、python3-pyqt6 依存追加
  • mainwindow.py: _refresh_after_write でサブストリングマッチ廃止→DML後は無条件リフレッシュ
  • database.py: _strip_sql_noise に拡張し文字列リテラル内 WHERE によるバイパスを防止
  • resources/init.py: as_file() コンテキスト外パス参照問題を修正
  • test_database.py: エラーパステスト5件追加

Low

  • database.py: 未使用 field import 削除
  • resources/init.py: 未使用 Path, Optional import 削除
  • sql_highlighter.py: 96個の正規表現を1パターンに統合
  • app.py: プレースホルダドメイン example.com 削除

Test plan

  • uv run python -m pytest tests/ -v — 全15テスト pass

🤖 Generated with Claude Code

Address all consensus findings (2+ AI agreement) from Multi AI Audit:

- [High] Fix run_app.sh: use PYTHONPATH + python3 -m for proper module loading
- [High] Fix build_deb.sh launcher: same PYTHONPATH + -m approach
- [Medium] build_deb.sh: read version from pyproject.toml, add python3-pyqt6 dep
- [Medium] Fix _refresh_after_write: unconditionally refresh on DML
- [Medium] Improve destructive query detection: strip string literals before WHERE check
- [Medium] Add error path tests (empty query, invalid SQL, no connection, bad path)
- [Medium] Fix resources path: avoid as_file() context escape
- [Low] Remove unused imports (field, Path, Optional)
- [Low] Optimize SQL highlighter: consolidate 96 regex patterns into one
- [Low] Remove placeholder domain example.com

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

このプルリクエストは、Multi AI Audit (Claude + Gemini + Codex) によって特定された12件のコンセンサス所見に対処します。主な目的は、アプリケーションの堅牢性を向上させ、ビルドプロセスを合理化し、SQL解析の正確性を高め、UIのリフレッシュ動作を改善することです。これにより、潜在的なバグが修正され、コードベースの全体的な品質と保守性が向上します。

Highlights

  • ビルドスクリプトと実行スクリプトの改善: run_app.sh と build_deb.sh のランチャーが、相対インポートの失敗を修正するため、PYTHONPATH を設定し、python3 -m sqliteviewer を使用するように変更されました。
  • ビルドプロセスの動的化と依存関係の追加: build_deb.sh が pyproject.toml からバージョンを動的に取得し、python3-pyqt6 の依存関係が追加されました。
  • SQL解析ロジックの強化: database.py の _strip_sql_noise メソッドが拡張され、文字列リテラル内の 'WHERE' 句によるバイパスを防ぐようになりました。
  • UIリフレッシュ動作の簡素化: mainwindow.py で、DMLクエリ後のテーブルプレビューのリフレッシュロジックから、影響を受けるテーブル名のサブストリングマッチングが削除され、DML後は無条件にリフレッシュされるようになりました。
  • リソースパス解決の修正: resources/init.py で、as_file() コンテキスト外でのパス参照に関する問題が修正されました。
  • エラーパステストの追加: test_database.py に、データベース操作のエラー処理に関する5つの新しいテストが追加されました。
  • コードのクリーンアップと最適化: 未使用のインポートが削除され、sql_highlighter.py で96個の正規表現が1つのパターンに統合されるなど、複数のファイルでコードのクリーンアップと最適化が行われました。

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • scripts/build_deb.sh
    • ビルドバージョンを pyproject.toml から動的に取得するように更新されました。
    • Debianパッケージの依存関係に python3-pyqt6 が追加されました。
    • ランチャースクリプトが PYTHONPATH を設定し、python3 -m sqliteviewer を使用するように変更されました。
  • scripts/run_app.sh
    • アプリケーションの実行方法が PYTHONPATH を設定し、python3 -m sqliteviewer を使用するように変更されました。
  • src/sqliteviewer/app.py
    • プレースホルダの組織ドメイン 'example.com' が削除されました。
  • src/sqliteviewer/database.py
    • 未使用の 'field' インポートが削除されました。
    • _strip_sql_comments メソッドが _strip_sql_noise にリネームされ、SQLコメントだけでなく文字列リテラルも除去するように拡張されました。
    • is_destructive_query メソッドが更新された _strip_sql_noise を使用するように変更されました。
  • src/sqliteviewer/mainwindow.py
    • DMLクエリ後のテーブルプレビューのリフレッシュロジックから、影響を受けるテーブル名のサブストリングマッチングが削除され、DML後は無条件にリフレッシュされるようになりました。
  • src/sqliteviewer/resources/init.py
    • 未使用の 'Path' および 'Optional' インポートが削除されました。
    • resource_path 関数が resources.as_file コンテキストマネージャを使用せず、直接パスを返すように簡素化されました。
  • src/sqliteviewer/sql_highlighter.py
    • SQLキーワードのハイライト処理が、96個の個別の正規表現パターンをループする代わりに、単一の統合された正規表現パターンを使用するように最適化されました。
  • tests/test_database.py
    • DatabaseService のエラー処理に関する新しいテストが複数追加されました。これには、空のクエリ、無効なSQL、データベースがオープンされていない状態での操作、存在しないファイルのオープン、および文字列リテラル内の WHERE 句を含む is_destructive_query のテストが含まれます。
Activity
  • uv run python -m pytest tests/ -v コマンドで全15テストがパスしました。
  • このPRはClaude Codeによって生成されました。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

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

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: fd01680ac3

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

BUILD_DIR="$DIST_DIR/deb_build"
PACKAGE="sqliteview"
VERSION="0.2.1"
VERSION=$(python3 -c "import tomllib; print(tomllib.load(open('$ROOT_DIR/pyproject.toml','rb'))['project']['version'])")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restore Python 3.10 compatibility in version parsing

The new VERSION=$(python3 -c "import tomllib; ...") line requires tomllib, which is only available in Python 3.11+, so scripts/build_deb.sh now fails immediately on Python 3.10 build hosts with ModuleNotFoundError. This is a regression against the repository/package requirement of python >= 3.10, and it blocks generating the Debian package in a supported environment (e.g., Ubuntu 22.04 default Python).

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

このプルリクエストは、AI監査によって検出された12件の問題を修正し、動的なバージョン取得、依存関係の追加、SQLインジェクションの脆弱性修正、UIの更新ロジック改善、テストの追加を通じて、コードの堅牢性を大幅に向上させています。しかし、database.pyにおける破壊的なクエリチェックをバイパスする修正は不完全であり、単一引用符の文字列のみを処理し、二重引用符の識別子、バッククォート、角括弧など、SQLiteステートメントにキーワードを埋め込む他の方法を見落としているため、依然として重要なセキュリティ脆弱性が残っています。さらに、ビルドプロセスとリソースの読み込みに関して2つの潜在的な問題が特定されました。これらの点を修正することで、アプリケーションの安定性がさらに向上するでしょう。

BUILD_DIR="$DIST_DIR/deb_build"
PACKAGE="sqliteview"
VERSION="0.2.1"
VERSION=$(python3 -c "import tomllib; print(tomllib.load(open('$ROOT_DIR/pyproject.toml','rb'))['project']['version'])")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

この変更では tomllib を使って pyproject.toml からバージョンを取得していますが、tomllib は Python 3.11 で標準ライブラリに追加されたモジュールです。pyproject.tomlrequires-python>=3.10 となっており、Python 3.10 の環境でこのビルドスクリプトを実行すると ModuleNotFoundError: No module named 'tomllib' エラーで失敗してしまいます。

Python 3.10 との互換性を保つために、tomli パッケージ(tomllib の前身)をフォールバックとして使用することをお勧めします。以下のように一行で修正できます。

Suggested change
VERSION=$(python3 -c "import tomllib; print(tomllib.load(open('$ROOT_DIR/pyproject.toml','rb'))['project']['version'])")
VERSION=$(python3 -c "try: import tomllib except ImportError: import tomli as tomllib; print(tomllib.load(open('$ROOT_DIR/pyproject.toml','rb'))['project']['version'])")

kwrkb and others added 3 commits February 28, 2026 09:10
Past PRs で繰り返し発生した修正パターンをルール化:
- 未使用 import の即時削除
- セキュリティチェックの初回網羅実装
- python3 -m によるランチャー起動
- pyproject.toml を SSOT としたバージョン管理
- 変更の波及先確認チェックリスト
- uv によるPython環境統一

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- build_deb.sh: tomllib (Python 3.11+) を grep/sed に置換して Python 3.10 互換性を復元
- database.py: _strip_sql_noise でダブルクォート識別子も除去対象に追加
- test_database.py: ダブルクォート識別子内の WHERE キーワードに対するテスト追加

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- セキュリティチェックルールにダブルクォート識別子を追加
- バージョン取得ルールにPython最低バージョン互換性の注意を追加
- PLAN.mdの記述を実態に合わせて修正

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kwrkb kwrkb merged commit 2d414c4 into main Feb 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant