Debug error "0"

This debug output this:

[
  {'Grants for root@localhost': \"GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION\"},
  {'Grants for root@localhost': \"GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION\"}
],
[
  {'Grants for mysql.session@localhost': \"GRANT SUPER ON *.* TO 'mysql.session'@'localhost'\"},
  {'Grants for mysql.session@localhost': \"GRANT SELECT ON `performance_schema`.* TO 'mysql.session'@'localhost'\"},
  {'Grants for mysql.session@localhost': \"GRANT SELECT ON `mysql`.`user` TO 'mysql.session'@'localhost'\"}
 ],
 [
   {'Grants for mysql.sys@localhost': \"GRANT USAGE ON *.* TO 'mysql.sys'@'localhost'\"},
   {'Grants for mysql.sys@localhost': \"GRANT TRIGGER ON `sys`.* TO 'mysql.sys'@'localhost'\"},
   {'Grants for mysql.sys@localhost': \"GRANT SELECT ON `sys`.`sys_config` TO 'mysql.sys'@'localhost'\"}
 ],
 [
   {'Grants for root@%': \"GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION\"}
 ]

 I think something is wrong in the lambda and when grants art on ''@''.
This commit is contained in:
Laurent Indermuehle 2023-09-11 19:40:14 +02:00
parent d7beeec410
commit 31a5eb8739
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09

View file

@ -107,13 +107,16 @@ def get_tls_requires(cursor, user, host):
def get_grants(module, cursor, user, host):
cursor.execute("SHOW GRANTS FOR %s@%s", (user, host))
try:
grants_line = list(filter(lambda x: "ON *.*" in x[0], cursor.fetchall()))[0]
c = cursor.fetchall()
# grants_line = list(filter(lambda x: "ON *.*" in x[0], cursor.fetchall()))[0]
module.warn("%s" % c)
except Exception as e:
module.fail_json(msg="Error %s" % e)
pattern = r"(?<=\bGRANT\b)(.*?)(?=(?:\bON\b))"
grants = re.search(pattern, grants_line[0]).group().strip()
return grants.split(", ")
# pattern = r"(?<=\bGRANT\b)(.*?)(?=(?:\bON\b))"
# grants = re.search(pattern, grants_line[0]).group().strip()
# return grants.split(", ")
return "test"
def get_existing_authentication(cursor, user):