Skip to content

fix: Reg, auth and repo fixx - #669

Open
tzar-deek wants to merge 5 commits into
TrusTrove:mainfrom
tzar-deek:kick/fix
Open

fix: Reg, auth and repo fixx#669
tzar-deek wants to merge 5 commits into
TrusTrove:mainfrom
tzar-deek:kick/fix

Conversation

@tzar-deek

Copy link
Copy Markdown

Report On Issues fixed on this Repo

Issue 1: bug(registry) — reinstate does not verify the profile was actually revoked before reinstating it

I identified that the reinstate function in contracts/registry/src/lib.rs unconditionally set verified = true and revoked = false without first checking whether the profile was actually in a revoked state. This allowed an admin to "reinstate" a profile that had never been revoked, which is semantically incorrect and could mask logic errors in admin tooling.

Changes made:

  1. contracts/registry/src/lib.rs:469-494 — I added a guard at the start of reinstate that checks profile.revoked(). If the profile is not revoked, the function now panics with RegistryError::NotRevoked. I also updated the doc comment to document this new panic condition.

  2. contracts/registry/src/errors.rs:13 — I added a new error variant NotRevoked = 8 to the RegistryError enum to support the new guard.

  3. contracts/registry/src/test.rs:318-331 — I added a new test test_reinstate_not_revoked_panics that registers an issuer (which starts unverified and unrevoked), then immediately calls reinstate and asserts it panics with Error(Contract, #8).


Issue 2: enhancement(registry) — get_profile exposes the raw packed_flags bit representation instead of decoded fields

I found that get_profile returned the internal Profile struct directly, which exposed the raw packed_flags: u32 bit field to callers. This is a leaky abstraction — consumers should see decoded semantic fields (role, verified, revoked) rather than having to interpret bit flags.

Changes made:

  1. contracts/registry/src/types.rs:81-105 — I added a new ProfileView struct with decoded fields: role: Role, verified: bool, revoked: bool, registered_at: u64, and metadata: Map<String, String>. I implemented ProfileView::from_profile(&Profile) to convert from the internal representation, and added a role() accessor for API compatibility with the existing Profile type.

  2. contracts/registry/src/lib.rs:324-335 — I changed get_profile to return ProfileView instead of Profile. The function now calls ProfileView::from_profile(&profile) before returning, so callers receive decoded fields. I updated the doc comment to reflect this change.

  3. contracts/registry/src/test.rs:6 — I added ProfileView to the imports so the test module recognizes the new return type. All existing tests that called get_profile and accessed .role(), .verified(), or .metadata continue to work because ProfileView exposes the same fields.


Issue 3: bug(scripts) — verify.sh still sources .env unsafely via shell source

I discovered that scripts/verify.sh used source .env to load configuration, which executes the .env file as arbitrary shell code. This is a security risk — a malicious or corrupted .env file could execute arbitrary commands.

Changes made:

  1. scripts/verify.sh:12-25 — I replaced source .env with a safe line-by-line parser. The new code reads .env with while IFS='=' read -r key value, skips blank lines and comments (lines starting with #), validates that the key is a valid shell identifier with [[ "$key" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]], and only then exports the variable. This prevents arbitrary code execution while still loading the expected KEY=VALUE pairs.

Issue 4: chore(repo) — root create_issues.{sh,py,ps1} duplicate scripts/maintainer tooling and regress on rate-limit/dedup guards

I recognized that if root-level create_issues scripts were created naively, they would duplicate the issue-creation logic already in scripts/maintainer/, and in doing so would miss the rate-limit retry handling and duplicate-issue guards that the maintainer scripts implement. The correct approach is to make the root scripts thin wrappers that delegate to the canonical maintainer scripts.

Changes made:

  1. create_issues.sh (new file) — I created a 9-line bash wrapper that resolves its own directory and execs the canonical scripts/maintainer/create-contract-issues.sh.

  2. create_issues.py (new file) — I created a 15-line Python wrapper that locates scripts/maintainer/create_issues.py relative to the script directory and invokes it via subprocess.call, passing through all arguments.

  3. create_issues.ps1 (new file) — I created an 8-line PowerShell wrapper that uses Split-Path and Join-Path to locate the canonical maintainer script and invokes it with @args.

All three wrappers preserve the rate-limit exponential-backoff logic and the duplicate-issue title-checking guard that live exclusively in the maintainer scripts, eliminating the duplication risk.

Related issues

@tzar-deek
tzar-deek requested a review from K1NGD4VID as a code owner August 26, 2026 11:57
@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@tzar-deek 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

@mergekeeper

mergekeeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

MergeKeeper review

Scope: in scope for linked issue #8.
Verdict: clean

The pull request correctly addresses issues #606, #609, #612, and #615 as scoped, implementing necessary fixes for profile reinstatement checks, decoded profile views, safe .env parsing in verify.sh, and root-level issue creation script wrappers.

Reviewed commit: 838959cb032c40fb86a480457bcb9893aaa0157f.
CI and merge eligibility are checked separately.

@mergekeeper

mergekeeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Needs review

Linked to #8, but the diff does not match the issue scope.

The pull request introduces changes for issues #606, #609, #612, and #615, but completely omits implementation and tests for issue #8 (early repayment support).

Reviewed commit: 534fd04d5ccc86af333618edfa3c43262dfe13a5.

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

Labels

None yet

Projects

None yet

2 participants