From 019f226b5e42db96e3d1dc75ccdc3e2729e7a82d Mon Sep 17 00:00:00 2001 From: niko4299 Date: Thu, 21 Jul 2022 12:33:50 +0200 Subject: [PATCH] current --- src/query/access_checker.hpp | 2 ++ src/query/interpreter.cpp | 8 ++++++++ src/query/plan/operator.cpp | 1 + src/storage/v2/vertex_accessor.cpp | 2 +- src/storage/v2/vertex_accessor.hpp | 2 +- 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/query/access_checker.hpp b/src/query/access_checker.hpp index 493e1f01b..ab31433ec 100644 --- a/src/query/access_checker.hpp +++ b/src/query/access_checker.hpp @@ -20,5 +20,7 @@ class AccessChecker { public: virtual bool IsUserAuthorizedEdgeTypes(const std::vector &edgeTypes, memgraph::query::DbAccessor *dba) const = 0; + + virtual std::vector GetGrantedEdgeTypesId(memgraph::query::DbAccessor *dba) const = 0; }; } // namespace memgraph::query diff --git a/src/query/interpreter.cpp b/src/query/interpreter.cpp index 6a8e64711..b2067268f 100644 --- a/src/query/interpreter.cpp +++ b/src/query/interpreter.cpp @@ -273,6 +273,14 @@ class AccessChecker final : public memgraph::query::AccessChecker { }); } + std::vector GetGrantedEdgeTypesId(memgraph::query::DbAccessor *dba) const final { + auto edgeTypePermissions = user_->GetEdgeTypePermissions().GetGrants(); + std::vector edgeTypeIds{}; + for (auto edgeTypePermission : edgeTypePermissions) edgeTypeIds.push_back(dba->NameToEdgeType(edgeTypePermission)); + + return edgeTypeIds; + } + private: memgraph::auth::User *user_; }; diff --git a/src/query/plan/operator.cpp b/src/query/plan/operator.cpp index 74463ead0..2c58d7f3e 100644 --- a/src/query/plan/operator.cpp +++ b/src/query/plan/operator.cpp @@ -732,6 +732,7 @@ bool Expand::ExpandCursor::InitEdges(Frame &frame, ExecutionContext &context) { auto &vertex = vertex_value.ValueVertex(); auto direction = self_.common_.direction; + if (direction == EdgeAtom::Direction::IN || direction == EdgeAtom::Direction::BOTH) { if (self_.common_.existing_node) { TypedValue &existing_node = frame[self_.common_.node_symbol]; diff --git a/src/storage/v2/vertex_accessor.cpp b/src/storage/v2/vertex_accessor.cpp index 05ba1ebcc..e0bd9e18f 100644 --- a/src/storage/v2/vertex_accessor.cpp +++ b/src/storage/v2/vertex_accessor.cpp @@ -339,7 +339,7 @@ Result> VertexAccessor::Properties(View view return std::move(properties); } -Result> VertexAccessor::InEdges(View view, const std::vector &edge_types, +Result> VertexAccessor::InEdges(View view, AccessChecker *access_checker, const VertexAccessor *destination) const { MG_ASSERT(!destination || destination->transaction_ == transaction_, "Invalid accessor!"); bool exists = true; diff --git a/src/storage/v2/vertex_accessor.hpp b/src/storage/v2/vertex_accessor.hpp index 840eec910..332f151df 100644 --- a/src/storage/v2/vertex_accessor.hpp +++ b/src/storage/v2/vertex_accessor.hpp @@ -81,7 +81,7 @@ class VertexAccessor final { /// @throw std::bad_alloc /// @throw std::length_error if the resulting vector exceeds /// std::vector::max_size(). - Result> InEdges(View view, const std::vector &edge_types = {}, + Result> InEdges(View view, AccessChecker *access_checker = nullptr, const VertexAccessor *destination = nullptr) const; /// @throw std::bad_alloc