Skip to content

Conversation

@krishnprakash
Copy link
Owner

Potential fix for https://github.com/krishnprakash/cloudflare-docs/security/code-scanning/3

To fix the problem, we need to avoid logging the client_secret in clear text. Instead, we can log a message indicating that the service token was created without including the sensitive information. This way, we maintain the functionality of informing the user that the token was created while ensuring that sensitive data is not exposed.

We will modify the print statement on line 150 to exclude the client_secret. We will also add a note to the user to save the secrets without logging them.

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>
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.")
print(f"Created service token with client_id {client_id}. Please save the client_id and client_secret securely.")

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information

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

Copilot Autofix

AI 9 months ago

To fix the problem, we need to ensure that sensitive information such as client_id and client_secret is not logged in clear text. Instead, we can log a generic message indicating that a service token was created without including the sensitive details. This way, we maintain the functionality of informing the user about the creation of the service token without exposing sensitive information.

We will modify the code in public/cloudflare-one/static/authenticated-doh.py to remove the sensitive information from the log message on line 149.

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 @@
     client_id, client_secret = request_create_service_token(service_token_name)
-    print(f"Created service token with client_id {client_id}. Please save the client_id and client_secret securely.")
+    print("Created service token. Please save the client_id and client_secret securely.")
 
EOF
@@ -148,3 +148,3 @@
client_id, client_secret = request_create_service_token(service_token_name)
print(f"Created service token with client_id {client_id}. Please save the client_id and client_secret securely.")
print("Created service token. Please save the client_id and client_secret securely.")

Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@github-actions github-actions bot added size/m and removed size/xs labels Mar 13, 2025
@github-actions
Copy link

github-actions bot commented Mar 13, 2025

CI run failed: build logs

@krishnprakash krishnprakash marked this pull request as ready for review March 13, 2025 02:38
@krishnprakash krishnprakash merged commit 26f19f9 into production Mar 13, 2025
4 checks passed
@krishnprakash krishnprakash deleted the alert-autofix-3 branch March 13, 2025 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants