[E129-MG <-T0982-MG] implement edge type filtering (#489)
* GRANT, REVOKE, DENY and access_checker DONE
* Added AccessChecker to ExecutionContext
* grammar expanded; (#462)
* current
* T0954 mg expand user and role to hold permissions on labels (#465)
* added FineGrainedAccessPermissions class to model
* expanded user and role with fine grained access permissions
* fixed grammar
* [E129 < T0953-MG] GRANT, DENY, REVOKE added in interpreter and mainVisitor (#464)
* GRANT, DENY, REVOKE added in interpreter and mainVisitor
* Commented labelPermissons
* remove labelsPermission adding
* Fixed
* Removed extra lambda
* fixed
* [E129<-T0955-MG] Expand ExecutionContext with label related information (#467)
* added
* Added FineGrainedAccessChecker to Context
* fixed
* Added filtering
* testing
* Added edge filtering to storage, need to add filtering in simple Expand in operator.cpp
* Removed storage changes
* MATCH filtering working
* EdgeTypeFiltering working, just need to test everything again
* Removed FineGrainedAccessChecker
* Removed Expand Path
* Fix
* Tested FineGrainedAccessHandler, need to test AuthChecker
* Added integration test for lba
* Fixed merge conflicts
* PR fix
* fixed
* PR fix
* Fix test
* removed .vscode, .cache, .githooks
* githooks
* added tests
* fixed build
* Changed ast.lcp and User pointer to value in context.hpp
* Fixed test
* Remove denies on grant all
* AuthChecker
* Pr fix, auth_checker still not fixed
* Create mg-glue and extract UserBasedAuthChecker from AuthChecker
* Build fixed, need to fix test
* e2e tests
* e2e test working
* Added unit test, e2e and FineGrainedChecker
* Mege E129, auth_checker tests
* Fixed test
* e2e fix
Co-authored-by: Boris Taševski <36607228+BorisTasevski@users.noreply.github.com>
Co-authored-by: josipmrden <josip.mrden@external-basf.com>
Co-authored-by: János Benjamin Antal <benjamin.antal@memgraph.io>
2022-08-16 21:57:23 +08:00
|
|
|
// Copyright 2022 Memgraph Ltd.
|
|
|
|
//
|
|
|
|
// Use of this software is governed by the Business Source License
|
|
|
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
|
|
|
// License, and you may not use this file except in compliance with the Business Source License.
|
|
|
|
//
|
|
|
|
// As of the Change Date specified in that file, in accordance with
|
|
|
|
// the Business Source License, use of this software will be governed
|
|
|
|
// by the Apache License, Version 2.0, included in the file
|
|
|
|
// licenses/APL.txt.
|
|
|
|
|
|
|
|
#include <gflags/gflags.h>
|
|
|
|
|
|
|
|
#include "communication/bolt/client.hpp"
|
|
|
|
#include "io/network/endpoint.hpp"
|
|
|
|
#include "io/network/utils.hpp"
|
|
|
|
|
|
|
|
DEFINE_string(address, "127.0.0.1", "Server address");
|
|
|
|
DEFINE_int32(port, 7687, "Server port");
|
|
|
|
DEFINE_string(username, "", "Username for the database");
|
|
|
|
DEFINE_string(password, "", "Password for the database");
|
|
|
|
DEFINE_bool(use_ssl, false, "Set to true to connect with SSL to the server.");
|
|
|
|
|
|
|
|
DEFINE_bool(check_failure, false, "Set to true to enable failure checking.");
|
|
|
|
DEFINE_bool(should_fail, false, "Set to true to expect a failure.");
|
|
|
|
DEFINE_string(failure_message, "", "Set to the expected failure message.");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Executes queries passed as positional arguments and verifies whether they
|
|
|
|
* succeeded, failed, failed with a specific error message or executed without a
|
|
|
|
* specific error occurring.
|
|
|
|
*/
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
|
|
|
|
|
|
|
memgraph::communication::SSLInit sslInit;
|
|
|
|
|
|
|
|
memgraph::io::network::Endpoint endpoint(memgraph::io::network::ResolveHostname(FLAGS_address), FLAGS_port);
|
|
|
|
|
|
|
|
memgraph::communication::ClientContext context(FLAGS_use_ssl);
|
2022-09-06 17:14:27 +08:00
|
|
|
memgraph::communication::bolt::Client client(context);
|
[E129-MG <-T0982-MG] implement edge type filtering (#489)
* GRANT, REVOKE, DENY and access_checker DONE
* Added AccessChecker to ExecutionContext
* grammar expanded; (#462)
* current
* T0954 mg expand user and role to hold permissions on labels (#465)
* added FineGrainedAccessPermissions class to model
* expanded user and role with fine grained access permissions
* fixed grammar
* [E129 < T0953-MG] GRANT, DENY, REVOKE added in interpreter and mainVisitor (#464)
* GRANT, DENY, REVOKE added in interpreter and mainVisitor
* Commented labelPermissons
* remove labelsPermission adding
* Fixed
* Removed extra lambda
* fixed
* [E129<-T0955-MG] Expand ExecutionContext with label related information (#467)
* added
* Added FineGrainedAccessChecker to Context
* fixed
* Added filtering
* testing
* Added edge filtering to storage, need to add filtering in simple Expand in operator.cpp
* Removed storage changes
* MATCH filtering working
* EdgeTypeFiltering working, just need to test everything again
* Removed FineGrainedAccessChecker
* Removed Expand Path
* Fix
* Tested FineGrainedAccessHandler, need to test AuthChecker
* Added integration test for lba
* Fixed merge conflicts
* PR fix
* fixed
* PR fix
* Fix test
* removed .vscode, .cache, .githooks
* githooks
* added tests
* fixed build
* Changed ast.lcp and User pointer to value in context.hpp
* Fixed test
* Remove denies on grant all
* AuthChecker
* Pr fix, auth_checker still not fixed
* Create mg-glue and extract UserBasedAuthChecker from AuthChecker
* Build fixed, need to fix test
* e2e tests
* e2e test working
* Added unit test, e2e and FineGrainedChecker
* Mege E129, auth_checker tests
* Fixed test
* e2e fix
Co-authored-by: Boris Taševski <36607228+BorisTasevski@users.noreply.github.com>
Co-authored-by: josipmrden <josip.mrden@external-basf.com>
Co-authored-by: János Benjamin Antal <benjamin.antal@memgraph.io>
2022-08-16 21:57:23 +08:00
|
|
|
|
|
|
|
client.Connect(endpoint, FLAGS_username, FLAGS_password);
|
|
|
|
|
|
|
|
for (int i = 1; i < argc; ++i) {
|
|
|
|
std::string query(argv[i]);
|
|
|
|
try {
|
|
|
|
client.Execute(query, {});
|
|
|
|
} catch (const memgraph::communication::bolt::ClientQueryException &e) {
|
|
|
|
if (!FLAGS_check_failure) {
|
|
|
|
if (!FLAGS_failure_message.empty() && e.what() == FLAGS_failure_message) {
|
|
|
|
LOG_FATAL(
|
|
|
|
"The query should have succeeded or failed with an error "
|
|
|
|
"message that isn't equal to '{}' but it failed with that error "
|
|
|
|
"message",
|
|
|
|
FLAGS_failure_message);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (FLAGS_should_fail) {
|
|
|
|
if (!FLAGS_failure_message.empty() && e.what() != FLAGS_failure_message) {
|
|
|
|
LOG_FATAL(
|
|
|
|
"The query should have failed with an error message of '{}'' but "
|
|
|
|
"instead it failed with '{}'",
|
|
|
|
FLAGS_failure_message, e.what());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
LOG_FATAL(
|
|
|
|
"The query shoudn't have failed but it failed with an "
|
|
|
|
"error message '{}'",
|
|
|
|
e.what());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!FLAGS_check_failure) continue;
|
|
|
|
if (FLAGS_should_fail) {
|
|
|
|
LOG_FATAL(
|
|
|
|
"The query should have failed but instead it executed "
|
|
|
|
"successfully!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|