Skip to content

Commit

Permalink
Fix insert tagless vertex with BASIC role (vesoft-inc#2120)
Browse files Browse the repository at this point in the history
  • Loading branch information
czpmango authored Jan 5, 2023
1 parent 86dc300 commit cdc2ca5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/graph/validator/MutateValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ Status InsertVerticesValidator::check() {
if (!FLAGS_graph_use_vertex_key && tagItems.empty()) {
return Status::SemanticError("Insert vertex is forbidden, please specify the tag");
}
if (SchemaUtil::isBasicRole(qctx_) && tagItems.empty()) {
return Status::PermissionError("The BASIC role is not allowed to insert tagless vertex.");
}

schemas_.reserve(tagItems.size());
for (auto &item : tagItems) {
Expand Down
6 changes: 6 additions & 0 deletions tests/admin/test_user_privilege.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,12 @@ def test_user_privilege(self):
resp = self.testDmlPriClient.execute(query)
self.check_error_msg(resp, "PermissionError: The BASIC role is not allowed to use delete vertex statement.")

query = 'INSERT vertex VALUES "vid":()'
resp = self.testDmlPriClient.execute(query)
# Behavior when FLAGS_graph_use_vertex_key enabled
# self.check_error_msg(resp, "PermissionError: The BASIC role is not allowed to insert tagless vertex.")
self.check_error_msg(resp, "SemanticError: Insert vertex is forbidden, please specify the tag")

query = 'DELETE tag A,B FROM "vid"'
resp = self.testDmlPriClient.execute(query)
self.check_error_msg(resp, "PermissionError: Tag `A' is not writable.")
Expand Down

0 comments on commit cdc2ca5

Please sign in to comment.