From b2ee1246b174e5d891f7b82a200eda34a7202188 Mon Sep 17 00:00:00 2001 From: Clemens Hahn Date: Mon, 21 Jul 2025 09:42:03 +0200 Subject: [PATCH 1/3] mask sensitive config values in logs if PRINT_CONFIGURATION is enabled --- .env | 3 ++- developer_README.md | 2 ++ sdk/moveapps_execution.py | 18 +++++++++++++++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.env b/.env index d14e29e..e0b3857 100644 --- a/.env +++ b/.env @@ -1,3 +1,4 @@ SOURCE_FILE=./resources/samples/input1_LatLon.pickle # development settings -CONFIGURATION_FILE=./app-configuration.json \ No newline at end of file +CONFIGURATION_FILE=./app-configuration.json +PRINT_CONFIGURATION=yes \ No newline at end of file diff --git a/developer_README.md b/developer_README.md index 236b46d..d01c4e3 100644 --- a/developer_README.md +++ b/developer_README.md @@ -33,6 +33,8 @@ Critical parts of the SDK can be adjusted by `environment variables`. Keep in mi - `SOURCE_FILE`: path to the input file for your App. - `CONFIGURATION_FILE`: path to the configuration/settings file of your App (in [JSON](https://www.w3schools.com/js/js_json_intro.asp) format - must correspondent with the `settings` of your `appspec.json`, see [MoveApps parameters](https://docs.moveapps.org/#/copilot-python-sdk.md#moveapps-parameters) for an example of the `app-configuration.json` file). +- `PRINT_CONFIGURATION`: prints the configuration your App receives (`yes|no`) +- `MASK_SETTING_IDS`: A comma-separated list of setting IDs whose values will be hidden in the SDK logs You can adjust these environment variables by adjusting the file `./.env`. diff --git a/sdk/moveapps_execution.py b/sdk/moveapps_execution.py index b915bcb..4d0f854 100644 --- a/sdk/moveapps_execution.py +++ b/sdk/moveapps_execution.py @@ -59,10 +59,22 @@ def __load_config(): else: config = os.environ.get('CONFIGURATION', '{}') parsed = json.loads(config) + if os.environ.get("PRINT_CONFIGURATION", "no") == "yes": - logging.info(f'app will be started with configuration: {parsed}') + # Create a copy of parsed for logging + logging_config = parsed.copy() + # Get and process MASK_SETTING_IDS + mask_setting_ids = os.environ.get('MASK_SETTING_IDS', '').strip() + if mask_setting_ids: + # Split by comma and trim each value + mask_keys = [key.strip() for key in mask_setting_ids.split(',')] + # Replace values with "***masked***" for specified keys in the logging copy + for key in mask_keys: + if key in logging_config: + logging_config[key] = "***masked***" + logging.info(f'app will be started with configuration: {logging_config}') return parsed - + def __store_output(self, data): logging.info(f'storing output: {data}') pd.to_pickle(data, self.env.output_file) @@ -74,4 +86,4 @@ def __store_error(self, error: Exception): def __call_app(self, data): outputs = self._pm.hook.execute(data=data, config=self.env.app_configuration) - return outputs[0] + return outputs[0] \ No newline at end of file From 01a6b5b5d3fb8b5d97daa8806aa7f03c958f888e Mon Sep 17 00:00:00 2001 From: Clemens Hahn Date: Mon, 21 Jul 2025 09:46:26 +0200 Subject: [PATCH 2/3] update changelog for upcoming v2.3.0 and miniforge switch --- CHANGELOG_SDK.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG_SDK.md b/CHANGELOG_SDK.md index 4686e5c..0f8327e 100644 --- a/CHANGELOG_SDK.md +++ b/CHANGELOG_SDK.md @@ -1,5 +1,13 @@ # Changelog SDK +## 2025-07 `v2.3.0` + +- introduce app-setting-type `SECRET` + +## 2024-09 + +- switch to [miniforge](https://github.com/conda-forge/miniforge) + ## 2024-03 `v2.1.0` - introduce app-setting-type `USER_FILE` From db3e8aad3908f5b1fb06ea4a237d31437e669afe Mon Sep 17 00:00:00 2001 From: Clemens Hahn Date: Mon, 21 Jul 2025 09:48:24 +0200 Subject: [PATCH 3/3] add version number to September 2024 changelog entry --- CHANGELOG_SDK.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG_SDK.md b/CHANGELOG_SDK.md index 0f8327e..ae32285 100644 --- a/CHANGELOG_SDK.md +++ b/CHANGELOG_SDK.md @@ -4,7 +4,7 @@ - introduce app-setting-type `SECRET` -## 2024-09 +## 2024-09 `v2.2.1` - switch to [miniforge](https://github.com/conda-forge/miniforge)