-
Notifications
You must be signed in to change notification settings - Fork 59
Add global tide prediction support via tidepredict library #248
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: SpudGunMan <[email protected]>
Co-authored-by: SpudGunMan <[email protected]>
Co-authored-by: SpudGunMan <[email protected]>
| result = locationdata.get_NOAAtide(str(lat), str(lon)) | ||
| if result and "Error" not in result: | ||
| print(f"✓ NOAA API returned data") | ||
| print(f" First 100 chars: {result[:100]}") |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High test
sensitive data (private)
This expression logs
sensitive data (private)
This expression logs
sensitive data (private)
This expression logs
sensitive data (private)
This expression logs
sensitive data (private)
This expression logs
sensitive data (private)
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 13 days ago
To fix the problem, we must prevent clear-text logging of potentially sensitive location data in the test script. Specifically, in modules/test_xtide.py, line 68, instead of printing the first 100 characters of the tide table returned by NOAA—which may contain location-specific tide info—we should log a generic message confirming data was received, without exposing the returned payload.
Best approach: Replace print(f" First 100 chars: {result[:100]}") in test_noaa_fallback() with a generic log such as print(" (tide data received, not displayed for privacy)"). Similarly, in the branch at line 71 (potential error or abnormal result), avoid printing raw result, and print only "⚠ NOAA API returned: <hidden>" or similar.
No additional imports, methods, or definitions are needed, just a direct edit to the messages printed in this function.
-
Copy modified line R68 -
Copy modified line R71
| @@ -65,10 +65,10 @@ | ||
| result = locationdata.get_NOAAtide(str(lat), str(lon)) | ||
| if result and "Error" not in result: | ||
| print(f"✓ NOAA API returned data") | ||
| print(f" First 100 chars: {result[:100]}") | ||
| print(" (tide data received, not displayed for privacy)") | ||
| return True | ||
| else: | ||
| print(f"⚠ NOAA API returned: {result[:100]}") | ||
| print("⚠ NOAA API returned: <hidden>") | ||
| return True # Still pass as network might not be available | ||
| except Exception as e: | ||
| print(f"⚠ NOAA test encountered expected issue: {e}") |
| print(f" First 100 chars: {result[:100]}") | ||
| return True | ||
| else: | ||
| print(f"⚠ NOAA API returned: {result[:100]}") |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High test
sensitive data (private)
This expression logs
sensitive data (private)
This expression logs
sensitive data (private)
This expression logs
sensitive data (private)
This expression logs
sensitive data (private)
This expression logs
sensitive data (private)
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 13 days ago
To fix the problem, we need to prevent the cleartext logging of sensitive data, specifically any content derived directly from user location or related API responses. In this script, the offending line is:
print(f"⚠ NOAA API returned: {result[:100]}")The best way to mitigate the risk is to avoid logging any part of result directly if it could contain sensitive data. Instead, we can log a generic message indicating the failure or error, possibly along with a code or indicator, without including the result content itself. This preserves the functionality (letting users know that something unexpected happened) without risking the exposure of sensitive data.
Steps:
- In
test_noaa_fallback(), replace the print statement that outputs a portion ofresultwith a generic message, such as:print("⚠ NOAA API returned an unexpected response or error (details omitted for privacy)")
- No imports or method definitions are necessary beyond this direct code edit.
-
Copy modified line R71
| @@ -68,7 +68,7 @@ | ||
| print(f" First 100 chars: {result[:100]}") | ||
| return True | ||
| else: | ||
| print(f"⚠ NOAA API returned: {result[:100]}") | ||
| print("⚠ NOAA API returned an unexpected response or error (details omitted for privacy)") | ||
| return True # Still pass as network might not be available | ||
| except Exception as e: | ||
| print(f"⚠ NOAA test encountered expected issue: {e}") |
The current tide command uses NOAA API, limiting functionality to US locations. This adds optional global tide prediction using the tidepredict library, which provides offline predictions from University of Hawaii's Research Quality Dataset (600+ worldwide stations).
Implementation
New module
modules/xtide.pyIntegration in
modules/locationdata.pyConfiguration
useTidePredictboolean to[location]section in config.iniNotes
~/.tidepredict/Documentation
modules/xtide.md: Setup, troubleshooting, data sourcestest_xtide.pyWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
api.tidesandcurrents.noaa.govpython3 test_xtide.py(dns block)ftp.soest.hawaii.edupython3(dns block)python3 -c from tidepredict import process_station_list import traceback try: print('Attempting to download station list...') stations = process_station_list.create_station_dataframe() print(f'Downloaded {len(stations)} stations') print(stations.head()) except Exception as e: print(f'Error: {e}') traceback.print_exc()(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.