in cartography/driftdetect/detect_drift.py [0:0]
def run(config):
"""
:type config: config object passed from argparse
:param config: refer to config.py
:return: list of tuples of drift dictionaries and detectors
"""
if not valid_directory(config):
return
neo4j_auth = None
if config.neo4j_user or config.neo4j_password:
neo4j_auth = (config.neo4j_user, config.neo4j_password)
try:
neo4j_driver = GraphDatabase.driver(
config.neo4j_uri,
auth=neo4j_auth,
)
except neobolt.exceptions.ServiceUnavailable as e:
logger.debug("Error occurred during Neo4j connect.", exc_info=True)
logger.error(
(
"Unable to connect to Neo4j using the provided URI '%s', an error occurred: '%s'. Make sure the "
"Neo4j server is running and accessible from your network."
),
config.neo4j_uri,
e
)
return
except neobolt.exceptions.AuthError as e:
logger.debug("Error occurred during Neo4j auth.", exc_info=True)
if not neo4j_auth:
logger.error(
(
"Unable to auth to Neo4j, an error occurred: '%s'. driftdetect attempted to connect to Neo4j "
"without any auth. Check your Neo4j server settings to see if auth is required and, if it is, "
"provide driftdetect with a valid username and password."
),
e
)
else:
logger.error(
(
"Unable to auth to Neo4j, an error occurred: '%s'. driftdetect attempted to connect to Neo4j "
"with a username and password. Check your Neo4j server settings to see if the username and "
"password provided to driftdetect are valid credentials."
),
e
)
return
with neo4j_driver.session() as session:
drift_info_detector_pairs = perform_drift_detection(
session,
config.drift_detector_directory,
config.update
)
return drift_info_detector_pairs