Skip to content

Conversation

@kamalgovindgj
Copy link

No description provided.

def _send_request_sync(self, request: Request) -> httpx.Response:
return self._core_send_request(self.client, request)
url, headers = self._prepare_request(request)
print(f"Making request to: {url}")

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

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

Copilot Autofix

AI 11 months ago

To fix the problem, we need to ensure that sensitive information such as request.secret is not logged. The best way to do this without changing existing functionality is to sanitize the url before logging it. We can replace sensitive parts of the url with placeholders before logging.

Specifically, we will:

  1. Create a function to sanitize the url by replacing sensitive information with placeholders.
  2. Use this function to sanitize the url before logging it.
Suggested changeset 1
javelin_sdk/client.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/javelin_sdk/client.py b/javelin_sdk/client.py
--- a/javelin_sdk/client.py
+++ b/javelin_sdk/client.py
@@ -118,3 +118,4 @@
         url, headers = self._prepare_request(request)
-        print(f"Making request to: {url}")
+        sanitized_url = self._sanitize_url(url)
+        print(f"Making request to: {sanitized_url}")
         print(f"With headers: {headers}")
@@ -126,2 +127,6 @@
 
+    def _sanitize_url(self, url: str) -> str:
+        # Replace sensitive information with placeholders
+        sanitized_url = url.replace(request.secret, "[SECRET]")
+        return sanitized_url
 
EOF
@@ -118,3 +118,4 @@
url, headers = self._prepare_request(request)
print(f"Making request to: {url}")
sanitized_url = self._sanitize_url(url)
print(f"Making request to: {sanitized_url}")
print(f"With headers: {headers}")
@@ -126,2 +127,6 @@

def _sanitize_url(self, url: str) -> str:
# Replace sensitive information with placeholders
sanitized_url = url.replace(request.secret, "[SECRET]")
return sanitized_url

Copilot is powered by AI and may make mistakes. Always verify output.
return self._core_send_request(self.client, request)
url, headers = self._prepare_request(request)
print(f"Making request to: {url}")
print(f"With headers: {headers}")

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

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

Copilot Autofix

AI 11 months ago

To fix the problem, we should avoid logging sensitive information such as headers and URLs directly. Instead, we can log non-sensitive parts of the request or use a sanitized version of the headers and URLs. Specifically, we can remove or mask sensitive information before logging.

  1. Identify the lines where sensitive information is being logged.
  2. Modify the logging statements to exclude or mask sensitive data.
  3. Ensure that the functionality of the code remains unchanged.
Suggested changeset 1
javelin_sdk/client.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/javelin_sdk/client.py b/javelin_sdk/client.py
--- a/javelin_sdk/client.py
+++ b/javelin_sdk/client.py
@@ -118,7 +118,6 @@
         url, headers = self._prepare_request(request)
-        print(f"Making request to: {url}")
-        print(f"With headers: {headers}")
+        print("Making request")
         response = self._core_send_request(self.client, request) 
         print(f"Response status: {response.status_code}")
-        print(f"Response body: {response.text}")
+        print("Response received")
         return response
EOF
@@ -118,7 +118,6 @@
url, headers = self._prepare_request(request)
print(f"Making request to: {url}")
print(f"With headers: {headers}")
print("Making request")
response = self._core_send_request(self.client, request)
print(f"Response status: {response.status_code}")
print(f"Response body: {response.text}")
print("Response received")
return response
Copilot is powered by AI and may make mistakes. Always verify output.



#def check_permissions():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uncomment this code

@abhijitjavelin
Copy link
Contributor

jfyi, pr merger check will fail if you dont use formats like 'fix: ' or 'feat: ' in commit msgs.

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.

3 participants