Skip to content

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

Merged
erseco merged 1 commit intomainfrom
alert-autofix-6
Apr 2, 2026
Merged

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

Conversation

@erseco
Copy link
Copy Markdown
Owner

@erseco erseco commented Mar 31, 2026

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

To fix the issue, we should ensure that no log entry ever includes the password (or other secrets), and ideally avoid logging any structure derived directly from tainted data. Instead of copying and redacting the full payload, we can log only non-sensitive fields and static information, such as the URL and username, which are not secrets. That way, the debug log still provides useful context while guaranteeing that the password is not even indirectly part of the logged object.

Concretely, in src/py_moodle/auth.py inside _standard_login, we will replace the current debug block that creates redacted_payload and logs payload={redacted_payload} with a simpler message that mentions only the login URL and the username. This removes any dependency on the password field and should satisfy CodeQL for all alert variants tied to this location. The tests in tests/conftest.py do not perform any logging of the password—they only pass it to login—so they do not need code changes for this specific “clear-text logging” issue.

No new imports or helper methods are needed; we will only adjust the existing if self.debug: block around line 122 in src/py_moodle/auth.py.


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

@erseco erseco marked this pull request as ready for review March 31, 2026 10:47
…nsitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@erseco erseco merged commit be1c84e into main Apr 2, 2026
13 checks passed
@erseco erseco deleted the alert-autofix-6 branch April 2, 2026 17:27
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