Skip to content

Commit 3a32b13

Browse files
committed
obfuscated details
1 parent f0020c8 commit 3a32b13

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

0x00-personal_data/filtered_logger.py

+30
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def get_logger() -> logging.Logger:
4747
my_logger.propagate = False
4848
stream_handler = logging.StreamHandler()
4949
stream_handler.setFormatter(RedactingFormatter(PII_FIELDS))
50+
my_logger.addHandler(stream_handler)
5051
return my_logger
5152

5253

@@ -60,3 +61,32 @@ def get_db() -> mysql.connector.connection.MySQLConnection:
6061
host=HOST, database=DB, user=USERNAME, password=PASSWORD
6162
)
6263
return connect
64+
65+
66+
def main() -> None:
67+
"""The function will obtain a database connection using get_db
68+
and retrieve all rows in the users table"""
69+
my_logger = get_logger()
70+
db = get_db()
71+
cursor = db.cursor()
72+
cursor.execute("SELECT * FROM users")
73+
for (
74+
name,
75+
email,
76+
phone,
77+
ssn,
78+
password,
79+
ip,
80+
last_login,
81+
user_agent,
82+
) in cursor:
83+
user_details = "name={};email={};phone={};ssn={};"
84+
user_details += "password={};ip={};last_login={};user_agent={};".format
85+
(
86+
name, email, phone, ssn, password, ip, last_login, user_agent
87+
)
88+
my_logger.info(user_details)
89+
90+
91+
if __name__ == "__main__":
92+
main()

0 commit comments

Comments
 (0)