Skip to content

区分の判定: 実測でコミュニティ管理者のみ到達する行も管理者向けとして扱う - #1968

Merged
mhaya merged 1 commit into
develop_v2.0.5from
fix/api-inventory-patch-content-type
Nov 3, 2026
Merged

mhaya merged 1 commit into
develop_v2.0.5from
fix/api-inventory-patch-content-type

Conversation

@mhaya

@mhaya mhaya commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

概要

API 台帳の区分判定(tools/api-inventory/scripts/prioritize.py)で、管理者向けの行の認識を実測ベースに広げる。

従来は admin 行を admin-role-table/admin-access/要(管理) の auth 文字列だけで認識しており、session+role:…Administrator や action-need:…-access で制限される行を見落として、コミュニティ管理者の管轄確認(P3b)に回せていなかった。

変更

  • comadmin_only_reach(c, H) を追加。実測で一般ユーザと Contributor がともに遮断され、コミュニティ管理者が到達する行を判定する(auth 文字列に依らない)。
  • community_related と管理者分岐のゲートに加え、該当行を P3b(管轄確認)へ振り分ける。
  • auth 文字列で admin を広げると item-access/author-access/index:update など一般・Contributor も持つ権限アクションを誤判定するため、実測ベースにした。一般/Contributor が到達する行では発火しないので誤爆しない。

効果

管理者向けで実測上コミュニティ管理者だけが到達する行が、確実に P3b(管轄の確認・後回し)に分類され、即対応バケツ(P2x)から分離される。

動作確認

フルチェーンを回し、対象行のみ P2x→P3b に移り、一般/Contributor が到達する行(例: item-access/author-access/index:update 系)は不変、reconcile ゲート ✅ を確認。

🤖 Generated with Claude Code

Summary by Sourcery

実測でコミュニティ管理者のみ到達する行を管理者向けとして扱い、適切にP3bへ振り分ける。

New Features:

  • 実測結果に基づき、一般ユーザとContributorが遮断されコミュニティ管理者のみ到達する行を管理者向けとして判定する。

Bug Fixes:

  • 認証文字列に依存していたため見落としていたコミュニティ管理者限定の行を、P2xではなくP3b(管轄確認)へ分類する。

Enhancements:

  • 一般ユーザまたはContributorも到達する権限アクションを管理者向けと誤判定しないよう、実測ベースの判定を分類ゲートへ統合する。

管理者向けの行を admin-role-table/admin-access/要(管理) の auth 文字列だけで
認識していたため、session+role:…Administrator や action-need:…-access で
制限される行を見落とし、コミュニティ管理者の越境の確認(P3b)に回せていなかった。

- comadmin_only_reach(c,H) を追加: 実測で一般ユーザと Contributor がともに
  遮断され、コミュニティ管理者が到達する行を判定する(auth 文字列に依らない。
  一般/Contributor も持ちうる権限アクションを管理者向けと誤判定しない)。
- community_related と管理者分岐のゲートに加え、該当行を P3b に振り分ける。
  一般/Contributor が到達する行では発火しないため誤爆しない。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Sorry @mhaya, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 days and 14 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 865167f1-8ea3-452d-9437-4e37863e0c9b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@sourcery-ai

sourcery-ai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Reviewer's Guide

API 台帳の区分判定を実測ベースに拡張し、一般ユーザと Contributor が遮断されコミュニティ管理者のみ到達する行を、auth 文字列に依存せずコミュニティ管理者の管轄確認である P3b に振り分けるようにした。一般・Contributor も到達する権限アクションは対象外のまま維持される。

Sequence diagram for measurement-based P3b routing

sequenceDiagram
    participant C as API inventory row
    participant R as comadmin_only_reach
    participant D as dynamic_verified
    participant A as comadmin_reach
    participant P as classify_full

    P->>R: comadmin_only_reach(c, H)
    R->>D: field(c, H, dynamic_verified)
    D-->>R: general and contributor results
    alt both roles are blocked
        R->>A: comadmin_reach(c, H)
        A-->>R: reach
        R-->>P: true
        P->>C: community_related(c, H)
        C-->>P: true
        P-->>C: P3b
    else either role reaches or comadmin is blocked
        R-->>P: false
        P-->>C: preserve existing classification
    end
Loading

Flow diagram for measurement-based administrator classification

flowchart TD
    A[API inventory row] --> B[comadmin_only_reach]
    B --> C{general and contributor both blocked?}
    C -- No --> D[Existing classification]
    C -- Yes --> E{comadmin_reach equals reach?}
    E -- No --> D
    E -- Yes --> F[community_related]
    F --> G[P3b: community administrator scope review]
    D --> H[Preserve existing priority]
Loading

File-Level Changes

Change Details Files
実測結果に基づいて、コミュニティ管理者だけが到達する管理者向け行を判定するロジックを追加した。
  • general と contributor の dynamic_verified がともに「遮断」であることを確認する判定を追加
  • comadmin の実測到達を確認し、auth 文字列に依存せず対象行を識別
  • 未測定・判定不能、または一般/Contributor が到達する行は対象外として誤判定を防止
tools/api-inventory/scripts/prioritize.py
新しい実測ベースの判定を、コミュニティ関連判定と優先度の再分類フローに組み込んだ。
  • community_related の管理者判定ゲートより前に comadmin 専用到達判定を適用
  • 管理者行に限定されていた P3b 振り分け条件を、実測上の comadmin 専用到達行にも拡張
  • 一般ユーザ/Contributor 到達行や「実効せず」指摘を従来どおり再分類対象外に維持
tools/api-inventory/scripts/prioritize.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

🔍 Claude によるレビュー

指摘 4 件 — 🔴 高 0 / 🟠 中 2 / 🟡 低 2 / 🔎 未確認 4 件


🟠 [中] comadmin_only_reach が一般/Contributor の最初のセルしか見ず、複数対象の行で到達を見落とす

tools/api-inventory/scripts/prioritize.py:289 (1/3 パス)

ROLE_CELL[r].search は最初の一致だけを返す。dynamic_verified は ' || ' 区切りで対象ごとに general=/contributor= のセルを持てるので、1つ目の対象で遮断、2つ目の対象で到達という行でも「遮断」と判定される。その結果、一般/Contributor が実際に届く行が comadmin_only_reach=True になり、community_related と classify_full で管理者向けの越境確認(P3b)に振り分けられる。縦の権限昇格として扱うべき行が逸れるおそれがある。隣の comadmin_reach は findall で全セルを見ており、判定の厳しさがそろっていない。

提案

findall で全セルを集め、1つ以上あり、かつすべて '遮断' のときだけ True にする。例: vs = ROLE_CELL[r].findall(dyn); if not vs or any(v != '遮断' for v in vs): return False

根拠
m = ROLE_CELL[r].search(dyn)
        low.append(m.group(1) if m else None)
    if not all(v == '遮断' for v in low):

確認: prioritize.py:167-173 の field() と 255-265 の dyn_segments を読み、dynamic_verified が ' || ' 区切りの複数セグメントを持つ前提を確認した。297-313 の comadmin_reach が findall で全セルを見ていること、316-333 と 342-378 の呼び出し箇所も確認した。実データ(inventory のTSV)で複数対象の行が実在するかは未確認。


🟠 [中] comadmin_only_reach は general/contributor のセルを最初の1件しか見ず、comadmin 側は全件を見ている

tools/api-inventory/scripts/prioritize.py:289 (1/3 パス)

ROLE_CELL[r].search は dynamic_verified の最初の一致だけを採る。comadmin_reach は findall で全対象を見て、どれかが到達なら reach とする。複数の対象やメソッドを測った行で、最初のセルだけ遮断で別の対象では一般/Contributor が到達している場合、「ともに遮断」と誤判定する。その結果、縦の権限昇格に当たる行が P3b(コミュニティ管理者・後回し)に振り分け直されうる。

提案

ROLE_CELL[r].findall(dyn) で全セルを取り、1件以上あり、かつすべてが '遮断' のときだけ遮断とみなす。

根拠
m = ROLE_CELL[r].search(dyn)
        low.append(m.group(1) if m else None)
    if not all(v == '遮断' for v in low):

確認: prioritize.py:255-313 を読んだ。dyn_segments は ' || ' 区切りの複数セグメントを前提にしており、COMADMIN_CELL_RE は findall で全件を使っている。ただし実データ(実測の列)が実際に複数セルを持つ行を、実物では確認していない。


🟡 [低] comadmin_only_reach は一般/Contributor のセルを最初の1件しか見ない

tools/api-inventory/scripts/prioritize.py:289 (1/3 パス)

dynamic_verified は ' || ' 区切りで複数の対象・メソッドの実測を持てます。ROLE_CELL.search() は最初に一致したセルだけを見ます。最初のセルが「遮断」で、後続の対象で general/contributor が「到達」している行でも、一般・Contributor ともに遮断とみなされます。その行は P3b(コミュニティ管理者の越境確認、後回し)に振り分け直され、縦の権限昇格の疑いが埋もれる可能性があります。同じ関数が呼ぶ comadmin_reach は findall と any で全セルを見ており、扱いが非対称です。

提案

findall で全セルを集め、すべてが「遮断」のときだけ True にする。例: all(v == '遮断' for v in ROLE_CELL[r].findall(dyn)) かつ findall が空でないこと。

根拠
m = ROLE_CELL[r].search(dyn)
low.append(m.group(1) if m else None)
if not all(v == '遮断' for v in low):

確認: prioritize.py:255-265 の dyn_segments(複数セグメントを前提とする構造)、:271-313 の COMADMIN_CELL_RE と comadmin_reach(findall + any)、:249-252 の LOW_REACH_RE(到達のみを別に検出)、:363-366 の classify_full の分岐を読んで確認しました。実データでセルが複数並ぶ行は確認していないため、実害の頻度は不明です。


🟡 [低] 管理者行でない P2A/P2B/P2C が、実測だけで P3b に格下げされうる

tools/api-inventory/scripts/prioritize.py:364 (1/3 パス)

classify_full の振り分け直しの条件に comadmin_only_reach を加えたため、auth 文字列が管理者向けでない行も対象になった。一般/Contributor が遮断・comadmin が到達する行は、元が確度の高い P2 でも P3b になる。影響の種類は理由文に残るが、優先度は下がる。意図した設計かもしれないが、認可まわりでは見逃しのリスクがある。

提案

意図通りか確認する。確定(★実証・指摘あり)の P2 は格下げの対象外にすることを検討する。

根拠
or not (is_admin_row(c, H) or comadmin_only_reach(c, H)) \
            or '一般ユーザ/Contributor が' in why or '実効せず' in finding:

確認: prioritize.py:342-378 の classify_full と、316-333 の community_related を読んだ。'一般ユーザ/Contributor が' を含む why と '実効せず' の指摘は除外されている。それ以外の P2 は、管理者行でなくても P3b になる。


🔎 未確認 — 裏が取れなかったもの 4 件
  • comadmin_only_reach の追加で、管理者行でない行も振り分け直しの対象になる tools/api-inventory/scripts/prioritize.py:364 (1/3 パス)
    • classify_full の条件が is_admin_row だけから (is_admin_row or comadmin_only_reach) に広がった。auth が管理者向けでない行でも、実測だけで P3b に振り分けられ得る。意図どおりの変更に見えるが、既存の出力 TSV や期待値テストが変わるかは見ていない。
    • 確認できなかった理由: tools/api-inventory 配下のテストと生成物との突き合わせまでは行わなかった。
  • ROLE_CELL の正規表現に単語境界 \b が無い tools/api-inventory/scripts/prioritize.py:274 (1/3 パス)
    • COMADMIN_CELL_RE と同様に \b が無いため、'xgeneral=' のような語にも一致し得る。現行のセル書式では起きない可能性が高い。
    • 確認できなかった理由: apply_probe_results.py が出すセル名の全パターンを確認していない。
  • is_admin_row 以外の行も振り分け直しの対象になる tools/api-inventory/scripts/prioritize.py:364 (1/3 パス)
    • comadmin_only_reach を OR 条件に加えたため、管理者行でない行(auth が action-need: や session+role: など)の P2/P3b/手動判定 が、実測だけで P3b に再分類されます。'一般ユーザ/Contributor が' in why のガードで縦の昇格行が除外される前提です。why の文言がそのガードに確実に入るかは、classify_base の全分岐を追えていません。
    • 確認できなかった理由: classify_base が長く、why の文言が全分岐でガードに一致するかを確認しきれなかった。また、この挙動のテストが差分に含まれているかも確認していない。
  • ROLE_CELL の正規表現に \b が無い tools/api-inventory/scripts/prioritize.py:274 (1/3 パス)
    • COMADMIN_CELL_RE と同様に、'general=' が他のキーの末尾に一致する可能性がある。LOW_2XX_RE などの既存の正規表現は \b を付けている。
    • 確認できなかった理由: dynamic_verified の実データのキー名を網羅的に確認していないため、誤一致が実際に起こるかは分からない。

モデル sonnet / 3 回実行して和集合 / コスト $0.2748。同じ差分でも結果が揺れるため複数回まわし、一部のパスでしか挙がらなかったものには回数を添えています

差分のみを対象にした自動レビューです。誤りが含まれることがあります。

@mhaya
mhaya merged commit e4b84ce into develop_v2.0.5 Nov 3, 2026
32 of 98 checks passed
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

API インベントリ差分(件数のみ)

台帳ブランチ: develop_v2.0.5

明細は公開できないため件数のみ表示しています。該当箇所はプライベートリポジトリ側の台帳・レポートで確認してください。

ベースラインとの差分

API インベントリ差分レポート

  • 旧: 4b1263c7f v2.0.4-43-g4b1263c7f (profile=default) endpoints=928 (外部ライブラリ由来 361)
  • 新: 34468efbe v2.0.4-52-g34468efbe (profile=default) endpoints=928 (外部ライブラリ由来 359)

判定: ✅ PASS (FAIL 0 / WARN 1)

サマリ

分類 件数
ADDED 0
REMOVED 0
RULE_CHANGED 0
METHODS_CHANGED 0
AUTH_CHANGED 0
IMPL_CHANGED 0
ATTRS_UNKNOWN_NEW 0
ModelView 追加 0
ModelView 削除 0
ModelView フラグ変化 0
config 変化 0
コメントアウト認証の増加 0
依存パッケージの版変化 4

[WARN] W6 依存パッケージの版が変化した — 4件

  • distlib — 0.4.3 -> 0.4.4
  • frozendict — 2.4.7 -> 2.5.1
  • pbr — 7.0.3 -> 7.1.3
  • weko-redis — 0.1.0.dev20170000 -> (削除)

台帳との突き合わせ

スナップショット ↔ インベントリ 突き合わせ

  • リビジョン: 34468efbe v2.0.4-52-g34468efbe 経路URI=908
  • 台帳: 行=1048 URI=919

件数のみ。詳細はプライベートリポジトリ側の完全版レポートを参照。

判定: ✅ 一致 (0件)

検出 件数
A. インベントリ未収載(抽出漏れ) 0
B. 実機に無い(未説明) 0
B'. 実機に無い(既知・許容) 11
C. メソッド不一致 0
D. app列の不一致 0
E. endpoint 未収載 0
E'. endpoint が実機に無い(参考) 1

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