Skip to content

fix(core): Add checks for role presence before granting it#5300

Merged
aoyako merged 9 commits intohyperledger-iroha:mainfrom
aoyako:validate_role_id
Feb 23, 2025
Merged

fix(core): Add checks for role presence before granting it#5300
aoyako merged 9 commits intohyperledger-iroha:mainfrom
aoyako:validate_role_id

Conversation

@aoyako
Copy link
Copy Markdown
Contributor

@aoyako aoyako commented Jan 31, 2025

Resolves #5246.

Verify that the role is present in the world before assigning it.

Example that should pass:

{
    "Register": {
        "Role": {
            "id": "good_role",
            "permissions": [
                {
                    "name": "CanSetParameters",
                    "payload": null
                }
            ],
            "grant_to": "ed0120E9F632D3034BAB6BB26D92AC8FD93EF878D9C5E69E01B61B4C47101884EE2F99@garden_of_live_flowers"
        }
    }
},
{
    "Grant": {
        "Role": {
            "object": "good_role",
            "destination": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"
        }
    }
}

Example that should fail:

{
    "Grant": {
        "Role": {
            "object": "bad_role",
            "destination": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"
        }
    }
}

Signed-off-by: Lohachov Mykhailo <lohachov@soramitsu.co.jp>
Signed-off-by: Lohachov Mykhailo <lohachov@soramitsu.co.jp>
s8sato
s8sato previously approved these changes Feb 3, 2025
Comment thread crates/iroha_smart_contract_utils/src/lib.rs Outdated
Co-authored-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: Mykhailo Lohachov <lohachov@soramitsu.co.jp>
s8sato
s8sato previously approved these changes Feb 3, 2025
@s8sato s8sato self-assigned this Feb 3, 2025
Signed-off-by: Lohachov Mykhailo <lohachov@soramitsu.co.jp>
Signed-off-by: Lohachov Mykhailo <lohachov@soramitsu.co.jp>
s8sato
s8sato previously approved these changes Feb 12, 2025
Signed-off-by: Lohachov Mykhailo <lohachov@soramitsu.co.jp>
Comment thread crates/iroha/tests/roles.rs
@aoyako aoyako self-assigned this Feb 22, 2025
@aoyako aoyako merged commit b5396e9 into hyperledger-iroha:main Feb 23, 2025
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.

Granting unexisting role

3 participants