Skip to content

feat: GeonicDB サーバー週次アップデート対応 (2026-03-13~20)#79

Merged
miya0001 merged 4 commits into
mainfrom
feat/server-updates-week-0320
Mar 20, 2026
Merged

feat: GeonicDB サーバー週次アップデート対応 (2026-03-13~20)#79
miya0001 merged 4 commits into
mainfrom
feat/server-updates-week-0320

Conversation

@miya0001

@miya0001 miya0001 commented Mar 20, 2026

Copy link
Copy Markdown
Member

Summary

GeonicDB サーバーの過去1週間の変更 (2026-03-13〜20) に CLI を追従させる。

  • Feat: admin api-keys create/update および me api-keys create--permissions オプション追加 — read, write, create, update, delete を指定して XACML ポリシーを自動生成 (GeonicDB #753)
  • Breaking: admin tenants update から --anonymous-access / --no-anonymous-access フラグを削除 — テナントフィーチャーフラグ廃止に伴い、匿名アクセスは XACML ポリシーで制御する方式に変更 (GeonicDB #752)
  • Breaking: スコープヘルプから write:X implies read:X の記述を削除 — write:Xread:X を暗黙的に含まなくなった (GeonicDB #723)
  • Docs: admin policies create のヘルプに servicePath リソース属性、priority の説明(大きい数値=高優先度)、デフォルトロールポリシーの説明を追加 (GeonicDB #747, #751, #752)
  • Docs: README を更新 — permissions, XACML 認可モデル, スコープ包含関係, API キーヘッダ排他仕様を反映

Server PRs referenced

PR Title
geolonia/geonicdb#753 API キー作成時に XACML ポリシーを自動生成
geolonia/geonicdb#752 XACML 認可一元化 — 5層の認可ロジックを統合
geolonia/geonicdb#751 XACML resource 属性に servicePath を追加
geolonia/geonicdb#747 evaluatePolicies のデフォルトを first-applicable に変更し priority を反転
geolonia/geonicdb#723 write:X スコープが read:X を暗黙的に含まないよう変更

Test plan

  • npm run lint — clean
  • npm run typecheck — clean
  • npm test — 629 tests passed (33 files)
  • --permissions フラグのユニットテスト追加 (admin api-keys create/update, me api-keys create)
  • anonymous-access テスト削除

Summary by CodeRabbit

  • 新機能

    • APIキー作成/更新に権限指定オプション(--permissions)を追加。カンマ区切りで権限を指定可能。
  • 重大な変更

    • テナント更新の匿名アクセスCLIオプションを削除(XACMLポリシーで制御)。
    • スコープ規則を変更:write:Xread:Xを暗黙に含まない。
  • ドキュメント

    • XACML認可モデル、ポリシー優先度とデフォルトロール挙動、servicePathマッチング事例を追記。
    • APIキーとBearerヘッダーの排他動作とCLI例を更新。

- API キーに --permissions オプション追加 (GeonicDB #753)
- write:X implies read:X 暗黙包含の削除をヘルプに反映 (GeonicDB #723)
- テナント anonymous-access フラグ削除 (GeonicDB #752)
- policies ヘルプに servicePath, priority, デフォルトポリシー情報追加
@coderabbitai

coderabbitai Bot commented Mar 20, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

CLIに--permissionsオプションを追加し、APIキー作成時にカンマ区切りの権限を解析してリクエストボディのpermissions配列に含めるようにしました。admin tenants updateから匿名アクセスフラグを削除し、ポリシー/スコープ関連のヘルプとドキュメントを更新しました。

Changes

Cohort / File(s) Summary
API-keys CLI
src/commands/admin/api-keys.ts, src/commands/me-api-keys.ts
--permissions <perms>フラグを追加。カンマ区切りをparsePermissionsで配列化してpermissionsフィールドをリクエストボディに設定。ヘルプと例を更新。
Policies & Tenants CLI
src/commands/admin/policies.ts, src/commands/admin/tenants.ts
policies createヘルプにservicePathターゲット属性とpriority意味論を追加。tenants updateから--anonymous-access/--no-anonymous-accessを削除し、JSON引数由来のペイロードのみを使用するよう変更。
Helpers (permission parsing & help text)
src/helpers.ts
SCOPES_HELP_NOTESを更新しwrite:Xread:Xを含まないことを明記。VALID_PERMISSIONS定義とparsePermissions(raw: string)を追加(無効入力でエラー出力してprocess.exit(1))。
Docs & Changelog
CHANGELOG.md, README.md
--permissionsオプション、XACML認可モデル(デフォルトロールポリシーと優先度)、スコープ含意ルール変更、APIキーとBearerヘッダの排他性などを追記・修正。
Tests
tests/admin-api-keys.test.ts, tests/me-api-keys.test.ts, tests/helpers.test.ts, tests/admin-tenants.test.ts
--permissionsの正常系/異常系テストを追加。parsePermissionsVALID_PERMISSIONSの単体テストを追加。匿名アクセス関連テストを削除/置換しtenants updateのJSONなしケースを検証。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 新しい旗をくわえて走るよ
カンマで区切れば権限が整う
匿名はひっそり去り、ポリシーが扉を開く
テストは跳ねて真実を確かめる
今日もコードの畑でぴょんと一跳び 🌱

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive PR タイトルは日本語で記述されており、サーバーの週次アップデート対応という一般的な概旨のみを示していますが、実際の変更内容(--permissions オプション追加、anonymous-access フラグ削除、scope 暗黙包含の削除など)との対応関係が不明確です。 タイトルをより具体的に変更してください。例:「feat: API キーに --permissions オプション追加、匿名アクセスフラグ削除」とすることで、主要な変更を明確にすることをお勧めします。
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/server-updates-week-0320
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CHANGELOG.md`:
- Line 15: The CHANGELOG entry "**Docs**: README を更新 — `--permissions`
オプション、XACML 認可モデル、スコープ包含関係、API キーヘッダ排他仕様を反映" is missing the PR number suffix;
update that line to append the PR reference " (`#79`)" (or the project’s preferred
suffix format) so it follows the project's guideline of including PR numbers on
CHANGELOG entries.

In `@src/commands/admin/api-keys.ts`:
- Around line 48-49: The permissions handling currently just splits
opts.permissions into payload.permissions allowing empty arrays or invalid
entries; update the logic where payload.permissions is set (uses
opts.permissions and payload.permissions) to validate and normalize values:
after splitting and trimming, filter out empty strings, ensure each permission
is in the allowed permission set (define or import the canonical list used by
create/update), and if any invalid entries exist, abort with a user-facing error
message instead of sending them to the API; apply the same
validation/normalization in the other places mentioned (the occurrences around
the blocks that set payload.permissions at the other two spots) so CLI-side
validation rejects or corrects empty/invalid permission values before submitting
create/update.
- Line 218: The CLI defines a global option "--permissions <perms>" but only the
"create" subcommand shows the permissions help text; add the same permissions
notes to the "update" subcommand so users see the comma-separated permissions
explanation for both. Locate the "--permissions <perms>" option registration and
the help/notes block used for the "create" command, then copy or reference that
permissions description into the "update" command's help/notes (the "create" and
"update" subcommand handlers/definitions) so both commands display identical
permission guidance.

In `@src/commands/me-api-keys.ts`:
- Around line 71-79: The permissions parsing currently builds
payload.permissions from opts.permissions without validating resulting values;
update the block that handles opts.permissions (where payload.permissions is
set) to validate after splitting and trimming: if opts.permissions is an empty
string or the split/trim/filter result is an empty array, surface a CLI error
(throw/console.error + process.exit(1) or return) and do not set
payload.permissions; additionally validate each permission token against the
canonical allowed-permissions set (use the existing permission constants or add
a small whitelist) and reject any unknown values with a clear error message so
`--permissions ""` and invalid tokens are rejected like origins.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1a5b8330-9df6-4409-a139-c1e5e223c3f1

📥 Commits

Reviewing files that changed from the base of the PR and between ccb339e and 4fa52fd.

📒 Files selected for processing (10)
  • CHANGELOG.md
  • README.md
  • src/commands/admin/api-keys.ts
  • src/commands/admin/policies.ts
  • src/commands/admin/tenants.ts
  • src/commands/me-api-keys.ts
  • src/helpers.ts
  • tests/admin-api-keys.test.ts
  • tests/admin-tenants.test.ts
  • tests/me-api-keys.test.ts

Comment thread CHANGELOG.md Outdated
Comment thread src/commands/admin/api-keys.ts Outdated
Comment thread src/commands/admin/api-keys.ts
Comment thread src/commands/me-api-keys.ts

@coderabbitai coderabbitai 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.

♻️ Duplicate comments (1)
src/commands/admin/api-keys.ts (1)

48-49: ⚠️ Potential issue | 🟠 Major

--permissions "" が無視され、バリデーションを迂回できます。

opts.permissions を truthy で判定しているため、空文字を明示指定したケースで parsePermissions() が実行されません。結果として入力が無視され、create/update で意図しない JSON 入力経路に入ります。undefined 判定に揃えてください。

修正案
-  if (opts.permissions) payload.permissions = parsePermissions(opts.permissions as string);
+  if (opts.permissions !== undefined) payload.permissions = parsePermissions(String(opts.permissions));

-        } else if (opts.name || opts.scopes || opts.origins || opts.entityTypes || opts.rateLimit || opts.dpopRequired !== undefined || opts.permissions || opts.tenantId) {
+        } else if (opts.name || opts.scopes || opts.origins || opts.entityTypes || opts.rateLimit || opts.dpopRequired !== undefined || opts.permissions !== undefined || opts.tenantId) {

-          } else if (opts.name || opts.scopes || opts.origins || opts.entityTypes || opts.rateLimit || opts.dpopRequired !== undefined || opts.permissions) {
+          } else if (opts.name || opts.scopes || opts.origins || opts.entityTypes || opts.rateLimit || opts.dpopRequired !== undefined || opts.permissions !== undefined) {

Also applies to: 143-144, 237-238

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/admin/api-keys.ts` around lines 48 - 49, The code currently
guards assignment with a truthy check which causes an explicit empty string
(--permissions "") to be ignored; change the conditional checks that set
payload.permissions from using truthiness (opts.permissions) to explicit
undefined checks (opts.permissions !== undefined) so
parsePermissions(opts.permissions as string) is called for empty string inputs;
update the three locations that perform this pattern (the places that set
payload.permissions using parsePermissions, e.g., inside the API key
create/update handlers where opts.permissions and payload.permissions are
referenced) to use the undefined check instead of a truthy check.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/commands/admin/api-keys.ts`:
- Around line 48-49: The code currently guards assignment with a truthy check
which causes an explicit empty string (--permissions "") to be ignored; change
the conditional checks that set payload.permissions from using truthiness
(opts.permissions) to explicit undefined checks (opts.permissions !== undefined)
so parsePermissions(opts.permissions as string) is called for empty string
inputs; update the three locations that perform this pattern (the places that
set payload.permissions using parsePermissions, e.g., inside the API key
create/update handlers where opts.permissions and payload.permissions are
referenced) to use the undefined check instead of a truthy check.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ed30ca1d-1219-46e4-b713-d1a450941fce

📥 Commits

Reviewing files that changed from the base of the PR and between 4fa52fd and f7e2ef5.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • src/commands/admin/api-keys.ts
  • src/commands/me-api-keys.ts
  • src/helpers.ts
  • tests/admin-api-keys.test.ts
  • tests/helpers.test.ts
  • tests/me-api-keys.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • CHANGELOG.md
  • tests/admin-api-keys.test.ts
  • tests/me-api-keys.test.ts
  • src/helpers.ts
  • src/commands/me-api-keys.ts

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CHANGELOG.md`:
- Around line 146-148: Update the changelog links: change the compare range
referenced by the link label [0.7.0] from v0.6.4...v0.7.0 to v0.6.3...v0.7.0
(adjust the URL/compare range accordingly) and remove the unused/invalid link
label [0.6.4] entirely so there is no reference to a non-existent v0.6.4 tag.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aa6ee333-647a-4f8a-ba94-20e67146f07b

📥 Commits

Reviewing files that changed from the base of the PR and between f7e2ef5 and 7b74dfa.

📒 Files selected for processing (1)
  • CHANGELOG.md

Comment thread CHANGELOG.md
Comment on lines +146 to +148
[Unreleased]: https://github.com/geolonia/geonicdb-cli/compare/v0.7.0...HEAD
[0.7.0]: https://github.com/geolonia/geonicdb-cli/compare/v0.6.4...v0.7.0
[0.6.4]: https://github.com/geolonia/geonicdb-cli/compare/v0.6.3...v0.6.4

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: v0.6.4 タグの存在を確認

# v0.6.4 タグが存在するか確認
if git tag | grep -q "^v0.6.4$"; then
  echo "✓ v0.6.4 タグが存在します"
  git log --oneline v0.6.3..v0.6.4
else
  echo "✗ v0.6.4 タグは存在しません"
fi

# 最新のタグを表示
echo ""
echo "最新のバージョンタグ:"
git tag --sort=-version:refname | head -n 5

Repository: geolonia/geonicdb-cli

Length of output: 96


🏁 Script executed:

# Check the current state of CHANGELOG.md lines around 146-148
wc -l CHANGELOG.md

Repository: geolonia/geonicdb-cli

Length of output: 81


🏁 Script executed:

# Read the end of CHANGELOG.md to see the link definitions
tail -20 CHANGELOG.md

Repository: geolonia/geonicdb-cli

Length of output: 1222


🏁 Script executed:

# Search for [0.6.4] section in the entire CHANGELOG.md
grep -n "\[0\.6\.4\]" CHANGELOG.md

Repository: geolonia/geonicdb-cli

Length of output: 142


** версия 0.6.4 のリンク定義が無効です。v0.6.4 タグが存在しないため削除してください。**

Git リポジトリに v0.6.4 タグが存在しません。以下の対応が必要です:

  • 147 行目:[0.7.0] の比較リンクを v0.6.4...v0.7.0 から v0.6.3...v0.7.0 に修正
  • 148 行目:[0.6.4] のリンク定義を削除
修正内容(CHANGELOG.md 147-148 行目)
[Unreleased]: https://github.com/geolonia/geonicdb-cli/compare/v0.7.0...HEAD
-[0.7.0]: https://github.com/geolonia/geonicdb-cli/compare/v0.6.4...v0.7.0
-[0.6.4]: https://github.com/geolonia/geonicdb-cli/compare/v0.6.3...v0.6.4
+[0.7.0]: https://github.com/geolonia/geonicdb-cli/compare/v0.6.3...v0.7.0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
[Unreleased]: https://github.com/geolonia/geonicdb-cli/compare/v0.7.0...HEAD
[0.7.0]: https://github.com/geolonia/geonicdb-cli/compare/v0.6.4...v0.7.0
[0.6.4]: https://github.com/geolonia/geonicdb-cli/compare/v0.6.3...v0.6.4
[Unreleased]: https://github.com/geolonia/geonicdb-cli/compare/v0.7.0...HEAD
[0.7.0]: https://github.com/geolonia/geonicdb-cli/compare/v0.6.3...v0.7.0
🧰 Tools
🪛 markdownlint-cli2 (0.21.0)

[warning] 148-148: Link and image reference definitions should be needed
Unused link or image reference definition: "0.6.4"

(MD053, link-image-reference-definitions)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CHANGELOG.md` around lines 146 - 148, Update the changelog links: change the
compare range referenced by the link label [0.7.0] from v0.6.4...v0.7.0 to
v0.6.3...v0.7.0 (adjust the URL/compare range accordingly) and remove the
unused/invalid link label [0.6.4] entirely so there is no reference to a
non-existent v0.6.4 tag.

@miya0001
miya0001 merged commit e20dcb2 into main Mar 20, 2026
11 of 13 checks passed
@miya0001
miya0001 deleted the feat/server-updates-week-0320 branch March 20, 2026 13:57
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