Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

aoyako
Copy link
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
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 on lines +275 to +277
let _result = NetworkBuilder::new()
.with_genesis_instruction(grant_genesis_role)
.start_blocking();
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be great to extend the NetworkBuilder in a way that it intercepts the error printed by Iroha, so that we can put a more precise assertion here.

@aoyako aoyako self-assigned this Feb 22, 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