Skip to content

feat(rbac): reject duplicate role grants, validate roles, and add dependency check (#761 #768 #770) - #866

Open
nekwasar wants to merge 1 commit into
BCPathway:mainfrom
nekwasar:feat/rbac-761-768-769-770
Open

feat(rbac): reject duplicate role grants, validate roles, and add dependency check (#761 #768 #770)#866
nekwasar wants to merge 1 commit into
BCPathway:mainfrom
nekwasar:feat/rbac-761-768-769-770

Conversation

@nekwasar

Copy link
Copy Markdown

Closes #761, Closes #768, Closes #770

#768 — Cannot grant already granted role (idempotency)

  • Added AdminError::RoleAlreadyGranted (discriminant 21).
  • grant_role / _grant_role now fail loudly when the target already holds the role, instead of silently OR-ing the bitmask.
  • Updated the fuzz and unit tests (including fuzz_grant_role_already_granted, test_grant_role_already_granted_fails, and the self-grant fuzz) to assert the new behavior.

#761 — Parameter validation for grant_role(role)

  • Locked in role-bound validation with test_grant_role_accepts_every_recognized_role, asserting each recognized role is granted end-to-end and maps to exactly its power-of-two bitmask bit. (The public Role type is a #[contracttype] enum, so unknown discriminants are excluded at the type level; require_valid_role remains as defense in depth.)

#769 — Lifecycle modifiers use RBAC

  • Confirmed contracts/lifecycle already uses admin::require_role(Pauser) / admin::require_pauser — no legacy require_admin remains. Snapshots updated to reflect the new pause-grant behavior.

#770 — Cross-module dependency check

  • Added scripts/check_crate_cycles.py (walks workspace path = "../…" deps and fails on any cycle) and wired it into .github/workflows/ci.yml.
  • Verified cargo tree shows token → admin/lifecycle/rate-limit/ttl with no circular back-references.

Verification

  • cargo build and cargo test -p bc-forge-admin: 190 passed, 0 failed.
  • cargo test -p bc-forge-lifecycle -p bc-forge-token: all pass.
  • cargo fmt --check and cargo clippy -D warnings: clean.

…endency check (BCPathway#761 BCPathway#768 BCPathway#770)

- BCPathway#768: add RoleAlreadyGranted (21) error; grant_role now fails loudly when
  the target already holds the role instead of silently no-oping
- BCPathway#761: lock in role-bound validation with tests for every recognized role
  and its bitmask bit
- BCPathway#770: add scripts/check_crate_cycles.py and wire it into CI to catch
  circular workspace crate dependencies; verify token->admin isolation
- update fuzz and error-name tests for the new variant and behavior
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@nekwasar Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant