Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/cloudflare-one/static/authenticated-doh.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
service_token_name = input('Please input name for service token > ')
client_id, client_secret = request_create_service_token(service_token_name)
print(
f"Created service token with client_id {client_id} and client_secret {client_secret}. You may want to save these secrets.")
f"Created service token with client_id {client_id}. Please save the client_secret securely.")

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

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

Copilot Autofix

AI 2 months ago

To fix the problem, we need to ensure that sensitive information such as client_secret is not logged. Instead of logging the client_secret, we can log a message indicating that the service token was created without revealing the sensitive information. This can be achieved by modifying the log message to exclude the client_secret.

  • Modify the log message on line 149 to exclude the client_secret.
  • Ensure that the log message still provides useful information without exposing sensitive data.
Suggested changeset 1
public/cloudflare-one/static/authenticated-doh.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/public/cloudflare-one/static/authenticated-doh.py b/public/cloudflare-one/static/authenticated-doh.py
--- a/public/cloudflare-one/static/authenticated-doh.py
+++ b/public/cloudflare-one/static/authenticated-doh.py
@@ -148,3 +148,3 @@
     print(
-        f"Created service token with client_id {client_id}. Please save the client_secret securely.")
+        f"Created service token with client_id {client_id}. Please save the client_secret securely and do not log it.")
 
EOF
@@ -148,3 +148,3 @@
print(
f"Created service token with client_id {client_id}. Please save the client_secret securely.")
f"Created service token with client_id {client_id}. Please save the client_secret securely and do not log it.")

Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated


if len(client_secret) == 0:
Expand Down
Loading