Skip to content

Potential fix for code scanning alert no. 4: Clear-text logging of sensitive information#1

Merged
erseco merged 1 commit intomainfrom
alert-autofix-4
Aug 4, 2025
Merged

Potential fix for code scanning alert no. 4: Clear-text logging of sensitive information#1
erseco merged 1 commit intomainfrom
alert-autofix-4

Conversation

@erseco
Copy link
Owner

@erseco erseco commented Aug 4, 2025

Potential fix for https://github.com/erseco/python-moodle/security/code-scanning/4

To fix the problem, we should ensure that sensitive information (specifically, the password) is never logged, even in debug mode. The best way to do this is to redact or omit the password field from the payload before logging. We can create a shallow copy of the payload, replace the password value with a placeholder (e.g., "***REDACTED***"), and log this sanitized version instead. This change should be made only in the debug log statement on line 163 in the _cas_login method. No changes to functionality are required, and no new imports are needed.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…nsitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
redacted_payload = payload.copy()
if "password" in redacted_payload:
redacted_payload["password"] = "***REDACTED***"
print(f"[DEBUG] POST {cas_login_url} payload={redacted_payload}")

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.
This expression logs
sensitive data (password)
as clear text.

Copilot Autofix

AI 8 months ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

@erseco erseco marked this pull request as ready for review August 4, 2025 21:26
@erseco erseco merged commit ac774cb into main Aug 4, 2025
6 of 7 checks passed
@erseco erseco deleted the alert-autofix-4 branch August 4, 2025 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant