Use opengribs.org API#111
Conversation
d9cc2b4 to
a95a59f
Compare
a95a59f to
6126072
Compare
7c6923d to
a28aac7
Compare
| """ | ||
| bbox = create_opengribs_bounding_box(longitude, latitude) | ||
| download_url = request_opengribs_file(bbox) | ||
| logger.info(f"Got GRIBS file {download_url} for {bbox}") |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
In general, to fix clear-text logging of sensitive data, remove sensitive fields from log messages or replace them with non-sensitive summaries (e.g., IDs, coarse buckets, or hashes) while preserving enough context for debugging. When you need to trace operations without exposing raw values, log an opaque identifier or a redacted/rounded representation instead of exact data.
For this specific issue, the problem is that logger.info(f"Got GRIBS file {download_url} for {bbox}") logs a bounding box derived from sensitive coordinates. The simplest fix that preserves behavior is to stop logging bbox entirely or replace it with a non-sensitive placeholder. Since download_url is already sufficient to understand what has been retrieved operationally, we can modify the log line to only mention the URL, or, if more context is needed, log the filename derived from the URL. No changes are required to how the data is requested or processed; only the log message string needs adjustment.
Concretely, in opendrift_leeway_webgui/leeway/utils.py at line 305, change the log call to avoid embedding the bbox dict (and thus latitude/longitude-derived values). For example:
logger.info("Got GRIBS file %s", download_url)or, if you want slightly more context without coordinates:
logger.info("Got GRIBS file for OpenGRIBS request: %s", download_url)This requires no new imports or helper methods, and it addresses all alert variants since every tainted path flows into bbox in that single log call.
| @@ -302,5 +302,5 @@ | ||
| """ | ||
| bbox = create_opengribs_bounding_box(longitude, latitude) | ||
| download_url = request_opengribs_file(bbox) | ||
| logger.info(f"Got GRIBS file {download_url} for {bbox}") | ||
| logger.info("Got GRIBS file %s", download_url) | ||
| return get_opengribs_file(download_url) |
a28aac7 to
f4e4197
Compare
| str(simulation.uuid), | ||
| "--no-web", | ||
| ] | ||
| print(" ".join(params)) |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
In general, to fix clear‑text logging of sensitive data you should avoid logging raw user-derived values or full command lines containing such values. Either remove the log, reduce it to non-sensitive, high-level information, or explicitly redact the sensitive fields before logging.
For this specific case, the minimal, non‑functional change is to stop printing the full docker command string containing simulation.longitude and simulation.latitude. Since this is a Celery task that already uses a logger, the best fix is to replace the print(" ".join(params)) with a safer debug message that omits or redacts sensitive parameters while still giving some context (e.g., logging only the simulation UUID or that a simulation is starting). This avoids introducing new behavior while retaining observability. No other parts of the snippet require changes, and no new imports or helper methods are needed.
Concretely:
- In
opendrift_leeway_webgui/leeway/tasks.py, at line 56, replaceprint(" ".join(params))with alogger.debugcall that does not include longitude/latitude or any other sensitive data. For example:logger.debug("Starting leeway simulation %s", simulation.uuid). - Leave all other lines as-is.
| @@ -53,7 +53,7 @@ | ||
| str(simulation.uuid), | ||
| "--no-web", | ||
| ] | ||
| print(" ".join(params)) | ||
| logger.debug("Starting leeway simulation %s", simulation.uuid) | ||
| with subprocess.Popen( | ||
| params, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True | ||
| ) as sim_proc: |
| filename = os.path.join(settings.SIMULATION_ROOT, "input", url.split("/")[-1]) | ||
| with open(filename, "wb") as f: | ||
| for chunk in response.iter_content(chunk_size=1024): | ||
| f.write(chunk) |
Check failure
Code scanning / CodeQL
Clear-text storage of sensitive information High
Copilot Autofix
AI 5 months 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.
Use opengribs.org to fetch sea currents and wind data. We first have to request a GRIBS file via the API. The API then returns a download path after a few seconds. The file is downloaded into the simulation input directory and should automatically be used.
Fix #74