Skip to content
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

Dev noa UI #105

Merged
merged 19 commits into from
Dec 31, 2024
Merged

Dev noa UI #105

merged 19 commits into from
Dec 31, 2024

Conversation

fbalaban
Copy link
Member

Closes #104

@fbalaban fbalaban self-assigned this Dec 31, 2024
@fbalaban fbalaban linked an issue Dec 31, 2024 that may be closed by this pull request
response.raise_for_status()

except requests.exceptions.RequestException as e:
return JsonResponse({"error": str(e)}, status=500)

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix AI 24 days ago

To fix the problem, we need to modify the exception handling code to log the detailed error message on the server and return a generic error message to the user. This will prevent sensitive information from being exposed while still allowing developers to access the necessary details for debugging.

  1. Import the logging module to enable logging of error messages.
  2. Configure the logging settings if not already configured.
  3. Modify the exception handling block to log the detailed error message and return a generic error message to the user.
Suggested changeset 1
noa-ui/browser/views.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/noa-ui/browser/views.py b/noa-ui/browser/views.py
--- a/noa-ui/browser/views.py
+++ b/noa-ui/browser/views.py
@@ -4,2 +4,3 @@
 import os
+import logging
 
@@ -13,2 +14,3 @@
 
+logging.basicConfig(level=logging.ERROR)
 API_BASE_URL = "http://10.201.40.192:30080/api/SatelliteProduct/GetAll"
@@ -63,3 +65,4 @@
         except requests.exceptions.RequestException as e:
-            return JsonResponse({"error": str(e)}, status=500)
+            logging.error("RequestException: %s", str(e))
+            return JsonResponse({"error": "An internal error has occurred."}, status=500)
 
EOF
@@ -4,2 +4,3 @@
import os
import logging

@@ -13,2 +14,3 @@

logging.basicConfig(level=logging.ERROR)
API_BASE_URL = "http://10.201.40.192:30080/api/SatelliteProduct/GetAll"
@@ -63,3 +65,4 @@
except requests.exceptions.RequestException as e:
return JsonResponse({"error": str(e)}, status=500)
logging.error("RequestException: %s", str(e))
return JsonResponse({"error": "An internal error has occurred."}, status=500)

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

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
result['quicklook'] = f"https://datahub.creodias.eu/odata/v1/Assets({result['uuid']})/$value"
return results
except requests.RequestException as e:
return JsonResponse({"error": f"API request failed: {str(e)}"}, status=500)

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix AI 24 days ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

}, status=400)

except requests.exceptions.RequestException as e:
return JsonResponse({"error": str(e)}, status=500)

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix AI 24 days ago

To fix the problem, we need to ensure that detailed exception messages are not exposed to the end user. Instead, we should log the detailed error message on the server and return a generic error message to the user. This can be achieved by modifying the exception handling in the submit_order function to log the exception and return a generic error message.

  • Modify the exception handling block in the submit_order function to log the detailed error message and return a generic error message.
  • Add the necessary import for logging and configure the logger if not already done.
Suggested changeset 1
noa-ui/browser/views.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/noa-ui/browser/views.py b/noa-ui/browser/views.py
--- a/noa-ui/browser/views.py
+++ b/noa-ui/browser/views.py
@@ -1,2 +1,3 @@
 import requests
+import logging
 from datetime import datetime
@@ -16,2 +17,4 @@
 
+logger = logging.getLogger(__name__)
+logging.basicConfig(level=logging.ERROR)
 def map_view(request):
@@ -207,3 +210,4 @@
         except requests.exceptions.RequestException as e:
-            return JsonResponse({"error": str(e)}, status=500)
+            logger.error(f"Error submitting order: {e}")
+            return JsonResponse({"error": "An internal error has occurred. Please try again later."}, status=500)
     
EOF
@@ -1,2 +1,3 @@
import requests
import logging
from datetime import datetime
@@ -16,2 +17,4 @@

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.ERROR)
def map_view(request):
@@ -207,3 +210,4 @@
except requests.exceptions.RequestException as e:
return JsonResponse({"error": str(e)}, status=500)
logger.error(f"Error submitting order: {e}")
return JsonResponse({"error": "An internal error has occurred. Please try again later."}, status=500)

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

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@fbalaban fbalaban merged commit c8a60ec into main Dec 31, 2024
2 checks passed
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.

Merge ui to main
2 participants