-
Notifications
You must be signed in to change notification settings - Fork 0
🛡️ Sentinel: [MEDIUM] Fix Information Leakage #158
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ def fetch_grades_route(): | |
| return jsonify({'success': True, 'message': '成績已更新', 'data': data}) | ||
| except Exception as exc: | ||
| logger.error(f'Error fetching grades (API): {exc}', exc_info=True) | ||
| return jsonify({'success': False, 'error': str(exc)}), 500 | ||
| return jsonify({'success': False, 'error': '伺服器內部錯誤'}), 500 | ||
|
|
||
|
|
||
| @bp.route('/api/structure', methods=['GET']) | ||
|
|
@@ -64,7 +64,7 @@ def get_structure_route(): | |
| return jsonify({'structure': structure}) | ||
| except Exception as exc: | ||
| logger.error(f'Error getting structure (API): {exc}', exc_info=True) | ||
| return jsonify({'error': str(exc)}), 500 | ||
| return jsonify({'error': '伺服器內部錯誤'}), 500 | ||
|
Comment on lines
65
to
+67
|
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,8 +81,8 @@ def create_share_link(): | |
| write_share_metadata(redis_client, share_id, student_no, share_ttl) | ||
| return jsonify({'success': True, 'id': share_id}) | ||
| except Exception as exc: | ||
| logger.error(f'Error creating share: {exc}', exc_info = True) | ||
| return jsonify({'error': str(exc)}), 500 | ||
| logger.error(f'Error creating share: {exc}', exc_info=True) | ||
| return jsonify({'error': '伺服器內部錯誤'}), 500 | ||
|
Comment on lines
83
to
+85
|
||
|
|
||
|
|
||
| @bp.route('/api/share/<share_id>', methods=['PUT']) | ||
|
|
@@ -147,7 +147,7 @@ def update_share_link(share_id): | |
| return jsonify({'success': True, 'id': share_id}) | ||
| except Exception as exc: | ||
| logger.error(f'Error updating share: {exc}', exc_info=True) | ||
| return jsonify({'error': str(exc)}), 500 | ||
| return jsonify({'error': '伺服器內部錯誤'}), 500 | ||
|
Comment on lines
148
to
+150
|
||
|
|
||
|
|
||
| @bp.route('/api/share/<share_id>', methods=['GET']) | ||
|
|
@@ -166,8 +166,8 @@ def get_shared_grades(share_id): | |
|
|
||
| return jsonify({'success': True, 'data': data}) | ||
| except Exception as exc: | ||
| logger.error(f'Error reading share: {exc}', exc_info = True) | ||
| return jsonify({'error': str(exc)}), 500 | ||
| logger.error(f'Error reading share: {exc}', exc_info=True) | ||
| return jsonify({'error': '伺服器內部錯誤'}), 500 | ||
|
Comment on lines
168
to
+170
|
||
|
|
||
|
|
||
| @bp.route('/share/<share_id>') | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,11 +50,11 @@ def health_check(): | |
| redis_client.ping() | ||
| redis_status = 'connected' | ||
| except Exception as e: | ||
| logger.error(f'Health check: Redis ping failed: {e}') | ||
| logger.error(f'Health check: Redis ping failed: {e}', exc_info=True) | ||
| return jsonify({ | ||
| 'status': 'error', | ||
| 'redis': 'disconnected', | ||
| 'detail': str(e), | ||
| 'detail': '伺服器內部錯誤', | ||
| }), 503 | ||
|
Comment on lines
52
to
58
|
||
|
|
||
| return jsonify({'status': 'ok', 'redis': redis_status}), 200 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,7 +129,7 @@ def login_and_get_tokens(self, username, password): | |
|
|
||
| except Exception as e: | ||
| _log('error', username, f"Login Exception: {e}") | ||
| return False, f"登入錯誤: {str(e)}", None, None, None | ||
| return False, "登入錯誤: 伺服器內部錯誤", None, None, None | ||
|
Comment on lines
130
to
+132
|
||
|
|
||
| def get_structure_via_api(self, cookies, student_no, token, session=None): | ||
| """Fetch structure using requests""" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are backend tests in the repo, but none appear to cover this updated 500 response path. Please add a regression test that makes
fetch_grades(...)raise and asserts the route returns the generic error message (and does not leak the exception text).