github-advanced-security[bot] commented on code in PR #45696: URL: https://github.com/apache/airflow/pull/45696#discussion_r1917413841
########## airflow/auth/managers/simple/simple_auth_manager.py: ########## @@ -97,31 +101,36 @@ users = [u.split(":") for u in conf.getlist("core", "simple_auth_manager_users")] return [{"username": username, "role": role} for username, role in users] - def init(self) -> None: + @staticmethod + def get_passwords(users: list[dict[str, str]]) -> dict[str, str]: user_passwords_from_file = {} # Read passwords from file - if os.path.isfile(self.get_generated_password_file()): - with open(self.get_generated_password_file()) as file: + password_file = SimpleAuthManager.get_generated_password_file() + if os.path.isfile(password_file): + with open(password_file) as file: passwords_str = file.read().strip() user_passwords_from_file = json.loads(passwords_str) - users = self.get_users() usernames = {user["username"] for user in users} - self.passwords = { + return { username: password for username, password in user_passwords_from_file.items() if username in usernames } + + def init(self) -> None: + users = self.get_users() + passwords = self.get_passwords(users) for user in users: - if user["username"] not in self.passwords: + if user["username"] not in passwords: # User dot not exist in the file, adding it - self.passwords[user["username"]] = self._generate_password() + passwords[user["username"]] = self._generate_password() - self._print_output(f"Password for user '{user['username']}': {self.passwords[user['username']]}") + self._print_output(f"Password for user '{user['username']}': {passwords[user['username']]}") with open(self.get_generated_password_file(), "w") as file: - file.write(json.dumps(self.passwords)) + file.write(json.dumps(passwords)) Review Comment: ## Clear-text storage of sensitive information This expression stores [sensitive data (password)](1) as clear text. This expression stores [sensitive data (password)](2) as clear text. This expression stores [sensitive data (password)](3) as clear text. This expression stores [sensitive data (password)](4) as clear text. [Show more details](https://github.com/apache/airflow/security/code-scanning/347) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org