Skip to content
Open
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
27 changes: 27 additions & 0 deletions secret_sample2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# APS test
import requests

# Sample API key (dummy for testing purposes)
api_key = "1234567890abcdef1234567890abcdef"

# Sample username and password
username = "testuser"
password = "testpassword123"

def make_request():
url = "https://api.example.com/data"
headers = {
"Authorization": f"Bearer {api_key}"
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
print("Request successful!")
else:
print("Failed request")

def main():
print(f"Using credentials: {username} / {password}")

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information

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

Copilot Autofix

AI over 1 year ago

To fix the problem, we need to remove the logging of sensitive information. Specifically, we should avoid printing the username and password in clear text. Instead, we can log a message indicating that credentials are being used without revealing the actual values.

  • Remove the line that logs the username and password.
  • Replace it with a generic log message that does not include sensitive information.
Suggested changeset 1
secret_sample2.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/secret_sample2.py b/secret_sample2.py
--- a/secret_sample2.py
+++ b/secret_sample2.py
@@ -22,3 +22,3 @@
 def main():
-    print(f"Using credentials: {username} / {password}")
+    print("Using credentials to make the request")
     make_request()
EOF
@@ -22,3 +22,3 @@
def main():
print(f"Using credentials: {username} / {password}")
print("Using credentials to make the request")
make_request()
Copilot is powered by AI and may make mistakes. Always verify output.
make_request()

if __name__ == "__main__":
main()