8000 Patch allowed on targaryen, not on firebase · Issue #134 · goldibex/targaryen · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Patch allowed on targaryen, not on firebase #134
Closed
@SamyPesse

Description

@SamyPesse

Targaryen is allowing patch that should be rejected.

The following patch is invalid because a key -KwzSBcjqM_ydHz6415J is forgotten after the invites/:

{ 'orgs/org1/invites/':
       { uid: '-KwzSBcjqM_ydHz6415J',
         role: 'admin',
         createdAt: 1508598138982 } }

The Firebase rules are:

        ....
        "invites": {
          "$key2": {
            ".validate": "newData.hasChildren(['uid', 'role', 'createdAt']) && $key2 == newData.child('uid').val()",
            "uid": {
              ".validate": "newData.isString()"
            },
            "role": {
              ".validate": "newData.isString() && (newData.val() == 'reader' || newData.val() == 'writer' || newData.val() == 'reviewer' || newData.val() == 'admin')"
            },
            "createdAt": {
              ".validate": "newData.isNumber()"
            },
            "$other": {
              ".validate": "false"
            },
            ".read": "true"
          },
          ".validate": "newData.hasChildren() && newData.parent().parent().parent().child('orgs').child($orgID).child('infos').val() != null",
          ".read": "root.child('orgs').child($orgID).child('members').child(auth.uid).child('role').val() == 'admin'",
          ".write": "newData.parent().parent().parent().child('orgs').child($orgID).child('members').child(auth.uid).child('role').val() == 'admin'"
        }
       ....

The update is accepted on Targaryen (log of data.update('/', update):

Result {
      path: '/',
      auth: { uid: 'user3' },
      type: 'patch',
      permitted: true,
      validated: true,
      database:
       Database { ... },
      newDatabase:
       Database { ... },
      newValue:
       { 'orgs/org1/invites/':
          { uid: '-KwzSBcjqM_ydHz6415J',
            role: 'admin',
            createdAt: 1508598138982 } } }

But on Firebase, the patch is rejected (as it should):

screen shot 2017-10-21 at 17 05 55

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0