GDPR consent authorization fix; wire dead analytics/governance modules; drop placeholder submodules - #1047
Merged
nanaf6203-bit merged 1 commit intoAug 25, 2026
Conversation
…laceholder submodules - gdpr (MettaChain#984): `grant_consent` accepted an arbitrary `data_subject`, letting any caller fabricate a `Granted` consent record in a victim's name (the record then satisfies `check_consent` and the data-access path). The function now mirrors `withdraw_consent`'s rule: the caller must be the data subject or the admin. Policy documented on the message. Tests cover third-party rejection (no fabricated record, check stays false), subject self-grant, and admin grant-on-behalf. - analytics (MettaChain#983): wire the previously dead `staking_dashboard.rs` into the crate via `pub mod staking_dashboard;`. Fixed its never-compiled test helper (`run_test` cannot return a value; construction now relies on the `#[ink::test]` environment). Its 17 unit tests now run under `cargo test -p propchain-analytics`. - governance (MettaChain#982): wire the three orphan files into the build: `pub mod treasury;`, `pub mod delegation;` and (test-only) `mod snapshot_tests;`, plus `extern crate alloc` for no_std builds. Their unit tests now run under `cargo test -p governance`; exposing them on the on-chain message surface remains a separate feature decision, documented in lib.rs. - property-management (MettaChain#973): removed the placeholder `submodules` module whose `is_registered`/`schedule_inspection` stubs returned `id > 0` and promised semantics that do not exist (real registry logic lives in lib.rs). Removal chosen over implementation against real storage because inspection scheduling implies a new feature (storage + events + access policy) beyond this fix. Closes MettaChain#984 Closes MettaChain#983 Closes MettaChain#982 Closes MettaChain#973
|
@limxiy 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
One commit, four assigned issues: a security fix in the GDPR consent registry, plus three dead-code/placeholder cleanups that make previously invisible code compile and run its tests.
gdpr — consent-grant authorization (#984) [security]
grant_consentaccepted anydata_subjectwith zero caller checks (the function body never referencedcaller), while its siblingwithdraw_consentenforceddata_subject == caller || caller == admin. An attacker could fabricate aGrantedConsentRecordfor any victim, which then flowed intocheck_consent(and the data-access path) as if the victim had consented — defeating the registry's entire purpose, since consent is the legal basis for processing.Fix: mirror
withdraw_consent's rule exactly. The policy (subject grants own consent; admin may record on behalf) is documented on the message.Tests: third-party grant rejected (
Error::NotAuthorized) leaving no fabricated record andcheck_consentfalse; subject self-grant succeeds; admin grant-on-behalf succeeds.analytics — compile the dead
staking_dashboardmodule (#983)staking_dashboard.rswas never declared anywhere, so none of it was compiled and all 17 of its unit tests silently never ran (the analytics crate had no other tests).Fix:
pub mod staking_dashboard;. Also fixed its never-compiled test helper:ink::env::test::run_testreturnsResult<()>and cannot smuggle a constructed value out; the helper now constructs directly inside the#[ink::test]environment. All tests now execute undercargo test -p propchain-analytics.governance — wire treasury/delegation/snapshot modules (#982)
treasury.rs,delegation.rs, andsnapshot_tests.rswere orphan files:lib.rsincluded only errors/types/tests, so governance shipped no treasury or delegation feature at all despite full implementations sitting inert in the tree.Fix: declared as root-level modules (
pub mod treasury;,pub mod delegation;, test-onlymod snapshot_tests;) withextern crate allocfor no_std builds. They now compile and their 12 unit tests run undercargo test -p governance. Wiring them into the contract's storage/message surface is a feature decision beyond this fix and is documented as such in lib.rs.property-management — remove placeholder submodules (#973)
submodules::property_registry::is_registered(id)returnedid > 0(can never detect an unregistered property) andsubmodules::property_maintenance::schedule_inspection(id)claimed success for any positive id without recording anything. No callers existed; the names promised semantics the crate doesn't have.Decision (documented): removed rather than implemented — real registry logic lives in
lib.rs; making inspection scheduling real requires new storage/events/access-policy (a feature, not a fill-in).Test results
cargo test -p propchain-gdpr: 14 passed (11 existing + 3 new)cargo test -p propchain-analytics: 19 passed (17 staking_dashboard + 2 existing)cargo test -p governance: 29 passed (18 existing + 5 treasury + 3 delegation + 4 snapshot... net +12 newly-compiled tests)cargo test -p property-management: 8 passed (unchanged after stub removal)Closes #984
Closes #983
Closes #982
Closes #973